Page 2 of 4
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 10:43 am
by lmiltchev
Can you post the "nsclient.ini" file, so that we can take a look at it? Obscure the sensitive data.
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 12:11 pm
by hk44765
I was able to run the code from the server after tweaking the ExecutionPolicy within Windows. This was given me an error along with solution below.
PS C:\Program Files\NSClient++\scripts> .\check_ms_win_disk_load.ps1
File C:\Program Files\NSClient++\scripts\check_ms_win_disk_load.ps1 cannot be loaded because the execution of scripts i
s disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:29
+ .\check_ms_win_disk_load.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
PS C:\Program Files\NSClient++\scripts> Get-ExecutionPolicy
Restricted
PS C:\Program Files\NSClient++\scripts>
PS C:\Program Files\NSClient++\scripts>
PS C:\Program Files\NSClient++\scripts> Set-ExecutionPolicy RemoteSigned
Now i'm able to run the code locally on the server at least. Still have not been able to run remotely from server using nrpe call:
PS C:\Program Files\NSClient++\scripts> .\check_ms_win_disk_load.ps1
OK: Drive C: Avg of 2 samples: {Rate (Read: 0.00000MB/s)(Write: 0.00219MB/s)} {Avg Nr of (Reads: 0.00000r/s)(Writes: 0.
0000w/s)} {Latency (Read: 0.00000us)(Write: 0.07500us)} {Queue Length (Read: 0.00000ql)(Write: 0.00000ql)} | 'Read_Late
cy'=0.00000us 'Write_Latency'=0.07500us 'Read_Queue'=0.00000ql 'Write_Queue'=0.00015ql 'Number_of_Reads'=0.00000r/s 'Nu
ber_of_Writes'=0.99696w/s 'Read_Rate'=0.00000MB/s 'Write_Rate'=0.00219MB/s
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 1:28 pm
by hk44765
Here is my nsc.ini file.
##################################################################
[modules]
NRPEListener.dll
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
CheckEventLog.dll
CheckHelpers.dll
CheckExternalScripts.dll
[/settings/external scripts]
allow arguments = True
[Settings]
use_file=1
allowed_hosts=192.168.214.238
[log]
;debug=1
;file=nsclient.log
;date_mask=%Y-%m-%d %H:%M:%S
;root_folder=exe
[NRPE]
allow_arguments=1
allowed_hosts=192.168.214.238
[Script Wrappings]
vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
bat=scripts\%SCRIPT% %ARGS%
[External Scripts]
allow_nasty_meta_chars=1
check_winservice=scripts\check_winservice.exe $ARG1$
check_ms_win_disk_load=cmd /c echo scripts/check_ms_win_disk_load.ps1 $ARG1$; exit LastExitCode | powershell.exe -command –
[External Alias]
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_cpu_ex=checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page
alias_up=checkUpTime MinWarn=1d MinWarn=1h
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_disk_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable
alias_volumes=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED
alias_volumes_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable
alias_service=checkServiceState CheckAll
alias_service_ex=checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc
alias_process=checkProcState "$ARG1$=started"
alias_process_stopped=checkProcState "$ARG1$=stopped"
alias_process_count=checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"
alias_process_hung=checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"
alias_event_log=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"
alias_file_size=CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10
alias_file_age=checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"
alias_sched_all=CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0
alias_sched_long=CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_sched_task=CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_updates=check_updates -warning 0 -critical 0
check_ok=CheckOK Everything is fine!
[NRPE Client Handlers]
check_other=-H 192.168.0.1 -p 5666 -c remote_command -a arguments
##############################################################################
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 1:31 pm
by hk44765
I successfully executed the remote code using following command and captured output from test cmd on server. It's complaining of an error on line 1:
On Nagios Server:
[root@vnlpnagios01 libexec]# ./check_nrpe -H hnwtcompu01 -t 60 -c check_ms_win_disk_load -a '-H localhost'
Missing expression after unary operator '-'.
At line:1 char:2
+ - <<<<
+ CategoryInfo : ParserError: (-:String) [], ParentContainsErrorR
ecordException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
Cient Output:
d rvice\NSClient++.cpp:616 NSClient++ - 0,4,1,105 2014-04-28 Started!
l ce\simple_client.hpp:32 Enter command to inject or exit to terminate...
d /server/protocol.hpp:66 Accepting connection from: 192.168.214.238
d rvice\NSClient++.cpp:960 Injecting: check_ms_win_disk_load...
d kExternalScripts.cpp:249 Command line: cmd /c echo scripts/check_ms_win_disk_load.ps1 -H localhost; exit LastExitCode | powershell.exe -command
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 1:32 pm
by WillemDH
It's still nsc.ini which implies you are still running 0.3 version of NSCLient. Please upgrade to 0.4.11.105. The post nsclient.ini.
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 1:41 pm
by hk44765
The command works locally but just not called from Nagios server? Why?
PS C:\Program Files\NSClient++\scripts> .\check_ms_win_disk_load.ps1 -H localhost -dl C
OK: Drive C: Avg of 2 samples: {Rate (Read: 0.00000MB/s)(Write: 0.00000MB/s)} {Avg Nr of (Reads: 0.00000r/s)(Writes: 0.0
0000w/s)} {Latency (Read: 0.00000us)(Write: 0.00000us)} {Queue Length (Read: 0.00000ql)(Write: 0.00000ql)} | 'Read_Laten
cy'=0.00000us 'Write_Latency'=0.00000us 'Read_Queue'=0.00000ql 'Write_Queue'=0.00000ql 'Number_of_Reads'=0.00000r/s 'Num
ber_of_Writes'=0.00000w/s 'Read_Rate'=0.00000MB/s 'Write_Rate'=0.00000MB/s
PS C:\Program Files\NSClient++\scripts> .\check_ms_win_disk_load.ps1 -H localhost -dl D
OK: Drive D: Avg of 2 samples: {Rate (Read: 0.06165MB/s)(Write: 0.01734MB/s)} {Avg Nr of (Reads: 3.94549r/s)(Writes: 3.9
4549w/s)} {Latency (Read: 0.05001us)(Write: 0.05000us)} {Queue Length (Read: 0.00039ql)(Write: 0.00039ql)} | 'Read_Laten
cy'=0.05001us 'Write_Latency'=0.05000us 'Read_Queue'=0.00039ql 'Write_Queue'=0.00015ql 'Number_of_Reads'=3.94549r/s 'Num
ber_of_Writes'=1.47956w/s 'Read_Rate'=0.06165MB/s 'Write_Rate'=0.01734MB/s
PS C:\Program Files\NSClient++\scripts>
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 1:44 pm
by hk44765
Both nsc.ini and nslcient.ini are present. I've upgrade and confirmed it's upgraded. Do I just remove and delete nsc.ini from directory?
Here is the content of nsclient.ini file.
#########################################################################################
# If you want to fill this file with all avalible options run the following command:
# nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
# nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help
; A list of modules.
[/modules]
; Undocumented key
CheckDisk = 0
; Undocumented key
CheckEventLog = 0
; Undocumented key
CheckExternalScripts = 0
; Undocumented key
CheckHelpers = 0
; Undocumented key
CheckNSCP = 0
; Undocumented key
CheckSystem = 0
; Undocumented key
FileLogger.dll =
; NRPE server - A simple server that listens for incoming NRPE connection and handles them.
NRPEServer = 1
; Section for NRPE (NRPEServer.dll) (check_nrpe) protocol options.
[/settings/NRPE/server]
; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true
; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges. parent for this key is found under: /settings/default this is marked as advanced in favour of the parent.
allowed hosts = 192.168.214.238
; Undocumented section
[/settings/external scripts]
; Undocumented key
allow nasty characters = 1
; Undocumented section
[/settings/external scripts/alias]
; Undocumented key
alias_cpu = checkCPU warn=80 crit=90 time=5m time=1m time=30s
; Undocumented key
alias_cpu_ex = checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s
; Undocumented key
alias_disk = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
; Undocumented key
alias_disk_loose = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable
; Undocumented key
alias_event_log = CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"
; Undocumented key
alias_file_age = checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"
; Undocumented key
alias_file_size = CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10
; Undocumented key
alias_mem = checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page
; Undocumented key
alias_process = checkProcState "$ARG1$=started"
; Undocumented key
alias_process_count = checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"
; Undocumented key
alias_process_hung = checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"
; Undocumented key
alias_process_stopped = checkProcState "$ARG1$=stopped"
; Undocumented key
alias_sched_all = CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0
; Undocumented key
alias_sched_long = CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0
; Undocumented key
alias_sched_task = CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0
; Undocumented key
alias_service = checkServiceState CheckAll
; Undocumented key
alias_service_ex = checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc
; Undocumented key
alias_up = checkUpTime MinWarn=1d MinWarn=1h
; Undocumented key
alias_updates = check_updates -warning 0 -critical 0
; Undocumented key
alias_volumes = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED
; Undocumented key
alias_volumes_loose = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable
; Undocumented key
check_ok = CheckOK Everything is fine!
; Undocumented section
[/settings/external scripts/scripts]
; Undocumented key
check_ms_win_disk_load = cmd /c echo scripts/check_ms_win_disk_load.ps1 $ARG1$; exit LastExitCode | powershell.exe -command –
; Undocumented key
check_winservice = scripts\check_winservice.exe $ARG1$
; Undocumented section
[/settings/external scripts/wrappings]
; Undocumented key
bat = scripts\%SCRIPT% %ARGS%
; Undocumented key
ps1 = cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
; Undocumented key
vbs = cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
[/settings/default]
; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 192.168.214.238
###############################################################
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 1:54 pm
by WillemDH
Hey,
This the external config part of my nsclient.ini:
Code: Select all
; Section for external scripts configuration options (CheckExternalScripts).
[/settings/external scripts]
; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true
; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true
; SCRIPT DIRECTORY - Load all scripts in a directory and use them as commands. Probably dangerous but useful if you have loads of scripts :)
script path =
; COMMAND TIMEOUT - The maximum time in seconds that a command can execute. (if more then this execution will be aborted). NOTICE this only affects external commands not internal ones.
timeout = 300
; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]
check_ms_win_updates=cmd /c echo scripts\powershell\check_ms_win_updates.ps1 $ARG1$; exit $LastExitCode | powershell.exe /noprofile -command -
And the NRPE part:
Code: Select all
; Section for NRPE (NRPEServer.dll) (check_nrpe) protocol options.
[/settings/NRPE/server]
; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true
; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true
; PORT NUMBER - Port to use for NRPE.
port = 5666
; Timeout for NRPE checks
timeout = 120
Seems like u r missing 'allow arguments = true' in the external scripts/scripts part?
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 2:07 pm
by hk44765
So I started over again and installed nsclient and it's now using nsclient.ini file.
I can see it sends command over to system and executes successfully. However, the nagios server command line reports the following:
[root@vnlpnagios01 libexec]# ./check_nrpe -H hnwtcompu01 -t 60 -c check_ms_win_disk_load -a '-H localhost'
Missing expression after unary operator '-'.
At line:1 char:2
+ - <<<<
+ CategoryInfo : ParserError: (-:String) [], ParentContainsErrorR
ecordException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
[root@vnlpnagios01 libexec]#
Re: check_ms_win_disk_load error?
Posted: Tue Sep 22, 2015 2:20 pm
by WillemDH
Well I doublechecked:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H server -p 5666 -t 120 -c check_ms_win_disk_load -a '-H localhost -ms 5 -dl C'
OUTPUT: OK: Drive C: Avg of 5 samples: {Rate (Read: 0,03082MB/s)(Write: 0,06282MB/s)} {Avg Nr of (Reads: 0,98616r/s)(Writes: 0,98616w/s)} {Latency (Read: 0,39333us)(Write: 2,01555us)} {Queue Length (Read: 0,00097ql)(Write: 0,00097ql)} |'Read_Latency'=0.39333us 'Write_Latency'=2.01555us 'Read_Queue'=0.00097ql 'Write_Queue'=0.00541ql 'Number_of_Reads'=0.98616r/s 'Number_of_Writes'=2.5677w/s 'Read_Rate'=0.03082MB/s 'Write_Rate'=0.06282MB/s
The above works for me. You have my nsclient.ini. I'm not sure what else could be wrong. Please doublecheck and post you updated last nsclient.ini config one more time. Please also post the command you are using.. tx