|
安装snmp包
[root@localhost tmp]# yum install net-snmp
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package net-snmp.x86_64 1:5.7.2-37.el7 will be installed
--> Processing Dependency: net-snmp-agent-libs = 1:5.7.2-37.el7 for package: 1:net-snmp-5.7.2-37.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:net-snmp-5.7.2-37.el7.x86_64
--> Processing Dependency: libnetsnmptrapd.so.31()(64bit) for package: 1:net-snmp-5.7.2-37.el7.x86_64
--> Processing Dependency: libnetsnmpmibs.so.31()(64bit) for package: 1:net-snmp-5.7.2-37.el7.x86_64
--> Processing Dependency: libnetsnmpagent.so.31()(64bit) for package: 1:net-snmp-5.7.2-37.el7.x86_64
--> Running transaction check
---> Package net-snmp-agent-libs.x86_64 1:5.7.2-37.el7 will be installed
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================================
Installing:
net-snmp x86_64 1:5.7.2-37.el7 mnt 331 k
Installing for dependencies:
net-snmp-agent-libs x86_64 1:5.7.2-37.el7 mnt 705 k
perl-Data-Dumper x86_64 2.145-3.el7 mnt 47 k
Transaction Summary
====================================================================================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 1.1 M
Installed size: 3.0 M
Is this ok [y/d/N]: y
Downloading packages:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 72 MB/s | 1.1 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:net-snmp-agent-libs-5.7.2-37.el7.x86_64 1/3
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 2/3
Installing : 1:net-snmp-5.7.2-37.el7.x86_64 3/3
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 1/3
Verifying : 1:net-snmp-agent-libs-5.7.2-37.el7.x86_64 2/3
Verifying : 1:net-snmp-5.7.2-37.el7.x86_64 3/3
Installed:
net-snmp.x86_64 1:5.7.2-37.el7
Dependency Installed:
net-snmp-agent-libs.x86_64 1:5.7.2-37.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
Complete!
修改参数
[root@localhost tmp]# cd /etc/snmp/
[root@localhost snmp]# vi snmpd.conf
###############################################################################
#
# snmpd.conf:
# An example configuration file for configuring the ucd-snmp snmpd agent.
#
###############################################################################
#
# This file is intended to only be as a starting point. Many more
# configuration directives exist than are mentioned in this file. For
# full details, see the snmpd.conf(5) manual page.
#
# All lines beginning with a '#' are comments and are intended for you
# to read. All other lines are configuration commands for the agent.
###############################################################################
# Access Control
###############################################################################
# As shipped, the snmpd demon will only respond to queries on the
# system mib group until this file is replaced or modified for
# security purposes. Examples are shown below about how to increase the
# level of access.
# By far, the most common question I get about the agent is "why won't
# it work?", when really it should be "how do I configure the agent to
# allow me to access it?"
#
# By default, the agent responds to the "public" community for read
# only access, if run out of the box without any configuration file in
# place. The following examples show you other ways of configuring
# the agent so that you can change the community names, and give
# yourself write access to the mib tree as well.
#
# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.
####
# First, map the community name "public" into a "security name"
# sec.name source community
com2sec notConfigUser default chcmu-admin --公共名称
####
# Second, map the security name into a group name:
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group 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
view systemview included .1 -增加
"snmpd.conf" 463L, 18902C written
[root@localhost snmp]#
[root@localhost snmp]#
[root@localhost snmp]#
查看snmp服务
[root@localhost snmp]# systemctl status snmpd.service
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
重启snmp服务
[root@localhost snmp]# systemctl restart snmpd.service
[root@localhost snmp]# systemctl status snmpd.service
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2024-01-25 11:37:55 CST; 3s ago
Main PID: 85932 (snmpd)
Tasks: 1
CGroup: /system.slice/snmpd.service
└─85932 /usr/sbin/snmpd -LS0-6d -f
Jan 25 11:37:55 localhost.localdomain systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
Jan 25 11:37:55 localhost.localdomain snmpd[85932]: NET-SNMP version 5.7.2
Jan 25 11:37:55 localhost.localdomain systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..
[root@localhost snmp]#
|
|