File: //lib/python2.7/site-packages/lap/procedures.py
import MySQLdb as mysql
def __run__(params):
try:
host = params.get('host') or '127.0.0.1'
port = params.get('port') or 3306
user = params.get('user')
passwd = params.get('passwd')
prc1 = set(params.get('procedures'))
except Exception, e:
return [ 2,'CRITICAL - Cannot access yaml data' ]
try:
db = mysql.connect(host=host,port=port,user=user, passwd=passwd)
c = db.cursor()
c.execute("SHOW PROCEDURE STATUS")
r = c.fetchall()
db.close()
prc2 = set([ x[1] for x in r ])
result = prc1.difference(prc2)
if result:
return [ 2,'CRITICAL - There is no procedures: %s' % list(result) ]
else:
return [ 0,'OK - All Procedures are OK' ]
except mysql.Error, e:
return [ 2,'CRITICAL - Cannot access yaml data' ]
except Exception, e:
return [ 2,'CRITICAL - Check your code %s' % repr(e) ]