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掉,但是服务却正常运行着,看样子是僵死了... 虽然是测试环境,但是也不能这样放着不管,于是连夜写了一个简单的监控脚本.因为服务器 ...
随机推荐
- BitmapFactory 读取图片方法总结
①decodeFile(java.lang.String pathName) ②decodeResource(android.content.res.Resources res, int id ...
- Netty入门1之----认识Netty
Netty 什么是Netty? Netty 是一个利用 Java 的高级网络的能力,隐藏其背后的复杂性而提供一个易于使用的 API 的客户端/服务器框架. Netty 是一个广泛使用的 Java ...
- SSIS ->> Environment Variables
SQL Server Integration Services(SSIS) 在2012版本引入了Environment Variables这个新特性.它允许我们为一个环境创建出一套变量用于为项目内的包 ...
- QT的QPropertyAnimation讲解
m_pAnimation->setEasingCurve(QEasingCurve::Linear); //直线风格 m_pAnimation->setLoopCount(-1); //无 ...
- C/C++内存泄露检测
以下测试基于的gcc版本: gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4Copyright (C) 2013 Free Software Foundation, In ...
- 【深入理解JAVA虚拟机】第一部分.走进Java
Java技术体系 如果仅从传统意义上来看,Sun官方所定义的Java技术体系包括以下几个组成部分:Java程序设计语言各种硬件平台上的Java虚拟机Class文件格式Java API类库来自商业机构和 ...
- GO语言(七)多核并行化的问题
package main import "fmt" type Vector []float64 func (v Vector) DoSome(i,n int, u Vector, ...
- 迷宫问题求解——C++
迷宫问题思路 根据昨天的博客,有如下几种解决方案 克鲁斯卡尔 ,为避免死循环,需要设定优化路径的次数. Prim,为避免死循环,需要设定优化路径的次数,暂定200次. BFS , 实现简单,无死循环. ...
- FRP-Functional Reactive Programming-函数响应式编程
响应式编程是一种面向数据流和变化传播的编程范式: 响应式编程和函数式编程的融合: 响应式编程为内核:函数式编程为工具: 流的概念先天适合函数式编程. Some quotes from the arti ...
- [cocos2d-x]-会动的精灵
小鸟一直在扑翅膀的代码块: auto sprite = Sprite::create(); Animation *animation = Animation::create(); animation- ...