Python Monitoring UPS with SNMPWALK
##Background
My co-worker told me he needed to monitor UPS with SNMP module but he only can get hexadecimal digits from UPS module with SNMPWALK commands. Then I had to turn hexadecimal to decimal.
He gave me a passage about IEEE754: http://www.softelectro.ru/ieee754_en.html
C 12 F 15
B 11 E 14 C2 05 FB EE 1100 0010 0000 0101 1111 1011 1110 1110 1 = negative "-" 1
1000 01000
0101 1111 1011 1110 1110 1000 0100 = 132 - 127 = 5 so 2^5 = 32 0000 1011 1111 0111 1101 110 = 392174, so 392174/2^23 = 0.0467507 fomula = - 2^5 x (1+0.0467507) = -33.4 0101 1111 1011 1110 1110 = 392174 C205FBEE
Python Script
#!/usr/bin/env python
#-*- coding:utf-8 -*-
var = input("Please enter dec number:")
b = bin(int(var, 16))
print(b)
S = int(b[2])
#print(S)
e = b[3:11]
#print(e) E = int(e, 2)
#print(E) m = b[12:]
#print(m)
M = int(m, 2)
#print(M) F = ((-1)**S)*(2**(E-127))*(1+M/(2**23))
print(round(F, 10))
Python Monitoring UPS with SNMPWALK的更多相关文章
- 查看进程的io
linux系统上可以使用(centos 2.6.18-144开始支持),dstat版本至少是:dstat-0.6.7-1.rf.noarch.rpm安装wget -c http://linux.web ...
- linux wa%过高,iostat查看io状况
命令总结: 1. top/vmstat 发现 wa%过高,vmstat b >1: 参考文章: 1. 关于Linux系统指令 top 之 %wa 占用高,用`iostat`探个究竟 最近测试一项 ...
- rrdtool ubuntu python snmpwalk
rrdtool install: apt-get install libpango1.0-dev libxml2-dev wget https://packages.debian.org/wheezy ...
- Python运维脚本整理
Python 实现的自动化服务器管理 import sys import os import paramiko ssh = paramiko.SSHClient() ssh.set_missing_h ...
- python常用运维脚本实例
转载 file是一个类,使用file('file_name', 'r+')这种方式打开文件,返回一个file对象,以写模式打开文件不存在则会被创建.但是更推荐使用内置函数open()来打开一个文件 ...
- 转:python常用运维脚本实例
python常用运维脚本实例 转载 file是一个类,使用file('file_name', 'r+')这种方式打开文件,返回一个file对象,以写模式打开文件不存在则会被创建.但是更推荐使用内置函 ...
- python常用运维脚本实例【转】
file是一个类,使用file('file_name', 'r+')这种方式打开文件,返回一个file对象,以写模式打开文件不存在则会被创建.但是更推荐使用内置函数open()来打开一个文件 . 首先 ...
- Sensitive directory/file Integrity Monitoring and Checking
catalogue . OSSEC . HashSentry: Host-Based IDS in Python . Afick . 检测流程 1. OSSEC OSSEC is an Open So ...
- Python检测服务端口存活状态并报警
最近发现公司的测试环境中有个Socket服务的端口总是莫名其妙Down掉,但是服务却正常运行着,看样子是僵死了... 虽然是测试环境,但是也不能这样放着不管,于是连夜写了一个简单的监控脚本.因为服务器 ...
随机推荐
- python基础(二)--多值参数以及类
1.多值参数函数 def 函数名(*args , **kwargs): ....... 多值参数函数顾名思义能够传入多个参数,args表示传入的元组,kwargs表示传入的字典 def functio ...
- webstorm出现黑色块光标
取消掉此项对勾即可
- Linq批量建表
public JsonResult CreateTable() { db = new RZBDbContext(); var query = (from c in db.Clients select ...
- NS Simulation Basic
这个网站上的一系列讲解NS2的内容真的是深入浅出,看完立刻豁然开朗.所以就接连转了几篇. Scheduling Events那篇里的例子特别好,看完就懂了. http://www.mathcs.emo ...
- JIAVA知识点整理
Java具有垃圾回收机制,程序退出之后,使用的所有内存全部都将被释放,如要保存数据你就要建立文件,因为当保存时是保存在运行内存中的. int 有返回值void 不需要返回值 1.判断语句if else ...
- 【Leetcode】【Easy】Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- [问题记录]libpomelo编译报错:ssize_t重定义
1. 时间:2015/01/16 描述:添加libpomelo到cocos2dx项目,报错如下图所示: 解决: 修改代码,源代码: #if !defined(_SSIZE_T_) && ...
- linux下清空文件的几种方式以及对比
: > filename> filenamecat /dev/null > filename上面这3种方式,能将文件清空,而且文件大小为0而下面两种方式,会让文件中存在空格,导致大小 ...
- sql语句浅谈以及mysql遇到的问题解决见解
mysql数据库基本操作: .显示数据库和查看mysql版本 show databases; select version(); select user();查看用户 .选择数据库 use 数据库名; ...
- February 20 2017 Week 8 Monday
Behind every beautiful thing, there's some kind of pain. 美丽背后,必有努力. No pains, no gains, and sometime ...