Because I don’t have access permissions on production servers. It caused me to think how
to use agnetless icinga plugin to monitor server. This is a cause of this concept.
First, I write a fabric command to a local function naming _icinga_cmd. It will retire a exit code after executing.
def _icinga_cmd(cmd): with settings(hide('warnings','running', 'stderr'),warn_only=True): try: result=sudo(cmd) if result.return_code==0: print "OK -" sys.exit(0) elif result.return_cod==1: print "WARNING-" sys.exit(1) elif result.return_code==2: print "CRITICAL-" sys.exit(2) elif result.return_code==3: print "UNKNOW-" sys.exit(3) else: print "Waring - Can't get response" sys.exit(1) return result.return_code except: # print "Warning- Can't get response" sys.exit(0) return def check_unix_memory(): cmd='/home/pmp-check-unix-memory -d' _icinga_cmd(cmd) _icinga_cmd(cmd)
沒有留言:
張貼留言