Станное поведение snmpd (OpenBSD 5.2 i386)

FreeBSD, NetBSD, OpenBSD, DragonFly и т. д.

Модератор: arachnid

Ответить
Аватара пользователя
Stauffenberg
Сообщения: 2042
Статус: ☮ PEACE ☮
ОС: открытая и свободная

Станное поведение snmpd

Сообщение Stauffenberg »

Всем привет.

На OpenBSD 5.2 (i386) получаю странное сообщение, при попытке запустить snmpd:

Код: Выделить всё

# /etc/rc.d/snmpd start
httpd2 (pid 29518) already running

Демон не стартует.

cat /etc/rc.d/snmpd:

Код: Выделить всё

#!/bin/sh
#
# $OpenBSD: snmpd,v 1.1 2011/07/06 18:55:36 robert Exp $

daemon="/usr/sbin/snmpd"

. /etc/rc.d/rc.subr

pexp="snmpd: parent.*"

rc_cmd $1


Если же вручную, то все работает (хотя PID процесса смущает):

Код: Выделить всё

# /usr/sbin/snmpd &
[1] 10259

# ps aux | grep snmpd
root     23284  0.0  0.1   556   980 ??  Ss     4:59PM    0:00.00 snmpd: parent (snmpd)
_snmpd   28300  0.0  0.1   556  1116 ??  S      4:59PM    0:00.00 snmpd: snmp engine (snmpd)
root      6434  0.0  0.1   432   708 p0  S+     4:59PM    0:00.00 grep snmpd
[1] + Done                 /usr/sbin/snmpd
Labor omnia vincit

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” (Brian Kernighan)
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 20794
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: Станное поведение snmpd

Сообщение Bizdelnick »

В openbsd не силён, но, возможно, pid-файл не удалился?
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
Аватара пользователя
Stauffenberg
Сообщения: 2042
Статус: ☮ PEACE ☮
ОС: открытая и свободная

Re: Станное поведение snmpd

Сообщение Stauffenberg »

Bizdelnick писал(а):
25.03.2015 18:59
В openbsd не силён, но, возможно, pid-файл не удалился?

Я не понимаю как так получается, что после запуска скрипта для snmpd, появляется сообщение о httpd2...
Labor omnia vincit

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” (Brian Kernighan)
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 20794
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: Станное поведение snmpd

Сообщение Bizdelnick »

А что в /etc/rc.d/rc.subr?
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
Аватара пользователя
Stauffenberg
Сообщения: 2042
Статус: ☮ PEACE ☮
ОС: открытая и свободная

Re: Станное поведение snmpd

Сообщение Stauffenberg »

Код: Выделить всё

# cat /etc/rc.d/rc.subr
#       $OpenBSD: rc.subr,v 1.58 2012/07/07 10:28:07 ajacoutot Exp $
#
# Copyright © 2010, 2011 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright © 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
# Copyright © 2010, 2011 Robert Nagy <robert@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


# Default functions and variables used by rc.d(8) scripts.

rc_err() {
        echo $1 1>&2
        exit 1
}

rc_usage() {
        rc_err "usage: $0 [-df] {start|check|reload|restart|stop}"
}

rc_write_runfile() {
        [ -d ${_RC_RUNDIR} ] || mkdir -p ${_RC_RUNDIR} && \
                print -rn -- "${pexp}" > ${_RC_RUNFILE}
}

rc_read_runfile() {
        local _new_pexp
        [ -f ${_RC_RUNFILE} ] && _new_pexp=$(< ${_RC_RUNFILE})
        [ -n "${_new_pexp}" ] && pexp="${_new_pexp}"
}

rc_rm_runfile() {
        [ -f ${_RC_RUNFILE} ] && rm -f ${_RC_RUNFILE}
}

rc_start() {
        ${rcexec} "${daemon} ${daemon_flags} ${_bg}"
}

rc_check() {
        pkill -0 -f "^${pexp}"
}

rc_reload() {
        pkill -HUP -f "^${pexp}"
}

rc_stop() {
        pkill -f "^${pexp}"
}

rc_do() {
        if [ -n "${_RC_DEBUG}" ]; then
                echo "doing $@" && "$@"
        else
                "$@" >/dev/null 2>&1
        fi
}

rc_exit() {
        [ -z "${INRC}" -o X"$1" != X"ok" ] && _pfix="($1)"
        echo ${INRC:+'-n'} "${_pfix}"
        [ X"$1" = X"ok" ] && exit 0 || exit 1
}

