[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1419
  • Last Modified:

snmpd won't start

Hi,
my snmpd don't start at system startup or manual start/restart ... see output:

[root@icinga-demo ~]# /etc/init.d/snmpd start
Starting snmpd: /bin/bash: line 1:  7823 Segmentation fault      /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
                                                           [FAILED]

but this will work:
[root@icinga-demo ~]# /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
(it is the line from the error message)
.. and now the snmpd work very well

has someone an idea?
0
Dirk Kotte
Asked:
Dirk Kotte
  • 5
  • 5
  • 3
1 Solution
 
edster9999Commented:
If it runs on the command line then this makes it less likely it is corruption of the command or files.

I would start by checking what user/group the command runs as if it is run from the init.d script (read it or post it here).
If it is a different user then try 'su' to that user and then run it from there.
Check the log files to see if anything goes into an snmpd log file or messages log file

0
 
arnoldCommented:
It is a corruption in the script.
can you post the script /etc/init.d/snmpd
What does it have on line 1?
0
 
Dirk KotteSEAuthor Commented:
additional info:
this works also
[root@icinga-demo ~]# /etc/init.d/snmpd stop

anf here the output from  /etc/init.d/snmpd restart:

[root@icinga-demo ~]# /etc/init.d/snmpd restart
Stopping snmpd:                                            [  OK  ]
Starting snmpd: /bin/bash: line 1:  3544 Segmentation fault      /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
                                                           [FAILED]
[root@icinga-demo ~]#

i think the script /etc/init.d/snmpd are not corrupt...if the stop command run without errors
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
arnoldCommented:
The start command might be doing something the stop command does not.

Without seeing what it is trying to do during the start process.

i.e. when you drive your car you press one set of pedals to go and one set of pedals to stop. Because you can do one does not mean the other will work.
i.e. you put the car in neutral and when pushed you can hit the brake to stop.  hitting the accelerator will not make the car move in this scenario.
 

what happens if on the command line you run the following:
daemon /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
0
 
Dirk KotteSEAuthor Commented:
the result:
[root@icinga-demo ~]# daemon /usr/sbin/snmpd -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid
bash: daemon: command not found...

start and stop command use the same etc/init.d/snmpd script and booth should pass the line 1.
because this i think there are no problem within this script. But i can post this...  
0
 
Dirk KotteSEAuthor Commented:
etc/init.d/snmpd


#!/bin/bash
# ucd-snmp init file for snmpd
#
# chkconfig: - 50 50
# description: Simple Network Management Protocol (SNMP) Daemon
#
# processname: /usr/sbin/snmpd
# config: /etc/snmp/snmpd.conf
# config: /usr/share/snmp/snmpd.conf
# pidfile: /var/run/snmpd.pid

### BEGIN INIT INFO
# Provides: snmpd
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start: 
# Should-Stop: 
# Default-Start: 
# Default-Stop: 
# Short-Description: start and stop Net-SNMP daemon
# Description: Simple Network Management Protocol (SNMP) Daemon
### END INIT INFO

# source function library
. /etc/init.d/functions


OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"
if [ -e /etc/sysconfig/snmpd ]; then
  . /etc/sysconfig/snmpd
fi

RETVAL=0
prog="snmpd"
binary=/usr/sbin/snmpd
pidfile=/var/run/snmpd.pid

start() {
        [ -x $binary ] || exit 5
        echo -n $"Starting $prog: "
        if [ $UID -ne 0 ]; then
                RETVAL=1
                failure
        else
                daemon --pidfile=$pidfile $binary $OPTIONS
                RETVAL=$?
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
        fi;
        echo 
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        if [ $UID -ne 0 ]; then
                RETVAL=1
                failure
        else
                killproc -p $pidfile $binary
                RETVAL=$?
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
        fi;
        echo
        return $RETVAL
}

reload(){
        echo -n $"Reloading $prog: "
        killproc -p $pidfile $binary -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

restart(){
	stop
	start
}

condrestart(){
    [ -e /var/lock/subsys/snmpd ] && restart
    return 0
}

case "$1" in
  start)
	start
	RETVAL=$?
	;;
  stop)
	stop
	RETVAL=$?
	;;
  restart)
	restart
	RETVAL=$?
        ;;
  reload|force-reload)
	reload
	RETVAL=$?
        ;;
  condrestart|try-restart)
	condrestart
	RETVAL=$?
	;;
  status)
        status snmpd
	RETVAL=$?
        ;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
	RETVAL=2
esac

exit $RETVAL

Open in new window

0
 
arnoldCommented:
see line #45

daemon --pidfile=$pidfile $binary $OPTIONS
 
prepend the following line above line #45 and comment the above line out.
echo daemon --pidfile=$pidfile $binary $OPTIONS
and see what happens when you try to start it..

Post the output. and revert back.
0
 
edster9999Commented:
also can you post what is in this file :
/etc/sysconfig/snmpd
0
 
Dirk KotteSEAuthor Commented:
i have destroied my snmpd scrip while using wordpad.
there are an ^M at the end of every line.
next days i copy a new/clean file from another appliance and post the results.
(or there are some tips to repair this)
0
 
edster9999Commented:
If you can use vi to edit then do

vi snmpd
start typing this and it will go down to the command promt (bottom line)
:g/^M/s///
press enter after it and all the ^M's should vanish
press : to get to the command prompt at the bottom again and type
wq
and press eneter to write and quit
0
 
edster9999Commented:
or I guess you could do it on the command line if 'vi' is not your thing :

cd /etc/init.d
mv snmpd snmpd-bak
sed 's(ctrl+v ctrl+m)g//g' snmpd-bak > snmpd


0
 
edster9999Commented:
and as you just learned.... dont edit unix files in windows :)
0
 
Dirk KotteSEAuthor Commented:
the repair of the file works, but the first still exists.
after snapshotting the machine i do and
yum /reinstall
this solves all problems.
thanks all
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 5
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now