NSClient++ Help (#1) - .bat files via nsca on nscp 4.0.170 (#967) - Message List
Hello everyone i've set up my nagios now and everything is working fine with the nsclient. At the moment im only using nsca and everything seems to be ok. The only thing i dont get is how i include .bat scripts in my nsclient.ini config, without getting errors in the nsclient.log. I have tried a lot, but always got the error:
2012-05-08 11:24:15: e:..\..\..\trunk\service\NSClient++.cpp:943: No handler for command: scripts\check_fb.bat avalible commands: commands {, a-check-win-cpu, a-check-win-disk, a-check-win-fb, a-check-win-ram, a-check-win-service, check_eventlog, check_eventlog_cache, check_nscp, check_ok, checkalwayscritical, checkalwaysok, checkalwayswarning, checkcounter, checkcpu, checkcritical, checkdrivesize, checkeventlog, checkeventlogcache, checkfile2, checkfiles, checkfilesize, checkmem, checkmultiple, checkok, checkprocstate, checkservicestate, checksingleregentry, checkuptime, checkversion, checkwarning, checkwmi, checkwmivalue, listcounterinstances, nsca_exec, nsca_forward, nsca_help, nsca_query, nsca_submit}, plugins {, 0, 1, 2, 3, 4, 5, 6, 7}
2012-05-08 11:24:15: e:..\..\..\..\trunk\include\nscapi\nscapi_core_wrapper.cpp:181: No handler for command 'scripts\check_fb.bat'.
2012-05-08 11:24:15: e:..\..\..\..\trunk\include\nscapi\nscapi_core_wrapper.cpp:181: No handler for command 'a-check-win-fb'.
2012-05-08 11:24:15: e:..\..\..\..\trunk\modules\Scheduler\Scheduler.cpp:122: Command was not found: a-check-win-fb
and i couldnt find a sample for including .bat files via nsca (>= 4.0 ) anywhere.. :S (found only threads about previous versions..) Im sure im doing it wrong so posting my current config would not make sense... Anyone who could show me a little sample? maybe with a .bat with 2 arguments? :)
-
Message #2568
Not sure if you are upgrading from previous version. But if so you can use the old config and/or upgrade the old config.
If not using old config I would recommend the following approach: Edit you nsclient.ini like so:
[/modules] CheckExternalScripts=1
(yes, very short)
Then run:
nscp settings --generate ini --add-defaults
And it will fill your config with available keys.. You will find a section called something along the lines of: /settings/external scripts/scripts where you can add key=script. Key will be you nsca/nrpe command and script will be the script you want. There is also a few simplification you can do by using something called wrapped scripts...
If you want I can create an example sample when I get home (dont have nsclient++ at work)...
Michael Medin
mickem05/08/12 13:44:18 (13 months ago)-
Message #2569
Thank you for quick answer!
well i can show you what i've configured, so its probably easier to see whats wrong.. how i alrdy said.. the other things work fine :)
[/modules] CheckDisk = 1 CheckEventLog = 1 CheckExternalScripts = 1 CheckHelpers = 1 CheckNSCP = 1 CheckSystem = 1 CheckWMI = 1 NRPEServer = 0 NSCAClient = 1 NSClientServer = 1 Scheduler = 1 [/settings/default] allowed hosts = 192.168.0.167 ;password=omd-secret [/settings/NSCA/client] hostname = martinpc [/settings/NSCA/client/targets/default] encryption = 1 host = 192.168.0.167 port = 5667 password = omd-secret [/settings/scheduler/schedules/default] channel = NSCA interval = 30s report = all [/settings/external scripts] ;script path =\scripts\ allow arguments = 1 allow nasty characters = 1 command timeout = 60 [/settings/external scripts/alias] a-check-win-cpu = checkCPU warn=$ARG1$ crit=$ARG2$ time=20m time=5m time=5s a-check-win-ram = CheckMEM MaxWarn=$ARG1$% MaxCrit=$ARG2$% ShowAll type=physical a-check-win-disk= CheckDriveSize MaxWarn=$ARG1$% MaxCrit=$ARG2$% FilterType=FIXED Drive=C a-check-win-service= checkservicestate $ARG1$ $ARG2$ a-check-win-fb=scripts\check_fb.bat "C:\\Program Files (x86)\\Firebird\\Firebird_2_5\\bin\\" "C:\\Programme3\\TopControl\\Fruitmanager\\Daten\\" "10000" "20000" [/settings/log] date mask = %Y-%m-%d %H:%M:%S file name = nsclient.log [/settings/scheduler/default] interval = 30s [/settings/scheduler/schedules] cpu_check = a-check-win-cpu "80" "90" ram_check = a-check-win-ram "80" "90" disk_check = a-check-win-disk "80" "90" service_check= a-check-win-service "uvnc_service" "FirebirdServerDefaultInstance" fb_check=a-check-win-fb
im new to nagios, im not using an old config.. im trying to get it running now for 3-4 days and it now im at a point where im stuck. :) i try to include a check_fb.bat which i put in the scripts folder.. the check_fb accepts 4 Arguments, the first two are Paths.. the 3d is the warn value and the 4th the crit value... just to let you know...
tjtj805/08/12 14:05:42 (13 months ago)-
Message #2570
aliases and script are different: [/settings/external scripts/alias] is used for "internal command" and [/settings/external scripts/scripts] is used for external (batch/vbs/exe/*) commands...
So just move a-check-win-fb over to the .../scripts section and you should be good to go...
Once your done start nsclient++ in test mode:
nscp test ... commands ... a-check-win-fb ...
Michael Medin
mickem05/08/12 14:16:52 (13 months ago)-
Message #2571
Thank you! i now finally see the nsclient is sending back sth to the nagios server. But now i've got this error
2012-05-08 14:24:28: e:d:\source\nscp\trunk\modules\checkexternalscripts\commands.hpp:89: Failed to parse arguments for command 'a-check-win-fb', using old split string method: unknown escape sequence: scripts\check_fb.bat "C:\Program Files (x86)\Firebird\Firebird_2_5\bin\" "C:\Programme3\TopControl\Fruitmanager\Daten\" "10000" "20000"
u maybe know what this could mean?
tjtj805/08/12 14:29:13 (13 months ago)-
Message #2572
It is not an error per see... It uses parsing when it parses the command string so \ is an escape character...
hence: foo\bar should be: foo
bar and so on and so forth. Since this is "new" in 0.4.0 if we fail to parse we will read it all as space separated strings (and give that error message).It should work any way unless you are using "" and such...
Michael Medin
mickem05/08/12 16:07:54 (13 months ago) -
Message #2573
now i get
l:..\..\..\trunk\service\NSClient++.cpp:385: NSClient++ 0,4,0,170 2012-05-03 x64 booting... 2012-05-08 16:00:41: e:d:\source\nscp\trunk\modules\checkexternalscripts\commands.hpp:89: Failed to parse arguments for command 'a-check-win-fb', using old split string method: unknown escape sequence: scripts\check_fb.bat "C:\Firebird_2_5\bin\" "C:\Programme3\Topcontrol\Fruitmanager\Daten\" 10000 20000 2012-05-08 16:00:46: l:..\..\..\..\trunk\modules\CheckExternalScripts\CheckExternalScripts.cpp:229: Arguments: "C:\Firebird_2_5\bin\" "C:\Programme3\Topcontrol\Fruitmanager\Daten\" 10000 20000
i get this error msg at the Nagios-Server in the syslog:
Name: 'martinpc', Service Description: 'fb_check', Return Code: '0', Output: 'Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch. #015#012OK! Transactiondifferenz = 2 / WarningT = "10000" / CriticalT ="20000"'
if i call the fb_check manually i get as msg:
OK! Transactiondifferenz = 2 / WarningT = "10000" / CriticalT ="20000"
and the echo command in the .bat file is
echo OK! Transactiondifferenz = %VarGesamt% / WarningT = %varWarnT% / CriticalT = %varCritT%
seems that the nscp is converting the echo in the wrong way or sth like that??
tjtj805/08/12 16:09:49 (13 months ago)-
Message #2574
NSClient++ doesn't really convert anything at all... I would (but I havent seen the script) guess the script has some issues...
The data could very well come before the echo so the problem could be earlier... try adding in some more echos here adnt there to see if you can find where it is caused...
Michael Medin
mickem05/08/12 16:37:56 (13 months ago)-
Message #2575
Its strange because if i open the console and go to the directory of the bat.. and execute the command manually.. it seems to work?!
check_fb.bat "C:\Program Files (x86)\Firebird\Firebird_2_5\bin\" "C:\Programme\TopControl\Fruitmanager\Daten\" 10000 20000 >> C:\log.txt
and in the log.txt i see then:
OK! Transactiondifferenz = 2 / WarningT = 10000 / CriticalT = 20000
tjtj805/08/12 16:44:41 (13 months ago)-
Message #2577
The path i set was wrong, now all is working, but the error remains..
Thank you anyway!
tjtj805/09/12 07:45:54 (13 months ago)-
Message #2578
Which error?
mickem05/09/12 08:34:32 (13 months ago)-
Message #2583
I get the error only once, when im starting/restarting the nscp service:
2012-05-10 10:47:09: l:..\..\..\trunk\service\NSClient++.cpp:385: NSClient++ 0,4,0,170 2012-05-03 x64 booting... 2012-05-10 10:47:09: e:d:\source\nscp\trunk\modules\checkexternalscripts\commands.hpp:89: Failed to parse arguments for command 'a-check-win-fb', using old split string method: unknown escape sequence: scripts\check_fb.bat "C:\Program Files (x86)\Firebird\Firebird_2_5\bin\" "C:\Programme3\Topcontrol\Fruitmanager\Daten\FRUITMANAGER_OGT.FDB" 10000 20000
But the bat is working and the results seem correctly.
tjtj805/10/12 10:51:03 (12 months ago)
-
-
-
-
-
-
-
-
-