rc_wait() {
        local _i=0 _w=${2:-30}
        while [ $_i -lt $_w ]; do
                case "$1" in
                        reload|start)
                                rc_do rc_check && return 0
                                ;;
                        stop)
                                rc_do rc_check || return 0
                                ;;
                        *)
                                break
                                ;;
                esac
                sleep 1
                _i=$((_i+1))
        done
        return 1
}

rc_cmd() {
        local _bg _n

        if [ -z "${_RC_FORCE}" ] && [ X"${daemon_flags}" = X"NO" ]
        then
                if [ -n "${_RC_DEBUG}" ]
                then
                        rc_err "$0: no $1 without -f, ${_name}_flags=NO"
                fi
                exit 1
        fi

        eval _enotsup=\${rc_${1}}
        [ X"${_enotsup}" != X"NO" ] || rc_err "$0: $1 is not supported"

        [ X"${rc_bg}" = X"YES" ] && _bg="&"
        [ -n "${_RC_DEBUG}" ] || _n="-n"

        rc_do rc_read_runfile

        case "$1" in
        check)
                rc_do rc_check
                ;;
        start)
                [ -z "${INRC}" ] && rc_do rc_check && exit 0
                echo $_n "${INRC:+ }${_name}"
                while true; do  # no real loop, only needed to break
                        if type rc_pre >/dev/null; then
                                rc_do rc_pre || break
                        fi
                        # XXX only checks the status of the return code,
                        # and _not_ that the daemon is actually running
                        rc_do rc_start || break
                        if [ -n "${_bg}" ]; then
                                sleep 1
                                rc_do rc_wait start || break
                        fi
                        rc_do rc_write_runfile
                        rc_exit ok
                done
                # handle failure
                type rc_post >/dev/null && rc_do rc_post
                rc_do rc_rm_runfile
                rc_exit failed
                ;;
        stop)
                rc_do rc_check || exit 0
                echo $_n "${INRC:+ }${_name}"
                rc_do rc_stop || rc_exit failed
                rc_do rc_wait stop || rc_exit failed
                if type rc_post >/dev/null; then \
                        rc_do rc_post || rc_exit failed
                fi
                rc_do rc_rm_runfile
                rc_exit ok
                ;;
        reload)
                rc_do rc_check || exit 0
                echo $_n "${INRC:+ }${_name}"
                rc_do rc_reload || rc_exit failed
                rc_do rc_wait reload || rc_exit failed
                rc_exit ok
                ;;
        restart)
                /etc/rc.d/${_name} ${_RC_DEBUG} ${_RC_FORCE} stop &&
                        /etc/rc.d/${_name} ${_RC_DEBUG} ${_RC_FORCE} start
                ;;
        *)
                rc_usage
                ;;
        esac
}

[ $(id -u) -eq 0 ] || rc_err "$0: need root privileges"

[ -z "${local_rcconf}" ] && . /etc/rc.conf

[ -n "${daemon}" ] || rc_err "$0: daemon is not set"

unset _RC_DEBUG _RC_FORCE
while getopts "df" c; do
        case "$c" in
                d) _RC_DEBUG=-d;;
                f) _RC_FORCE=-f;;
                *) rc_usage;;
        esac
done
shift $((OPTIND-1))

_name=$(basename $0)
_RC_RUNDIR=/var/run/rc.d
_RC_RUNFILE=${_RC_RUNDIR}/${_name}

eval _rcflags=\${${_name}_flags}
eval _rcuser=\${${_name}_user}

getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && \
        daemon_class=${_name}

[ -z "${daemon_class}" ] && daemon_class=daemon
[ -z "${daemon_user}"  ] && daemon_user=root

[ -n "${_RC_FORCE}" ] && [ X"${_rcflags}" = X"NO" ] && unset _rcflags
[ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
[ -n "${_rcuser}"  ] && daemon_user=${_rcuser}

daemon_flags=$(printf ' %s' ${daemon_flags})
daemon_flags=${daemon_flags## }
pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
Labor omnia vincit

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” (Brian Kernighan)
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 20794
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: Станное поведение snmpd

Сообщение Bizdelnick »

Stauffenberg писал(а):
26.03.2015 19:45

Код: Выделить всё

. /etc/rc.conf

А там?
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
Ответить