Monitoring Disk Space by Size, not Percentage

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Monitoring Disk Space by Size, not Percentage

Postby peterooney » Mon Jan 09, 2017 7:02 am

Good morning,
Moderators - please accept my apologies if I should have continued my quest in my original thread:
viewtopic.php?f=7&t=41721
which had turned towards using check_nrpe to monitor available disk space by amount, rather than by percentage.
Through no fault of the excellent support provided here, I was getting nowhere, so requested that the thread be closed.
I have found a number of suggestions as to how I could address this requirement at http://serverfault.com/questions/309913 ... nt-co?rq=1
I've got as far as creating the three wrapper scripts provided there (which i can't get to work from the command prompt, let alone using them to define a NAGIOS service!), however, I don't want to go any further with THIS thread until I know that you'd be prepared to provide assistance on this externally provided solution?

Thanks
Pete
peterooney
 
Posts: 240
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitoring Disk Space by Size, not Percentage

Postby lmiltchev » Mon Jan 09, 2017 1:06 pm

Pete, did you decide not to use "check_nrpe" with NSClient++? The reason I am asking is that "check_nrpe" seems to work just fine for me.
Code: Select all
# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -t 30 -c check_drivesize -a drive=C: 'warning=free<10G' 'critical=free<5G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size} total}' top-syntax='${status}: ${problem_list}'
OK: {C: 55.269GB free / 107.47GB total}|'C: free'=55.26886G;10;5;0;107.46972 'C: free %'=51%;9;4;0;100


Can you run the same command from the command line on the Nagios box, and show the output? What is the version of NSClient++ that ou are currently using?
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x


Post the entire nsclient.ini file from the Windows machine. Hide sensitive info.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
QA Manager
 
Posts: 9069
Joined: Mon May 23, 2011 12:15 pm

Re: Monitoring Disk Space by Size, not Percentage

Postby dwhitfield » Mon Jan 09, 2017 1:09 pm

One thing to note about NSClient in general is that if you install a new version, cruft from the old version gets left behind. Also, particularly with .3.x versus .4.x, the configs are very different.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
dwhitfield
The Doctor
 
Posts: 2100
Joined: Wed Sep 21, 2016 10:29 am
Location: Nagios Enterprises, LLC

Re: Monitoring Disk Space by Size, not Percentage

Postby peterooney » Tue Jan 10, 2017 5:26 am

Good morning - when i type the command in as shown, I get:
Code: Select all
Request command contained illegal metachars!

My NRPE version is 2.15, by the way. Do I need to have NRPE installed and running on the remote PC (which is Windows, not Linux) too?
You can see why I preferred to go with one of the solutions referenced in the link I provided, if possible - I don't want to have to amend the NSClient.ini file on 500+ servers!
Here's the nsclient.ini file from my test target machine:
Code: Select all
# 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


; Undocumented section
[/settings/default]

; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = 99.99.99.99


; Undocumented section
[/modules]

; Undocumented key
Scheduler = 0

; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1

; NSClientServer - A server that listens for incoming check_nt connection and processes incoming requests.
NSClientServer = 1

; CheckExternalScripts - Execute external scripts
CheckExternalScripts = 1

; CheckHelpers - Various helper function to extend other checks.
CheckHelpers = 1

; CheckEventLog - Check for errors and warnings in the event log.
CheckEventLog = 1

; CheckNSCP - Use this module to check the healt and status of NSClient++ it self
CheckNSCP = 1

; CheckDisk - CheckDisk can check various file and disk related things.
CheckDisk = 1

; NRPEServer - A server that listens for incoming NRPE connection and processes incoming requests.
NRPEServer = 1


; A list of templates for wrapped scripts.
[/settings/external scripts/wrappings]

; WRAPPING - An external script wrapping
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

; WRAPPING - An external script wrapping
bat = scripts\\%SCRIPT% %ARGS%

; WRAPPING - An external script wrapping
An alias is an internal command that has been predefined to provide a single command without arguments. Be careful so you don't create loops (ie check_loop = check_a, check_a=check_loop)

; WRAPPING - An external script wrapping
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%


[/settings/external scripts/alias]

; ALIAS - Query alias
alias_volumes_loose = check_drivesize

; ALIAS - Query alias
alias_volumes = check_drivesize

; ALIAS - Query alias
alias_sched_all = check_tasksched show-all "syntax=${title}: ${exit_code}" "crit=exit_code ne 0"

; ALIAS - Query alias
alias_process_stopped = check_process "process=$ARG1$" "crit=state != 'stopped'"

; ALIAS - Query alias
alias_service = check_service

; ALIAS - Query alias
alias_process_hung = check_process "filter=is_hung" "crit=count>0"

; ALIAS - Query alias
alias_process_count = check_process "process=$ARG1$" "warn=count > $ARG2$" "crit=count > $ARG3$"

