Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nagios perl plugin

Status
Not open for further replies.

szpuni

Technical User
Feb 12, 2008
69
0
0
IE
Hi All,

I have a small problem with perl plugin for nagios 3.
Problem is with printf function:

elsif ($clients_conn < $opt_w) {

printf("OK: Clients connected: %d | CPU Usage: %d\n", $clients_conn, $cpusage);
exit $ERRORS{"OK"}
}

this is giving me an error from embaded perl of nagios:

**ePN /usr/lib/nagios/plugins/check_fms_1.pl: "Argument "" isn't numeric in sprintf at /usr/lib/nagios3/p1.pl line 81,"

But code work nice if I use it from a shell.
If I delete $cpusage varible and corresponding %d error dissapers.

Do anybody have any idea why this is happening?
 
One of these is causing an issue most likely:

$clients_conn, $cpusage

is it supposed be $cpuusage or $cpusage? Print their values to see if they are fully numeric and if you need to chomp anything.

Are you running strict / warnings?
 
I'm using strict but not warnings. Strict is needed by nagios anyway.

is you looking for a typo there is none, could be in this post but I was triple checking this.

It might be need for chomp anything like end of line but when I print this value on the screen this value is one digit.
Value is taken from xml file by regular expresion:

my $regex3 = '<cpu_Usage>(\d+)</cpu_Usage>';

so this is giving me digit let say 2.

as I was saying if I run this through shell everything is showing but through nagios I'm getting this error
 
So what do you get it if you print out the value of $cpusage when you don't run it through the shell? If you use something like print "\$cpusage is [$cpusage]\n"; it may be easier to see any unexpected characters around it.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top