Page 1 of 1
how show value in decimal and not round value
Posted: Tue Aug 08, 2017 2:09 am
by artaknew
I have small script which collect windows performance counter. The value is measured in seconds and it is very small, like 0.007 second.
Because returned value is very small, the value is rounded and always shows 0.
value=`/usr/local/nagios/libexec/check_nt -H $HOST -p 12489 -s $PASS -v COUNTER -l "\\PhysicalDisk(_Total)\\Avg. Disk sec/Write"`
delay=$(echo "scale=4; $value*1000" | bc)
perf=$(echo $delay)
echo "Avg. Disk sec/Write $delay | 'sec'=$perf"
exit $exitcode
My question is how show data in decimal, and not round value
Re: how show value in decimal and not round value
Posted: Tue Aug 08, 2017 12:12 pm
by bolson
Hello artaknew,
Unfortunately, because check_nt is a compiled plugin (rather than a script) there's really nothing than can be done to modify the precision of the output. You might look on the exchange for a similar plugin that returns disk i/o in milliseconds.
Re: how show value in decimal and not round value
Posted: Tue Aug 08, 2017 2:33 pm
by artaknew
What if to change check_nt commando to check_nrpe. is there possibility to change output with check_nrpe?
Re: how show value in decimal and not round value
Posted: Tue Aug 08, 2017 3:51 pm
by mcapra
Note: This all is through the lens of the latest version of NSClient++. If something is just not working and you can't figure out why, check the NSClient++ version because 0.3 is different from 0.4 is different from 0.5.
When calling NSClient++ command
check_pdh via check_nrpe, you can leverage the perf-syntax argument to adjust how the performance data is displayed. Though, I think with check_pdh it returns the literal value stored in the counter every time. I do not have a lab environment to test this with unfortunately.
Though, it's important to understand that, in this context, switching between check_nt and check_nrpe will require you to totally re-work your commands. I doubt you'll be able to just swap check_nt for check_nrpe and solve the problem.
Re: how show value in decimal and not round value
Posted: Wed Aug 09, 2017 12:56 pm
by dwhitfield
bolson wrote:there's really nothing than can be done to modify the precision of the output.
I'd like to clarify that there's nothing that can be done without recompiling the plugin. The code for check_nt is available at
https://github.com/nagios-plugins/nagio ... check_nt.c -- As
@mcapra noted, please be aware of version #s. The github may page is going to be the latest stable version (generally, this will be a newer version than what is included in XI). You can use the branch and tag settings in github to get the version that you would like.