; ALIAS - Query alias
alias_process = check_process "process=$ARG1$" "crit=state != 'started'"

; ALIAS - Query alias
alias_mem = check_memory

; ALIAS - Query alias
alias_file_size = check_files "path=$ARG1$" "crit=size > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${size}" max-dir-depth=10

; ALIAS - Query alias
alias_event_log = check_eventlog

; ALIAS - Query alias
alias_service_ex = check_service "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc

; ALIAS - Query alias
alias_disk = check_drivesize

; ALIAS - Query alias
alias_file_age = check_files "path=$ARG1$" "crit=written > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${written}" max-dir-depth=10

; ALIAS - Query alias
alias_cpu_ex = check_cpu "warn=load > $ARG1$" "crit=load > $ARG2$" time=5m time=1m time=30s

; ALIAS - Query alias
alias_cpu = check_cpu

; ALIAS - Query alias
alias_up = check_uptime

; ALIAS - Query alias
alias_disk_loose = check_drivesize

; ALIAS - Query alias
alias_sched_task = check_tasksched show-all "filter=title eq '$ARG1$'" "detail-syntax=${title} (${exit_code})" "crit=exit_code ne 0"

; ALIAS - Query alias
alias_sched_long = check_tasksched "filter=status = 'running'" "detail-syntax=${title} (${most_recent_run_time})" "crit=most_recent_run_time < -$ARG1$"


; Undocumented section
[/settings/NRPE/server]
ssl options =
verify mode = none
insecure = true
allow arguments = true
allow_nasty_meta_characters = 1


And NSClient++ is version 0.4.3.143-x64

Thanks

Pete
peterooney
 
Posts: 240
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitoring Disk Space by Size, not Percentage

Postby rkennedy » Tue Jan 10, 2017 12:52 pm

You need to add allow nasty characters=true under two sections in your config file -
Code: Select all
[/settings/NRPE/server]
allow nasty characters=true

[/settings/external scripts]
allow nasty characters=true


Then restart the nscp service on the Windows machine, and try once again
rkennedy
 
Posts: 6545
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitoring Disk Space by Size, not Percentage

Postby peterooney » Wed Jan 11, 2017 4:25 am

Good morning - I didn't have an [/settings/external scripts] section in my NSCLIENT.INI, so I added it at the bottom - here's the resulting file:
Code: Select all
# 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


; Undocumented section
[/settings/default]

; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = my.nagios.core.master


; Undocumented section
[/modules]

; Undocumented key
Scheduler = 0

; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1

; NSClientServer - A server that listens for incoming check_nt connection and processes incoming requests.
NSClientServer = 1

; CheckExternalScripts - Execute external scripts
CheckExternalScripts = 1

; CheckHelpers - Various helper function to extend other checks.
CheckHelpers = 1

; CheckEventLog - Check for errors and warnings in the event log.
CheckEventLog = 1

; CheckNSCP - Use this module to check the healt and status of NSClient++ it self
CheckNSCP = 1

; CheckDisk - CheckDisk can check various file and disk related things.
CheckDisk = 1

; NRPEServer - A server that listens for incoming NRPE connection and processes incoming requests.
NRPEServer = 1


; A list of templates for wrapped scripts.
[/settings/external scripts/wrappings]

; WRAPPING - An external script wrapping
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

; WRAPPING - An external script wrapping
bat = scripts\\%SCRIPT% %ARGS%

; WRAPPING - An external script wrapping
An alias is an internal command that has been predefined to provide a single command without arguments. Be careful so you don't create loops (ie check_loop = check_a, check_a=check_loop)

; WRAPPING - An external script wrapping
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%


[/settings/external scripts/alias]

; ALIAS - Query alias
alias_volumes_loose = check_drivesize

; ALIAS - Query alias
alias_volumes = check_drivesize

; ALIAS - Query alias
alias_sched_all = check_tasksched show-all "syntax=${title}: ${exit_code}" "crit=exit_code ne 0"

; ALIAS - Query alias
alias_process_stopped = check_process "process=$ARG1$" "crit=state != 'stopped'"

; ALIAS - Query alias
alias_service = check_service

; ALIAS - Query alias
alias_process_hung = check_process "filter=is_hung" "crit=count>0"

; ALIAS - Query alias
alias_process_count = check_process "process=$ARG1$" "warn=count > $ARG2$" "crit=count > $ARG3$"

; ALIAS - Query alias
alias_process = check_process "process=$ARG1$" "crit=state != 'started'"

; ALIAS - Query alias
alias_mem = check_memory

; ALIAS - Query alias
alias_file_size = check_files "path=$ARG1$" "crit=size > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${size}" max-dir-depth=10

; ALIAS - Query alias
alias_event_log = check_eventlog

