snmpd daemon status validation

If the snmpd daemon terminates as soon as it is invoked, the following are possible reasons for failure and probable solutions:

  • The reason the snmpd daemon terminated will be logged in the snmpd log file or the configured syslogd log file. Check the log file to see the FATAL error message.

Solution: Correct the problem and restart the snmpd daemon.

service snmpd restart
  • The snmpd daemon must be invoked by the root user.

    Solution: Switch to the root user and restart the snmpd daemon.

    [omkadmin@lab_latam_omk1 ~]# su root
    Password:
    [root@lab_latam_omk1 ~]#
    [root@lab_latam_omk1 ~]# service snmpd restart
  • The snmpd.conf file must be owned by the root user. The snmpd agent verifies the ownership of the configuration file. If the file is not owned by the root user, the snmpd agent terminates with a fatal error.

Solution: Make sure you are the root user, change the ownership of the configuration file to the root user, and restart the snmpd daemon

[root@lab_latam_omk1 ~]# cd /etc/snmp/
[root@lab_latam_omk1 snmp]# ll
total 24
-rw------- 1 root root 19090 Oct 25 13:13 snmpd.conf
-rw------- 1 root root   220 Jul 29  2019 snmptrapd.conf
[root@lab_latam_omk1 snmp]#

.

  • The udp port 161 is already bound. Make sure that the snmpd daemon is not already running. Issue the ps -eaf | grep  or lsof -i :199 command to determine if an snmpd daemon process is already executing. Only one snmpd agent can bind to udp port 161.

    Solution: Either kill the existing snmpd agent or do not try to start up another snmpd daemon process.

[root@lab_latam_omk1 snmp]# ps -eaf | grep snmpd
root      2317     1  0 Nov19 ?        00:59:28 /usr/sbin/snmpd -LS0-6d -f
root     14379 13080  0 16:56 pts/0    00:00:00 grep --color=auto snmpd
You have new mail in /var/spool/mail/root
[root@lab_latam_omk1 snmp]# lsof -i :199
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
snmpd   2317 root    8u  IPv4  22950      0t0  TCP localhost:smux (LISTEN)
[root@lab_latam_omk1 snmp]#


Activate, start, stop and restart the service.

Run the following to activate the service at all runlevels:

chkconfig snmpd on

Run the following to run the service for the first time:

service snmpd start

Run the following to restart the service and apply changes made to the configuration:

service snmpd restart

Run the following to stop the service:

service snmpd stop

Annex

the following script is added to perform these validations.