Page 1 of 1

Check Output Data Format

Posted: Wed Nov 20, 2019 4:56 pm
by nicholashadaway
I have a check which returns numbers but I would like to format the number to an integer.

I'm not sure what I need to pass to the command to get the right formatting for integer output:
$USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v COUNTER -l "\\Server\\Errors Logon","Since last reboot","logon errors"

Is there documentation somewhere that shows the string formatting options? (%.2f etc)
Can somebody guide me to what I need to change in my check to get the correct formatting of the data output so I get integer output?

Re: Check Output Data Format

Posted: Wed Nov 20, 2019 5:29 pm
by ssax
If this won't meet your needs you'll need to use another plugin as it requires a floating point per the help section:

Code: Select all

/usr/local/nagios/libexec/check_nt -H X.X.X.X -s 'secret' -p 12489 -v COUNTER -l "\\Server\\Errors Logon"
COUNTER =
Check any performance counter of Windows NT/2000.
Request a -l parameters with the following syntax:
-l "\\<performance object>\\counter","<description>
The <description> parameter is optional and is given to a printf
output command which requires a float parameter.

If <description> does not include "%%", it is used as a label.
Some examples:
"Paging file usage is %%.2f %%%%"
"%%.f %%%% paging file used."

So really it's a printf formatting thing:

https://alvinalexander.com/programming/ ... heat-sheet

Are you just trying to remove the perdata float value (.000000) or what specifically are you trying to do?

Re: Check Output Data Format

Posted: Fri Nov 22, 2019 4:33 pm
by nicholashadaway
That clarifies it nicely. It is printf formatting ...

So, in order to get an integer I use "%d"

Thank you for your guidance.

Re: Check Output Data Format

Posted: Fri Nov 22, 2019 4:48 pm
by scottwilkerson
nicholashadaway wrote:That clarifies it nicely. It is printf formatting ...

So, in order to get an integer I use "%d"

Thank you for your guidance.
Correct