Python 官方文档:入门教程 => 点击学习
使用的系统为Redhat 7.6 的64位,使用Net-SNMP 5.7版本安装mysql包rpm -ivh Mysql-commUnity-libs-compat*不安装这个包会出现如下报错安装cd /mnt/Pack
使用的系统为Redhat 7.6 的64位,使用Net-SNMP 5.7版本
安装
cd /mnt/Packagesrpm -ivh net-snmpyum install -y net-snmp-perlyum install -y net-snmp-utilsyum install -y net-snmp-develyum install -y net-snmp-lib
验证
可以使用下面的命令去验证你是否成功安装了Net-SNMP,如果你可以获取到正确的版本号,说明你已经成功安装了Net-SNMP
snmpget --version
配置snmpd.conf
vi /etc/snmp/snmpd.conf
################################################################################ Access Control################################################################################ First, map the community name "public" into a "security name"# sec.name source communitycom2sec notConfigUser default publiC# Second, map the security name into a group name:# groupName securityModel securityNamegroup notConfigGroup v1 notConfigUsergroup notConfigGroup v2c notConfigUser# Third, create a view for us to let the group have rights to:# Make at least snmpwalk -v 1 localhost -c public system fast again.# name incl/excl subtree mask(optional)#view systemview included .1.3.6.1.2.1.1#view systemview included .1.3.6.1.2.1.25.1.1# Finally, grant the group read-only access to the systemview view.# group context sec.model sec.level prefix read write notifaccess notConfigGroup "" any noauth exact all none none# -----------------------------------------------------------------------------# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWord ONLY# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.## incl/excl subtree maskview all included .1 80################################################################################ System contact infORMation## It is also possible to set the sysContact and sysLocation system# variables through the snmpd.conf file:syslocation Unknown (edit /etc/snmp/snmpd.conf)syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)################################################################################ Logging## We do not want annoying "Connection from UDP: " messages in syslog.# If the following option is commented out, snmpd will print each incoming# connection, which can be useful for debugging.dontLogtcpWrappersConnects yes###############################################################################com2sec notConfigUser localhost Server_pu
运行snmpd 且开机自启动
chkconfig snmpd onsystemctl start snmp
可通过如下命令检查snmpd是否启动
netstat -na | grep 161
或
ps aux | grep snmp
测试snmpd
可以用如下的几个命令获取系统开机时间,如果有正确的返回则说明snmp运行正常
snmpwalk -v 2c -c public localhost sysUpTime.0
pip install client
pip install python3-netsnmp
--结束END--
本文标题: Python 开发环境搭建(5):SNMP
本文链接: https://www.lsjlt.com/news/245004.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0