CheckFiles format
CheckFiles format
Hi,
when using CheckFiles for monitoring file size:
root@nagios:/home/nagios# check_nrpe -H naud12 -c CheckFiles -a path=c:/Program\ Files/NSClient++/nsclient.log "filter=size > 100k" "syntax=%filename%: %size%" MaxWarn=1 MaxCrit=1
nsclient.log: 495263|'count'=1;1;1
root@nagios:/home/nagios# check_nrpe -H naud12 -c CheckFiles -a path=c:/Program\ Files/NSClient++/nsclient.log "filter=size > 1000k" "syntax=%filename%: %size%" MaxWarn=1 MaxCrit=1
No drives found|'count'=0;1;1
1- How do I change size from bytes to Megabytes or Gigabytes?
2- On this case, when the file size is smaller then what is configured, it shows: "No drives found!" I would like to change this to "OK" or just to output the file size. How do I do that?
when using CheckFiles for monitoring file size:
root@nagios:/home/nagios# check_nrpe -H naud12 -c CheckFiles -a path=c:/Program\ Files/NSClient++/nsclient.log "filter=size > 100k" "syntax=%filename%: %size%" MaxWarn=1 MaxCrit=1
nsclient.log: 495263|'count'=1;1;1
root@nagios:/home/nagios# check_nrpe -H naud12 -c CheckFiles -a path=c:/Program\ Files/NSClient++/nsclient.log "filter=size > 1000k" "syntax=%filename%: %size%" MaxWarn=1 MaxCrit=1
No drives found|'count'=0;1;1
1- How do I change size from bytes to Megabytes or Gigabytes?
2- On this case, when the file size is smaller then what is configured, it shows: "No drives found!" I would like to change this to "OK" or just to output the file size. How do I do that?
Re: CheckFiles format
What version of NSClient++ are you running?
Re: CheckFiles format
Sorry,
NSClient++ 0.4.3.131 2015-02-15
and
Nagios Version 4.0.8
NSClient++ 0.4.3.131 2015-02-15
and
Nagios Version 4.0.8
Re: CheckFiles format
It's working properly on mine, can you try using NSClient++ 0.4.1.105 and let me know if that works for you? The later versions of NSClient++ have had issues.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: CheckFiles format
OK so there are a number of things I will talk about here. Sorry if it gets complicated
The commands in 0.4.3 have changed and the online manual isn't that great. I'm still learning them however I am providing you with some examples which should give you what you are after. The key thing is that you want the check called check_files NOT CheckFiles.
When targeting a specific file, instead of using:
Use this instead:
When using a path and pattern, it iterates over all the files in that path to find the file.
When using file, it only looks for that specific file in that location.
http://docs.nsclient.org/reference/wind ... heck-files
However the key information is here:
http://nsclient.org/nscp/ticket/684
NOTE: The capital M or G is required, lower case does not work!
Now, this only appears to affect the performance data part of the string (everything to the RIGHT of the pipe | symbol).
You can display the file size in the status detail (everything to the LEFT of the pipe | symbol). This is done using the detail-syntax argument HOWEVER it is displayed as the original value.
I have logged a feature request / bug report for this on GitHub:
https://github.com/mickem/nscp/issues/125
What you want is to use the critical argument to specify the size. NOTE: This also has changed, it is critical not MaxCrit and has a syntax.
NOTE: the lower CASE k is important here, upper case K will not work.
Sooooo with all that in mind, here are the commands you should be using:
So now that leaves us with a bug that I have just identified:
When the file matches the critical criteria, it is not reported correctly:
It should say 1/1 files.
Rest assured that the CRITICAL state is being correctly returned:
I have reported this as a bug on GitHub:
https://github.com/mickem/nscp/issues/124
Let us know if that all makes sense.
The commands in 0.4.3 have changed and the online manual isn't that great. I'm still learning them however I am providing you with some examples which should give you what you are after. The key thing is that you want the check called check_files NOT CheckFiles.
When targeting a specific file, instead of using:
Code: Select all
path="c:\\Program Files\\NSClient++" pattern="nsclient.log"
Code: Select all
file="c:\\Program Files\\NSClient++\\nsclient.log"
When using file, it only looks for that specific file in that location.
I found there is an argument called perf-config however this documentation did not contain much information:guizalan wrote:1- How do I change size from bytes to Megabytes or Gigabytes?
http://docs.nsclient.org/reference/wind ... heck-files
However the key information is here:
http://nsclient.org/nscp/ticket/684
Code: Select all
"perf-config=size(unit:M)"
"perf-config=size(unit:G)"
Now, this only appears to affect the performance data part of the string (everything to the RIGHT of the pipe | symbol).
Code: Select all
CRITICAL: 0/1 files (nsclient.log)|'nsclient.log size'=0.31999M;0;0.00009
Code: Select all
"detail-syntax=${status}%(file) = %(size)"
Code: Select all
CRITICAL: 0/1 files (nsclient.log = 339708)|'nsclient.log size'=0.32397M;0;0.00292
https://github.com/mickem/nscp/issues/125
Regardless of version, using a filter restricts what is returned. If the file size is smaller then what is configured in the filter, then is is not included in the matches and hence cannot be reported on when there is an OK state.guizalan wrote:On this case, when the file size is smaller then what is configured, it shows: "No drives found!" I would like to change this to "OK" or just to output the file size. How do I do that?
What you want is to use the critical argument to specify the size. NOTE: This also has changed, it is critical not MaxCrit and has a syntax.
Code: Select all
"critical=size>100k"
Code: Select all
CRITICAL: 0/1 files (nsclient.log)|'nsclient.log size'=0.3331M;0;0.00009
Sooooo with all that in mind, here are the commands you should be using:
Code: Select all
Command:
check_nrpe -H naud12 -c check_files -a file="c:\\Program Files\\NSClient++\\nsclient.log" "critical=size>100k" "perf-config=size(unit:M)" "detail-syntax=${status}%(file) = %(size)"
Output:
CRITICAL: 0/1 files (nsclient.log = 357446)|'nsclient.log size'=0.34088M;0;0.09765
Code: Select all
Command:
check_nrpe -H naud12 -c check_files -a file="c:\\Program Files\\NSClient++\\nsclient.log" "critical=size>1000k" "perf-config=size(unit:M)" "detail-syntax=${status}%(file) = %(size)"
Output:
OK: All 1 files are ok|'nsclient.log size'=0.34167M;0;0.97656
So now that leaves us with a bug that I have just identified:
When the file matches the critical criteria, it is not reported correctly:
Code: Select all
CRITICAL: 0/1 files (nsclient.log = 357446)|'nsclient.log size'=0.34088M;0;0.09765
Rest assured that the CRITICAL state is being correctly returned:
Code: Select all
echo $?
2
https://github.com/mickem/nscp/issues/124
Let us know if that all makes sense.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: CheckFiles format
Box293,
It was beautiful, worked like a charm. I was breaking my head with CheckFiles, and this worked in the first attempt.
Thanks a lot Box!
It was beautiful, worked like a charm. I was breaking my head with CheckFiles, and this worked in the first attempt.
Thanks a lot Box!
Re: CheckFiles format
I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee