Revision 303

Date:
2010/01/19 19:40:48
Author:
alan
Revision Log:
Catchall exception and more stats report changes
Files:

Legend:

 
Added
 
Removed
 
Modified
  • binarystor/trunk/src/python/dbalerter/daemon/dbalerter/checkmysql.py

     
    117 117 notify.log_notify('Shutdown')
    118 118 time.sleep(5)
    119 119 sys.exit(1)
    120 except:
    121 notify.log_notify('Shutdown')
    122 raise
    123 time.sleep(5)
    124 sys.exit(1)
    120 125
    121 126
    127
    122 128 def connect():
    123 129 """Connect to MySQL server"""
    124 130
     
    401 407 def statistics_report():
    402 408 """MySQL server statistics"""
    403 409
    404 global auto_increment_state, db, global_status, statistics, variables
    410 global auto_increment_state, db, global_status, security_state, statistics, variables
    405 411 stats_report = ''
    406 412 cursor = db.cursor(MySQLdb.cursors.DictCursor)
    407 413
    408 #Outstanding issues
    414 #Auto increment threshold
    409 415 if (len(auto_increment_state) > 0):
    410 416 stats_report += "=== Auto Incrememnt Threshold Crossed ===\n"
    411 417 for key in auto_increment_state.keys():
    412 stats_report += ' ' + key
    418 stats_report += ' ' + key + "\n"
    413 419
    420 #Anonymous Accounts
    421 if (security_state['ANONACCOUNT'] == 1):
    422 stats_report += "=== Anonymous Accounts Detected ===\n"
    423 cursor.execute("""SELECT User, Host FROM mysql.user WHERE User=''""")
    424 rows = cursor.fetchall ()
    425 if (cursor.rowcount > 0):
    426 for row in rows:
    427 stats_report += ' ' + row['User'] + "'@'" + row['Host'] + "\n"
    428
    429 #Empty passwords
    430 if (security_state['EMPTYPASS'] == 1):
    431 stats_report += "=== Empty Accounts Detected ===\n"
    432 cursor.execute("""SELECT User, Host FROM mysql.user WHERE Password=''""")
    433 rows = cursor.fetchall ()
    434 if (cursor.rowcount > 0):
    435 for row in rows:
    436 stats_report += ' ' + row['User'] + "'@'" + row['Host'] + "\n"
    437
    414 438 if (stats_report != ''):
    415 stats_report = "== Outstanding Issues ==\n" + stats_report + "\n\n"
    439 stats_report = "== Outstanding Issues ==\n" + stats_report + "\n"
    416 440
    417 441 #Server Information
    418 442 stats_report += "== Server Information ==\n"