; ALIAS - Query alias
alias_service_ex = check_service "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc

; ALIAS - Query alias
alias_disk = check_drivesize

; ALIAS - Query alias
alias_file_age = check_files "path=$ARG1$" "crit=written > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${written}" max-dir-depth=10

; ALIAS - Query alias
alias_cpu_ex = check_cpu "warn=load > $ARG1$" "crit=load > $ARG2$" time=5m time=1m time=30s

; ALIAS - Query alias
alias_cpu = check_cpu

; ALIAS - Query alias
alias_up = check_uptime

; ALIAS - Query alias
alias_disk_loose = check_drivesize

; ALIAS - Query alias
alias_sched_task = check_tasksched show-all "filter=title eq '$ARG1$'" "detail-syntax=${title} (${exit_code})" "crit=exit_code ne 0"

; ALIAS - Query alias
alias_sched_long = check_tasksched "filter=status = 'running'" "detail-syntax=${title} (${most_recent_run_time})" "crit=most_recent_run_time < -$ARG1$"

[/settings/external scripts]
allow nasty characters=true

; Undocumented section
[/settings/NRPE/server]
ssl options =
verify mode = none
insecure = true
allow arguments = true
allow nasty characters = true


but
Code: Select all
[root@MYNAGIOSMASTER libexec]# /usr/local/nagios/libexec/check_nrpe -H 99.99.99.99 -t 30 -c check_drivesize -a drive=C: 'warning=free<10G' 'critical=free<5G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size} total}' top-syntax='${status}: ${problem_list}'

still returns:
Code: Select all
Exception processing request: Request command contained illegal metachars!


after I've restarted the NSCLIENT++ service. Is this a positioning problem in terms of where I've placed:
Code: Select all
[/settings/external scripts]
allow nasty characters=true

; Undocumented section
[/settings/NRPE/server]
ssl options =
verify mode = none
insecure = true
allow arguments = true
allow nasty characters = true

i.e. right at the end of the file?

Finally, I remembered that a previously suggested solution was to use "allow nasty_META_characters", including underscores so I tried this, but it still doesn't work.

As always, thanks for your help

Pete
peterooney
 
Posts: 240
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitoring Disk Space by Size, not Percentage

Postby peterooney » Wed Jan 11, 2017 6:15 am

...oh, and NSCLIENT.txt on the target server reported:
Code: Select all
2017-01-11 09:35:41: error:D:\source\nscp\modules\NRPEServer\NRPEServer.cpp:185: Request arguments contained illegal metachars!

Pete
peterooney
 
Posts: 240
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitoring Disk Space by Size, not Percentage

Postby dwhitfield » Wed Jan 11, 2017 1:54 pm

It looks like you can do this with check_wmi_plus.pl -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -m checkdrivesize -a 'C|D' -w _FreeGB=5G -c_FreeGB_4G

Obviously, you'll need to change things for your drives and the numbers you want to check.

It's written for XI, but you'll find more check_wmi_plus info at: https://assets.nagios.com/downloads/nag ... pgrade.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
dwhitfield
The Doctor
 
Posts: 2100
Joined: Wed Sep 21, 2016 10:29 am
Location: Nagios Enterprises, LLC

Re: Monitoring Disk Space by Size, not Percentage

Postby mcapra » Wed Jan 11, 2017 2:06 pm

Using your exact NSClient++ configuration and exact NSClient++ version, I didn't have any issues:

Code: Select all
[root@xi-stable ~]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99 -t 30 -c check_drivesize -a drive=C: 'warning=free<10G' 'critical=free<5G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size} total}' top-syntax='${status}: ${problem_list}'
OK: {C: 29.412GB free / 50.232GB total}|'C: free'=29.41158G;10;5;0;50.23241 'C: free %'=58%;19;9;0;100
[root@xi-stable ~]# /usr/local/nagios/libexec/check_nrpe -H 192.168.67.99
I (0.4.3.143 2015-04-29) seem to be doing fine...


Are you certain you restarted the nscp service on the remote machine after altering the configuration?
Be sure to check out our Knowledgebase for helpful articles and solutions!

https://github.com/mcapra/
User avatar
mcapra
Support Tech
 
Posts: 1965
Joined: Thu May 05, 2016 3:54 pm
Location: Nagios Enterprises

Re: Monitoring Disk Space by Size, not Percentage

Postby peterooney » Thu Jan 12, 2017 6:07 am

No, definitely restarted the service on the remote box.
I'm using Nagios 4.0.8 - could THAT be the problem?
Cheers
Pete
peterooney
 
Posts: 240
Joined: Fri Jul 24, 2015 11:04 am

Next

Return to Nagios Core

Who is online

Users browsing this forum: Bing [Bot], cdienger and 26 guests