snmptrapd suddenly failing to start

Posted on

RHEL 9.2

I've been working on a script to get snmpv3 engineID's, update the snmptrad.conf and restart snmptrapd.

I've been stopping and starting it successfully from the CLI without issue, but when I do it from my script it seems to have "broken" it and I can't get it to start. I was running the script in an SSH session.
Here's the stop/start section of the script:

 echo "$(date '+%Y-%m-%d %H:%M:%S') Stopping snmptrapd" >> $myLog systemctl stop snmptrapd
echo "$(date '+%Y-%m-%d %H:%M:%S') copying tmp file to snmptrad.conf" >> $myLog
/bin/cp $snmpPath/$MyFile $snmpPath/$confFile
echo "$(date '+%Y-%m-%d %H:%M:%S') Starting snmptrapd" >> $myLog
systemctl start snmptrapd
echo "$(date '+%Y-%m-%d %H:%M:%S') Ending GetEngineID" >> $myLog 
echo '-----------------------------' >> $myLog

Here's the error when trying to start it:

 snmptrapd.service - Simple Network Management Protocol (SNMP) Trap Daemon.
     Loaded: loaded (/usr/lib/systemd/system/snmptrapd.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Thu 2024-05-02 13:37:56 EDT; 7min ago
    Process: 4600 ExecStart=/usr/sbin/snmptrapd $OPTIONS -f (code=exited, status=1/FAILURE)
   Main PID: 4600 (code=exited, status=1/FAILURE)
        CPU: 47ms

May 02 13:37:56 rheldesk systemd[1]: Starting Simple Network Management Protocol (SNMP) Trap Daemon....
May 02 13:37:56 rheldesk systemd[1]: snmptrapd.service: Main process exited, code=exited, status=1/FAILURE
May 02 13:37:56 rheldesk systemd[1]: snmptrapd.service: Failed with result 'exit-code'.
May 02 13:37:56 rheldesk systemd[1]: Failed to start Simple Network Management Protocol (SNMP) Trap Daemon..

Anyone have any insight on what the issue is?

Regards,
Tom

Responses