通过python hp ilo对机器的状态进行监控,pythonilo,<通过python hp
通过python hp ilo对机器的状态进行监控,pythonilo,<通过python hp
<通过python hp ilo对机器的状态进行监控>标签: <无>1.[代码][通过python hp ilo对机器的状态进行监控Python]代码
#!/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)
编橙之家文章,
相关内容
- python深度搜索+命令模式 解数独,python解数,python深度搜
- 网友用python把IPv4地址变成LITNET-NAT64网段,ipv4litnet-nat
- python抓取百度音乐mp3歌曲,python抓取百度音乐,python抓取
- 使用Python生成文件的MD5和sha1,,使用Python生成文件
- 绑定修改网卡绑定关系的python程序,修改网卡绑定pyt
- Python用来处理图像几何变换,python图像几何变换,Pytho
- 用python将语料转化为可计算的形式,python语料,自然语言
- 简单的筛选格式 python工具,筛选python工具,自己写的简
- 使用python重命名指定目录文件,,使用python重命名指
- python数据结构快速排序,python数据结构,<python数据结
评论关闭