Show
Ignore:
Timestamp:
11/03/08 19:44:56 (5 years ago)
Author:
kakikubo
Message:

add elapsed time

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/nagios-plugins/check_memcached.py

    r22634 r22635  
    22''' 
    33 
    4   2007 Kakikubo Teruo 
    5   check_memcache.py  
     4  2008 Kakikubo Teruo 
     5  check_memcached.py  
    66 
    77  Check Memcached Server plugin.  
     
    99  This Plugin was tested only in the python 2.5  
    1010 
     11  * Wed Apr  2 20:42:56 JST 2008 
     12  add performance data (elapsed time) 
     13 
    1114''' 
    1215import memcache 
    1316import signal 
     17import time 
    1418import os,sys 
    1519 
     
    1721 
    1822pid = str(os.getpid()) 
     23 
    1924# option 
    2025parser = OptionParser() 
     
    3540svr = str(opts.hostaddress) + ":" + str(opts.port) 
    3641mc = memcache.Client([ svr ], debug=0) 
    37 #mc = memcache.Client({opts.hostaddress}:{opts.port}, debug=1) 
    38 #mc = memcache.Client(["ocnblg-tc01-int:112"], debug=1) 
    3942 
    4043def handler(signum, frame): 
    41     #print 'Signal handler called with signal', signum 
    42     #raise IOError, "hogehogehgoehgoe" 
    4344    print "CRITICAL - timeout after " + str(opts.timeout) + " seconds" 
    4445    sys.exit(2) 
    4546 
    46 ## Set the signal handler 
    4747signal.signal(signal.SIGALRM, handler) 
    4848signal.alarm(int(opts.timeout)) 
     49t1 = time.time() 
    4950 
    5051if not mc.set(pid,"nagios value"): 
     
    5758    else: 
    5859        mc.delete(pid) 
    59         print "OK - memcached alive" 
     60        t2 = time.time() 
     61        t3 = str(round((t2 - t1),6)) 
     62        print "OK - memcached on " + str(opts.hostaddress) + " alive: elapsed " + t3 + " sec;|" + str(opts.hostaddress) + ":" + str(opts.port) + " time=" + t3 + "s;" 
    6063        sys.exit(0) 
    6164