linux开启snmp服务
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
实验环境
CentOS 64位, 内核(3.10.0-957.el7.x86_64)
CentOS Linux release 7.6.1810 (Core)
以下所有步骤都以root
的身份来操作, 只是为了实验而已
步骤
安装相关组件
yum install -y net-snmp*
修改配置
$ cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
$ vim /etc/snmp/snmpd.conf
# 添加如下内容
rocommunity mycommunity # community值, 类似于密码
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
access notConfigGroup "" any noauth exact all none none
view all included .1 80
syslocation Unknown
syscontact Root <root@localhost>
dontLogTCPWrappersConnects yes
重启服务
$ systemctl restart snmpd
# snmp服务默认开启161端口(UDP), 可以这样查看启动没有
$ netstat -tlunp | grep :161
udp 0 0 0.0.0.0:161 0.0.0.0:* 86881/snmpd
测试
$ cat /etc/hostname
# 显示: localhost.localdomain
# 调snmp协议查看本机主机名
# 其中'1.3.6.1.2.1.1.5.0'是主机名对就的OID
$ snmpget -v 2c -c mycommunity localhost '1.3.6.1.2.1.1.5.0'
#显示: SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
# 设置hostname
$ echo my-machine > /etc/hostname
$ hostname `cat /etc/hostname`
$ systemctl restart snmpd
# 再次调snmp协议查看本机主机名
$ snmpget -v 2c -c mycommunity localhost '1.3.6.1.2.1.1.5.0'
# 显示: SNMPv2-MIB::sysName.0 = STRING: my-machine
参考
https://blog.51cto.com/14010230/2324117
目前对snmp只是有个初步了解,以后有机会再分享。
欢迎补充指正!




A beautiful web dashboard for Linux
最近提交(Master分支:5 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
所有评论(0)