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掉,但是服务却正常运行着,看样子是僵死了... 虽然是测试环境,但是也不能这样放着不管,于是连夜写了一个简单的监控脚本.因为服务器 ...
随机推荐
- 是否应该开启WebView硬件加速?
android webview 在3.0+后显示flash要启用硬件加速,开启硬件加速也能够使绘制更加平滑. 开启硬件加速是在manifest中加入: android:hardwareAccelera ...
- Data truncation: Out of range value for column 'id' at row 1 ### The
org.springframework.dao.DataIntegrityViolationException: ### Error updating database. Cause: com.mys ...
- 调用Linux的busybox,通过linux命令来获取AndRoidIP
//根据busybox获取本地Mac public static String getLocalMacAddressFromBusybox(){ String result = "" ...
- GIT团队合作探讨之二--Pull Request
pull request是github/bitbucket给开发人员实现便利合作提供的一个feature.他们提供一个用户友好的web界面在进代码之前来讨论这些变更. 简单说,pull request ...
- 网站的Information Architecture--构建一个最优用户体验的site structure
http://conversionxl.com/website-information-architecture-optimal-user-experience/ 在网站上应该有什么类型的conten ...
- leetcode-Restore IP Addresses-ZZ
http://www.cnblogs.com/remlostime/archive/2012/11/14/2770072.html class Solution { private: vector&l ...
- Python初学者第一天 Python安装及第一个Python程序
Python基础: 1day: 1.Python基础: A.编程语言介绍: a. 计算机只能理解0和1.编程即写一段按照一定规则写代码,让计算机帮你干活: b.机器语言:最底层的语言, ...
- Spark Broadcast内幕解密:Broadcast运行机制彻底解密、Broadcast源码解析、Broadcast最佳实践
本课主题 Broadcast 运行原理图 Broadcast 源码解析 Broadcast 运行原理图 Broadcast 就是将数据从一个节点发送到其他的节点上; 例如 Driver 上有一张表,而 ...
- Yii 验证和消息
setFlash(), getFlash()可以完成验证成功后提示 <?php # 成功信息提示 Yii::app()->user->setFlash('success', &quo ...
- BZOJ 4028: [HEOI2015]公约数数列 【分块 + 前缀GCD】
任意门:https://www.lydsy.com/JudgeOnline/problem.php?id=4028 4028: [HEOI2015]公约数数列 Time Limit: 10 Sec ...