- Created by SS Doc Editor on Sep 09, 2021
1. FIREWALL
If you use an external firewall make sure the following ports are open: 22 (SSH, TCP), 161(SNMP, TCP/UDP), 53 (DNS, UDP), 80 and 443 (HTTP HTTPS, TCP), ICMP (ping)
2. INSTALLATION.
To install SNMP Agent Daemon and SNMP clients, use Yum package manager available on all RedHat Operating systems. Login into the server as a root user and execute the following:
~]# yum -y install net-snmp net-snmp-libs net-snmp-utils |
|---|
3. CONFIGURATION
Move snmd.conf to snmpd.conf_bak:(in order to backup defaults)
~]# cd /etc/snmp/
~]# mv snmpd.conf snmpd.conf_bak
Add the following configuration to new snmpd.conf file (replace “My Location” and “My Name” with your data):
~]# echo 'syslocation "My Location"' >> snmpd.conf
~]# echo 'syscontact "My Name"' >> snmpd.conf
~]# echo '' >> snmpd.conf
~]# echo 'rocommunity public' >> snmpd.conf
~]# echo '' >> snmpd.conf
~]# echo 'disk /' >> snmpd.conf (this is for disk counters)
4. STARTING THE SERVICE
To run the snmpd service in the current session, enter the following at a shell prompt as root:
~]# service snmpd start
To configure the service to be automatically started at boot time, use the following command:
~]# chkconfig snmpd on
5. TESTING, TROUBLESHOOTING
To make sure SNMP listens on a valid port and to all IPs execute this command
~]# netstat -nepl
- If SNMP listener works only on 127.0.0.1 IP addresses, try to restart snmpd daemon (~]# service snmpd restart).
If the previous step does not help, check “SNMPDOPTS=” string at /etc/default/snmpd and make sure it looks like this.
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'
Make sure SNMP is appropriately installed. For example, the following snmpwalk command shows the system tree with a default agent configuration.
~]# snmpwalk -v2c -c public localhost system
The output should look like this:
public static void main(String[] args) { System.out.println("SNMPv2-MIB::sysDescr.0 = STRING: Linux ip-10-239-15-166 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon Jun 17 15:54:20 EDT 2013 x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1013444) 2:48:54.44 SNMPv2-MIB::sysContact.0 = STRING: "My Name" SNMPv2-MIB::sysName.0 = STRING: ip-10-239-15-166 SNMPv2-MIB::sysLocation.0 = STRING: "My Location" "); } |
|---|
- Select a counter by completing the Add SNMP Counters dialog, as described in the previous section, and click Test. You should receive "The SNMP counter is tested successfully" message.
If instead you receive "Can't connect to the host" message, make sure that port 161 is open for UDP and TCP traffic on the Linux server. To open these ports, execute the following commands:
public static void main(String[] args) { System.out.println("iptables -I INPUT -p udp --dport 161 -j ACCEPT
iptables -I INPUT -p tcp --dport 161 -j ACCEPT
iptables -I FORWARD -p udp --dport 161 -j ACCEPT
iptables -I FORWARD -p tcp --dport 161 -j ACCEPT
iptables-save"); }
- No labels



