Install and configure the snmp service in the RedHat Linux System

Source: Internet
Author: User
Tags snmpwalk

Check whether the system has installed the snmp service # 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 above installation packages will be available after the SNMP service is installed.


Install the SNMP service 1. Configure the local yum service and use yum to install yum install-y net-snmp *
2. Configure SNMP Service Startup # chkconfig snmpd on
# Chkconfig -- list | grep snmpd check whether startup setting is successful
Snmpd 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable

Verify SNMP Service 1. Use snmpwalk to obtain the host name # snmpwalk-v 2c-c public localhost sysName.0
SNMPv2-MIB: sysName.0 = STRING: wh69
Snmpwalk usage
Snmpwalk-v 1 | 2c | 3 (SNMP Version)-c <community string> ip address OID (object identifier)
2. Run the snmptranslate command To check whether 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
If some oid is found, the snmp tool can be used normally.

Configure SNMP Service 1. Configure the SNMP connection string community string # vi/etc/snmp/snmpd. conf
Modify the following fields
#       sec.name  source          communitycom2sec notConfigUser  default    public
Modify PublicCustom community string
2. Modify the permission to view the device node. Find the following location in the configuration file/etc/snmp/snmpd. conf:
##### 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.1view    systemview    included   .1.3.6.1.2.1.25.1.1
View: defines which node devices can be viewed.
By default, snmp can only view device information under nodes 1.3.6.1.2.1.1 and 1.3.6.1.2.1.25.1.1,
The host's CPU, memory, and other devices are not under these nodes, so the data cannot be obtained.
Therefore, you can modify the configuration as follows:
##### 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   .1view    systemview    included   .1.3.6.1.2.1.1view    systemview    included   .1.3.6.1.2.1.25.1.1
A line is added here:
View systemview supported ded. 1
Displays information about all devices on the. 1 node.
3. Modify the Process checks configuration and find the following position in the configuration file/etc/snmp/snmpd. conf:
################################################################################ Process checks.##  The following are examples of how to use 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 will not find httpd processes).#  MAX:   the maximum number allowed to be running.  Defaults to 0.#  MIN:   the minimum number to be running.  Defaults to 0.##  Examples (commented out by default):##  Make sure mountd is running#proc mountd#  Make sure there are no more than 4 ntalkds running, but 0 is ok too.#proc ntalkd 4#  Make sure at least one sendmail, but less than or equal to 10 are running.#proc sendmail 10 1
Remove
# Proc mountd
# Proc ntalkd 4
# Proc sendmail 10 1

# Before the three lines, uncomment
4. modify Executables/scripts and find the following position in the configuration file/etc/snmp/snmpd. conf:
################################################################################ Executables/scripts###  You can also have programs run by the agent that return a single#  line of output and an exit code.  Here are two examples.##  exec NAME PROGRAM [ARGS ...]##  NAME:     A generic name.#  PROGRAM:  The program to run.  Include the path!#  ARGS:     optional arguments to be passed to the program# a simple hello world#exec echotest /bin/echo hello world# Run a shell script containing:
Set
# Exec echotest/bin/echo hello world
Remove the preceding # and cancel the annotation.
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 will have the Mib's errorFlag set.#        Default value = 100000.# Check the / partition and make sure it contains at least 10 megs.#disk / 10000
Set
# Disk/10000
Remove the # Before and cancel the comment.

6. Modify the load average checks configuration and find the following position 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 errorFlag will be set.# 5MAX:   Similar, but for 5 min average.# 15MAX:  Similar, but for 15 min average.# Check for loads:#load 12 14 14
Set
# Load 12 14 14
Before # Remove, uncomment
7. Save the modification and restart the snmp service # service snmpd restart
8. Verify the snmp service after the configuration is modified # snmpwalk-v 2c-c xindixindi localhost 1.3.6.1.4.1.2021.11.11.0
UCD-SNMP-MIB: ssCpuIdle.0 = INTEGER: 99
As shown above, the CPU idle rate obtained through the local localhost is 99%.

Now, you can monitor the linux server through the SNMP service in monitoring systems such as solarwinds and Cacti.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.