通过hp ilo对机器的状态进行监控,hpilo状态监控,#!/usr/bin/p
文章由Byrx.net分享于2019-03-23 05:03:46
通过hp ilo对机器的状态进行监控,hpilo状态监控,#!/usr/bin/p
#!/usr/bin/python2.7import hpiloimport sysimport timeimport osimport jsonimport argparsedef check_log(fname): if not os.path.exists(fname): os.mknod("/tmp/ilo_error.log")check_log('/tmp/ilo_error.log')avg = argparse.ArgumentParser()avg.add_argument('-H',help="Plz input destination IP")avg.add_argument('-U',help="Plz input destination port")avg.add_argument('-P',help="Plz input connect user")qq = avg.parse_args()ls = os.lineseprs = hpilo.Ilo(qq.H, qq.U, qq.P)li = rs.get_server_event_log()the_time = (time.time() - 259200)save_list = []yes = 1error_num = 0for y in li: for z, k in y.items(): if z == 'description': err_rs = k.split(':') if err_rs[0] == 'POST Error': error_info = y['description'] error_time = y['initial_update'] error_time_strp = time.strptime(error_time, "%m/%d/%Y %H:%M") error_times = int(time.mktime(error_time_strp)) read_liens = open('/tmp/ilo_error.log','r') if the_time < error_times: for m in read_liens: m = json.loads(m) if not len(m) == 0: for line in m: #print line[1],error_times,line[2],error_info,line[0] if line[1] == error_times and line[2] == error_info and line[0] < 3: print "ERROR: %s" % error_info error_num = line[0] + 1 save_list.append([error_num, error_times, error_info]) error_num += 1 yes = 0 break elif line[1] == error_times and line[2] == error_info and line[0] == 3: save_list.append(line) yes = 0 if yes == 1: print "ERROR: %s" % error_info save_list.append([1, error_times, error_info]) else: print "ERROR: %s" % error_info save_list.append([1, error_times, error_info]) error_num += 1 read_liens.close()if error_num == 0: print "OK!" exit(0)else: fobj = open('/tmp/ilo_error.log','w') fobj.writelines(json.dumps(save_list)) fobj.close() exit(1)
相关内容
- 仅使用while和if计算1+2+。。。+100,while...+100,a=0b=0abc
- 演示文档字符串,,#演示文档字符串#!/u
- tornado实现文件下载的代码,tornado实现文件下载,获取请
- PyQt实现简单的计算器,pyqt计算器,#coding=utf-
- Python 我的第一个程序,Python第一个程序,import socke
- 20行构建哈夫曼树,20行哈夫曼,import rando
- Python操作Word批量生成文章,pythonword文章,需要做一些会
- 汉诺塔实现,,# -*- coding
- python实现将excel数据添加到mongodb,pythonmongodb,在做文本
- python删除特定文件,python删除,#!/usr/bin/p
评论关闭