4 # This script is a nagios plugin that allows to check for a host
17 #nagios_plugins_dir="/usr/lib/nagios/plugins"
21 long_opts = [ 'version' , 'help', 'no-comon' , 'key=', 'time-out=' ]
24 usage_string="""Usage : %s [-n] [-k private_key] nodename
26 This nagios plugin checks for a given (planetlab) host
27 The regular approach is to
28 * First try to reach the comon query interface.
30 this can be overridden with the --host option (NIY)
31 TODO : prevent this stage if a 'none' host is provided
32 * If we cannot conclude from this, we then try and reach
33 the comon sensor on the node itself on port %d,
34 TODO : skip on -n option
35 * Then, if an ssh private key is provided with the -k option,
36 we try to enter the node as root and check that
37 the pl_conf slice is up and running on the node
38 TODO : do this only of the -k option is provided
39 * if none of this is conclusive we just check for the ssh server on the node
40 with the standard ssh plugin
41 TODO : probably this should be left to the nagios config
42 """%(command,revision,comon_query.SERVER,comon_sensor.PORT)
52 opts,args = getopt.getopt(sys.argv[1:], options, long_opts)
53 except getopt.GetoptError:
54 print "Unknown option"
62 if o in ['-v','--version']:
63 print command,'--',revision
65 elif o in ['-h','--help']:
67 elif o in ['-n','--no-comon']:
69 elif o in ['-k','--key']:
71 elif o in ['-t','--time-out']:
74 print "Unknown option",o
77 if not len(args) == 1:
81 status = nagios.UNKNOWN
83 status = comon_query.check(nodename)
84 if status != nagios.UNKNOWN:
88 status = comon_sensor.check(nodename,opt_timeout)
90 # print "status",status
94 if __name__=='__main__':