PLugin Problem

Hi guys,

im trying to make a plugin in python but im having troubles.

THe plugin works in command line with the user nagios:


[nagios@MONITORIZATION ~]$ /srv/nagios/libexec/check_oracle_table_space
TABLE_M                        18,414           18,496           26,096                 70.5

[nagios@MONITORIZATION ~]$

This is already a test, i just want the last piece but im trying various things to solve this problem.

But when i call the script via nagios it gets something like this:

INDEX_M  WARNING 09-10-2009 13:16:47 0d 0h 22m 35s 3/3 (null)  

the plugin code is:

#!/usr/bin/python
import os,sys,string
#query = "/usr/bin/sqlplus -L nagios/nagios@EHR @/srv/nagios/libexec/file "+sys.argv[1] ;
query = "sqlplus -L nagios/nagios@EHR @/home/nagios/freesample.sql TABLE_M";
f=os.popen(query)
for i in f.readlines():
        if i.find("TABLE_M") == 0:
                print i
                sys.exit(2)
                value = i.split("\t")-1];
value = value.strip()
value = float(value);

warning  = float(sys.argv[2]) ;
critical = float(sys.argv[3]) ;

ret = -1 ;
if value > critical :
        print "[CRITICAL] ",sys.argv[1]," ",value,"%";
        ret = 2 ;
elif value > warning:
        print "[WARNING] ",sys.argv[1]," ",value,"%";
        ret = 1 ;
elif value > 0:
        print "[OK] ",sys.argv[1]," ",value,"%";
        ret = 0 ;
else:
        print "Unknown Error";

sys.exit(ret);

this code has already some debug lines in the cycle…

i dont know what else to try…

Can anyone help me ?

Solved

I added the env variables in the script :s

Strange how nagios doesnt load the profile user variables…