snmp/rc.snmp

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
parent 325
6601d28cfe52
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

     1 #!@l_prefix@/bin/openpkg rc
     2 ##
     3 ##  rc.snmp -- Run-Commands
     4 ##
     6 %config
     7     snmp_enable="$openpkg_rc_def"
     8     snmp_daemons="snmpd snmptrapd"
     9     snmp_listen="127.0.0.1"
    10     snmp_listentrap="127.0.0.1"
    11     snmp_log_prolog="true"
    12     snmp_log_epilog="true"
    13     snmp_log_numfiles="10"
    14     snmp_log_minsize="1M"
    15     snmp_log_complevel="9"
    17 %common
    18     snmp_pidfile_snmptrapd="@l_prefix@/var/snmp/snmptrapd.pid"
    19     snmp_pidfile_snmpd="@l_prefix@/var/snmp/snmpd.pid"
    20     snmp_signal () {
    21         [ -f $snmp_pidfile_snmptrapd ] \
    22             && kill -$1 `cat $snmp_pidfile_snmptrapd`
    23         local rc_snmptrapd=$?
    24         [ -f $snmp_pidfile_snmpd ] \
    25             && kill -$1 `cat $snmp_pidfile_snmpd`
    26         local rc_snmpd=$?
    27         [ $rc_snmptrapd -eq 0 -o $rc_snmpd -eq 0 ]
    28     }
    30 %status -u @l_susr@ -o
    31     snmp_usable="no"
    32     snmp_active="no"
    33     rcService snmp enable yes && \
    34         snmp_usable="yes"
    35     rcService snmp enable yes && \
    36         snmp_signal 0 && snmp_active="yes"
    37     echo "snmp_enable=\"$snmp_enable\""
    38     echo "snmp_usable=\"$snmp_usable\""
    39     echo "snmp_active=\"$snmp_active\""
    41 %start -u @l_susr@
    42     rcService snmp enable yes || exit 0
    43     rcService snmp active yes && exit 0
    44     for daemon in $snmp_daemons; do
    45         case "$daemon" in
    46             snmpd     ) @l_prefix@/sbin/snmpd     -p $snmp_pidfile_snmpd -Lsd $snmp_listen ;;
    47             snmptrapd ) @l_prefix@/sbin/snmptrapd -p $snmp_pidfile_snmptrapd -Lsd $snmp_listentrap ;;
    48         esac
    49     done
    51 %stop -u @l_susr@
    52     rcService snmp enable yes || exit 0
    53     rcService snmp active no  && exit 0
    54     snmp_signal TERM
    56 %restart -u @l_susr@
    57     rcService snmp enable yes || exit 0
    58     rcService snmp active no  && exit 0
    59     rc snmp stop
    60     sleep 2
    61     rc snmp start
    63 %daily -u @l_susr@
    64     rcService snmp enable yes || exit 0
    65     shtool rotate -f \
    66         -n ${snmp_log_numfiles} -s ${snmp_log_minsize} -d \
    67         -z ${snmp_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
    68         -P "${snmp_log_prolog}" \
    69         -E "${snmp_log_epilog}" \
    70         @l_prefix@/var/snmp/snmp.log

mercurial