Changeset 22634 for platform/nagios-plugins
- Timestamp:
- 11/03/08 19:44:01 (5 years ago)
- Files:
-
- 1 modified
-
platform/nagios-plugins/check_memcached.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
platform/nagios-plugins/check_memcached.py
r22633 r22634 1 1 #! /usr/bin/env python 2 2 ''' 3 check_memcache.py 4 set the temporary key and delete 3 4 2007 Kakikubo Teruo 5 check_memcache.py 6 7 Check Memcached Server plugin. 8 This Plugin requires the memcached-Python API. 9 This Plugin was tested only in the python 2.5 5 10 6 11 ''' 7 12 import memcache 8 13 import signal 9 import os 14 import os,sys 10 15 11 16 from optparse import OptionParser 17 12 18 pid = str(os.getpid()) 13 19 # option 14 20 parser = OptionParser() 15 21 parser.add_option("-H","--hostname",dest="hostaddress", 16 help="Host Address", metavar=" hostaddr")22 help="Host Address", metavar=" <hostaddr>") 17 23 parser.add_option("-t","--timeout",dest="timeout", 18 help="timeout x seconds", metavar=" timo", default=10)24 help="timeout x seconds", metavar=" <timeout>", default=10) 19 25 parser.add_option("-p","--port",dest="port", 20 help="port number", metavar=" pt" , default=11211)26 help="port number", metavar=" <port number>" , default=11211) 21 27 (opts,args)=parser.parse_args() 22 28 23 29 if not opts.hostaddress: 24 30 parser.print_help() 25 parser.error(" Please specify Host")31 parser.error("UNKNOWN - Please specify Host") 26 32 exit(2) 27 33 28 34 svr = u"" 29 35 svr = str(opts.hostaddress) + ":" + str(opts.port) 30 mc = memcache.Client([ svr ], debug= 1)36 mc = memcache.Client([ svr ], debug=0) 31 37 #mc = memcache.Client({opts.hostaddress}:{opts.port}, debug=1) 32 38 #mc = memcache.Client(["ocnblg-tc01-int:112"], debug=1) 39 40 def handler(signum, frame): 41 #print 'Signal handler called with signal', signum 42 #raise IOError, "hogehogehgoehgoe" 43 print "CRITICAL - timeout after " + str(opts.timeout) + " seconds" 44 sys.exit(2) 45 46 ## Set the signal handler 47 signal.signal(signal.SIGALRM, handler) 48 signal.alarm(int(opts.timeout)) 49 33 50 if not mc.set(pid,"nagios value"): 34 raise ValueError,"CRITICAL - cannot set the value"35 exit(2)51 print "CRITICAL - cannot set the value" 52 sys.exit(2) 36 53 else: 37 54 if not mc.get(pid) == 'nagios value': 38 raise ValueError,"CRITICAL - cannot get the value"39 exit(2)55 print "CRITICAL - cannot get the value" 56 sys.exit(2) 40 57 else: 41 58 mc.delete(pid) 42 59 print "OK - memcached alive" 43 exit 60 sys.exit(0) 61
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)