Commit 59e08897 authored by Adam Wujek's avatar Adam Wujek 💬

rootfs: add log destination option for SNMPD to dot-config

Update Kconfig
Update user-manual
Update snmpd's init script
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent f6c3965b
...@@ -97,6 +97,18 @@ config WRS_LOG_PTP ...@@ -97,6 +97,18 @@ config WRS_LOG_PTP
to represent no logging (like /dev/null). Please note that to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch. unknown facility names will generate a runtime error on the switch.
config WRS_LOG_SNMPD
string "Logging directions for the SNMP daemon"
default "sd"
help
The string can be a pathname (e.g. /dev/kmsg) or a valid snmpd log
option (without -L). "sd" or "s daemon" will forward messages to
syslog with daemon as facility. To set level (i.e. 5) use
"S 5 daemon". For details please check "man snmpcmd". An empty
strings is used to represent no logging (like /dev/null). Please
note that unknown facility names will generate a runtime error on the
switch.
config KEEP_ROOTFS config KEEP_ROOTFS
bool "Keep generated filesystem and related script" bool "Keep generated filesystem and related script"
help help
......
...@@ -472,7 +472,7 @@ value is changed by the web interface, proper action is taken. ...@@ -472,7 +472,7 @@ value is changed by the web interface, proper action is taken.
Supply Right (PSR) temperature sensors. When any temperature exceeds Supply Right (PSR) temperature sensors. When any temperature exceeds
threshold level SNMP object @t{WR-SWITCH-MIB::tempWarning} will change threshold level SNMP object @t{WR-SWITCH-MIB::tempWarning} will change
accordingly. accordingly.
@item CONFIG_WRS_LOG_HAL @item CONFIG_WRS_LOG_HAL
@itemx CONFIG_WRS_LOG_RTU @itemx CONFIG_WRS_LOG_RTU
@itemx CONFIG_WRS_LOG_PTP @itemx CONFIG_WRS_LOG_PTP
...@@ -485,6 +485,20 @@ value is changed by the web interface, proper action is taken. ...@@ -485,6 +485,20 @@ value is changed by the web interface, proper action is taken.
unknown facility names will generate a runtime error on the switch. unknown facility names will generate a runtime error on the switch.
All three strings default to ``@t{daemon.info}''. All three strings default to ``@t{daemon.info}''.
@item CONFIG_WRS_LOG_SNMPD
Value can be a pathname, to select logging to file (and
@t{/dev/kmsg} is a possible ``file'' target) or a valid snmpd log
option (without -L).
Allowed strings are in format ``@t{s} @i{facility}'' (e.g.
``@t{s daemon}'') and ``@t{s} @i{level} @i{facility}'' (e.g.
``@t{s 2 daemon}''). For example, ``@t{sd}'' or ``@t{s daemon}'' will forward
messages to syslog with daemon as facility. To set level (i.e. 5) use
``@t{S 5 daemon}''. For details please check ``man snmpcmd''. An empty
strings selects no logging at all. Please note that unknown facility
names will generate a runtime error on the switch.
@item CONFIG_PORT00_PARAMS @item CONFIG_PORT00_PARAMS
@itemx CONFIG_PORT01_PARAMS @itemx CONFIG_PORT01_PARAMS
@itemx ... @itemx ...
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
SNMP_PID=/var/run/snmpd.pid SNMP_PID=/var/run/snmpd.pid
SNMP_CONF=/wr/etc/snmpd.conf SNMP_CONF=/wr/etc/snmpd.conf
dotconfig=/wr/etc/dot-config
start_counter() { start_counter() {
# increase boot counter # increase boot counter
...@@ -17,9 +18,29 @@ start_counter() { ...@@ -17,9 +18,29 @@ start_counter() {
start() { start() {
echo -n "Starting snmpd daemon: " echo -n "Starting snmpd daemon: "
# Log to syslog at daemon level. And log source address (-a)
if [ -f "$dotconfig" ]; then
. "$dotconfig"
else
echo "$0 unable to source dot-config ($dotconfig)!"
fi
WRS_LOG=$CONFIG_WRS_LOG_SNMPD
if [ -z "$WRS_LOG" ]; then
LOG="";
elif echo "$WRS_LOG" | grep / > /dev/null; then
# if a pathname, use it
LOG="-Lf $WRS_LOG";
else
# not a pathname: use verbatim
LOG="-L$WRS_LOG"
fi
# Log source address (-a)
start-stop-daemon -q -p $SNMP_PID -S \ start-stop-daemon -q -p $SNMP_PID -S \
--exec /usr/sbin/snmpd -- -Lsd -p $SNMP_PID -a -c $SNMP_CONF --exec /usr/sbin/snmpd -- $LOG -p $SNMP_PID -a -c $SNMP_CONF
ret=$? ret=$?
if [ $ret -eq 0 ]; then if [ $ret -eq 0 ]; then
start_counter start_counter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment