代码拉取完成,页面将自动刷新
同步操作将从 LepusGroup/lepus 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!//bin/env python
#coding:utf-8
import os
import sys
import string
import time
import datetime
import MySQLdb
import logging
import logging.config
logging.config.fileConfig("etc/logger.ini")
logger = logging.getLogger("lepus")
path='./include'
sys.path.insert(0,path)
import functions as func
import thread
from multiprocessing import Process;
dbhost = func.get_config('monitor_server','host')
dbport = func.get_config('monitor_server','port')
dbuser = func.get_config('monitor_server','user')
dbpasswd = func.get_config('monitor_server','passwd')
dbname = func.get_config('monitor_server','dbname')
def check_os(ip,community,filter_os_disk,tags):
func.mysql_exec("insert into os_status_history select *, LEFT(REPLACE(REPLACE(REPLACE(create_time,'-',''),' ',''),':',''),12) from os_status where ip='%s';" %(ip),'')
func.mysql_exec("insert into os_disk_history select *, LEFT(REPLACE(REPLACE(REPLACE(create_time,'-',''),' ',''),':',''),12) from os_disk where ip='%s';" %(ip),'')
func.mysql_exec("insert into os_diskio_history select *, LEFT(REPLACE(REPLACE(REPLACE(create_time,'-',''),' ',''),':',''),12) from os_diskio where ip='%s';" %(ip),'')
func.mysql_exec("insert into os_net_history select *, LEFT(REPLACE(REPLACE(REPLACE(create_time,'-',''),' ',''),':',''),12) from os_net where ip='%s';" %(ip),'')
func.mysql_exec("delete from os_status where ip='%s'" %(ip),'')
func.mysql_exec("delete from os_disk where ip='%s'" %(ip),'')
func.mysql_exec("delete from os_diskio where ip='%s'" %(ip),'')
func.mysql_exec("delete from os_net where ip='%s'" %(ip),'')
command="sh check_os.sh"
try :
os.system("%s %s %s %s %s %s %s %s %s %s"%(command,ip,dbhost,dbport,dbuser,dbpasswd,dbname,community,filter_os_disk,tags))
logger.info("%s:%s statspack complete."%(dbhost,dbport))
except Exception, e:
print e
logger.info("%s:%s statspack error: %s"%(dbhost,dbport,e))
sys.exit(1)
finally:
sys.exit(1)
def main():
#get os servers list
servers=func.mysql_query("select host,community,filter_os_disk,tags from db_servers_os where is_delete=0 and monitor=1;")
logger.info("check os controller started.")
if servers:
plist = []
for row in servers:
host=row[0]
community=row[1]
filter_os_disk=row[2]
tags=row[3]
if host <> '' :
thread.start_new_thread(check_os, (host,community,filter_os_disk,tags))
time.sleep(1)
#p = Process(target = check_os, args=(host,filter_os_disk))
#plist.append(p)
#p.start()
#for p in plist:
# p.join()
else:
logger.warning("check os: not found any servers")
logger.info("check os controller finished.")
if __name__=='__main__':
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。