Check Output Data Format

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nicholashadaway
Posts: 31
Joined: Thu Sep 05, 2019 1:03 pm

Check Output Data Format

Post 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?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Check Output Data Format

Post 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?
nicholashadaway
Posts: 31
Joined: Thu Sep 05, 2019 1:03 pm

Re: Check Output Data Format

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check Output Data Format

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked