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?
LVL 25
Dirk KotteSEAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.