def main(): local_ip = get_local_ip() set_prefix(local_ip) progress(5, '本机地址: %s' % local_ip) db_ip, db_port = get_mysql_addr() progress(15, '数据库地址: %s:%d' % (db_ip, db_port)) try: check_disk_space() conn = MySQLdb.connect(host=db_ip, user='******', passwd='iraindb10241GB', db='irain_park', charset='utf8') cursor = conn.cursor() cursor.execute( 'select depot_terminal.name from depot_terminal where depot_terminal.ip = "%s"; ' % local_ip) name = cursor.fetchall() progress(20, "板子名称:%s" % name[0]) check_processes() progress(30) check_vpr_config(cursor, local_ip, db_ip) progress(40) check_boa_and_serial(cursor, local_ip) progress(50) check_paramiko() progress(60) check_network_connection() progress(70) check_rinetd() progress(80) check_link_file() except Exception, e: err("exception![%s]\n%s" % (str(e), traceback.format_exc()))
from helper import get_mysql_addr, start, end, info if __name__ == '__main__': start() addr = get_mysql_addr() info('%s %d' % (addr[0], addr[1])) end()
#!/usr/bin/env python # coding: utf-8 import traceback import MySQLdb import paramiko from helper import info, start, end, err, progress, get_mysql_addr import threading if __name__ == "__main__": progress(0) start() try: db_ip, db_port = get_mysql_addr() except Exception as e: err("init param exception %s\n%s" % (e, traceback.format_exc())) try: conn = MySQLdb.connect(host=db_ip, port=db_port, user='******', passwd='iraindb10241GB', db='irain_park', charset='utf8') except Exception as e: err("connect mysql exception %s\n%s" % (e, traceback.format_exc())) try: cursor = conn.cursor() cursor.execute("SELECT ip FROM depot_terminal;") ip_list = cursor.fetchall() except Exception as e: err("check terminal ip failuer %s\n%s" % (e, traceback.format_exc()))
def run_sql(sql): ms_addr, _ = get_mysql_addr() sql_cmd = 'mysql -uroot -piraindb10241GB -h%s irain_park -sNe "%s"' % ( ms_addr, sql) return [r for r in l_exec_cmd(sql_cmd)]
# coding:utf-8 from helper import start, end, get_mysql_addr, info import os if __name__ == '__main__': start() db_ip, _ = get_mysql_addr() _, out = os.popen2( """mysql -uroot -piraindb10241GB -h%s -sN irain_park -e 'update project_conf set value = "http://img.parkingwang.com/picupload/" where id=3'""" % db_ip) info(out.read()) _, out = os.popen2( """mysql -uroot -piraindb10241GB -h%s -sN irain_park -e 'select value from project_conf where id=3'""" % db_ip) info(out.read()) end()