Check if the system has SNMP services installed# Rpm-qa|grep SNMP
Net-snmp-5.3.2.2-17.el5
Net-snmp-perl-5.3.2.2-17.el5
Net-snmp-devel-5.3.2.2-17.el5
Net-snmp-libs-5.3.2.2-17.el5
Net-snmp-utils-5.3.2.2-17.el5
Net-snmp-libs-5.3.2.2-17.el5
Net-snmp-devel-5.3.2.2-17.el5
The SNMP service will have the above installation package after installation
Installing the SNMP service1. Configure the local Yum service and use Yum to install Yum install-y net-snmp*
2. Configure the SNMP service to boot #chkconfig snmpd on
#chkconfig--list | grep snmpd See if boot boot settings are successful
SNMPD 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
Verifying the SNMP service1. Use Snmpwalk to get host name # snmpwalk-v 2c-c public localhost sysname.0
snmpv2-mib::sysname.0 = string:wh69
Snmpwalk usage
Snmpwalk-v 1|2c|3 (on behalf of SNMP version)-C <community string> IP address OID (object identifier)
2. Use the snmptranslate command to check if the SNMP tool can use # Snmptranslate-to | Head
.1.3
.1.3.6
.1.3.6.1
.1.3.6.1.1
.1.3.6.1.2
.1.3.6.1.2.1
.1.3.6.1.2.1.1
.1.3.6.1.2.1.1.1
.1.3.6.1.2.1.1.2
.1.3.6.1.2.1.1.3
A partial OID is detected, which means the SNMP tool can be used normally
Configuring the SNMP service1. Configure the SNMP connection string community string #vi/etc/snmp/snmpd.conf
Modify the following fields
# Sec.name source communitycom2sec notconfiguser default public
Modify
PublicCommunity string defined for itself
2. Modify the View Device node permissions to find the following location in the configuration file/etc/snmp/snmpd.conf
##### Third, create a view for us to let the group has rights to:# make at least snmpwalk-v 1 localhost-c Public sy Stem fast again.# name incl/excl subtree mask (optional) view SystemView included . 1.3.6.1.2.1.1view SystemView included . 1.3.6.1.2.1.25.1.1
View: Defines the information for which node devices can be viewed.
The SNMP default configuration can only view device information under the. 1.3.6.1.2.1.1 and. 1.3.6.1.2.1.25.1.1 nodes,
Devices such as the host CPU and memory are not available under these nodes, so the data cannot be obtained.
Therefore, you can modify this configuration as follows:
##### Third, create a view for us to let the group has rights to:# make at least snmpwalk-v 1 localhost-c Public sy Stem fast again.# name incl/excl subtree mask (optional) view SystemView included . 1view SystemView included . 1.3.6.1.2.1.1view systemview included . 1.3.6.1.2.1.25.1.1
A row is added here:
view SystemView included. 1
Indicates that you can view all device information under the. 1 node.
3. Modify the configuration of the process checks to find the following location in the configuration file/etc/snmp/snmpd.conf
################################################################################ Process checks.## the Following is examples of the the agent to check for# processes running on the host. The syntax looks something like:## proc name [max=0] [min=0]## name: The name of the process to check for.
it must match# exactly (ie, HTTP would not find httpd processes). # MAX: The maximum number allowed-be Runni Ng. Defaults to 0.# MIN: The minimum number to be running. Defaults to 0.## Examples (commented off by default): # Make sure mountd are running#proc mountd# make sure There was no more than 4 NTALKDS running, but 0 was ok too. #proc ntalkd 4# make sure at least one sendmail, but less t Han or equal to running. #proc SendMail 10 1
Remove
#proc Mountd
#proc NTALKD 4
#proc SendMail 1
The # number in front of these three lines, uncomment
4. Modify the executables/scripts configuration to find the following location in the configuration file/etc/snmp/snmpd.conf
################################################################################ Executables/scripts### You can also has programs run by the agent so return a single# line of output and an exit code. Here is the examples.## exec NAME program [ARGS ...] # # NAME: A Generic name.# Program: The program to run. Include the path!# ARGS: Optional arguments to being passed to the program# a simple Hello world#exec echotest/bin /echo Hello world# Run a shell script containing:
Will
#exec Echotest/bin/echo Hello World
The previous # removed, uncomment
5. Modify Disk Checks Configuration
Find the following location in the configuration file/etc/snmp/snmpd.conf
################################################################################ Disk checks## the agent can check The amount of available disk space, and make# sure it is above a set limit. # disk path [min=100000]## path: mount path to the disk in question.# MIN: Disks with space below this value would The Mib ' s errorflag set.# Default value = 100000.# Check the/partition and make sure it contains at least me GS. #disk/10000
Will
#disk/10000
Before the # number is removed, uncomment
6. Modify the load average checks configuration to find the following location in the configuration file/etc/snmp/snmpd.conf
################################################################################ load average checks## load [1MAX= 12.0] [5max=12.0] [15max=12.0]## 1MAX: If the 1 minute load average is above this limit at query# time , the Errorf Lag'll is set.# 5MAX: Similar, but is 5 min average.# 15MAX: Similar, but for min average.# Check for loads: #load 12 14 14
Will
#load
Before the # removed, uncomment
7. Save the changes, restart the SNMP service #service snmpd restart
8. Verify the SNMP service after modifying the configuration # snmpwalk-v 2c-c xindixindi localhost 1.3.6.1.4.1.2021.11.11.0
ucd-snmp-mib::sscpuidle.0 = integer:99
As above, the idle rate from native localhost to the CPU is 99%
Complete the configurationThe Linux server can now be monitored through the SNMP service in monitoring systems such as solarwinds and cacti.