added support for system variables like sysLocation and for custom
scripts executed on SNMP read request. git-svn-id: svn://svn.openwrt.org/openwrt/packages@14414 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
4c9918c037
commit
f4db581ba1
@ -62,3 +62,17 @@ config access private_access
|
||||
option read all
|
||||
option write all
|
||||
option notify all
|
||||
|
||||
config system
|
||||
option sysLocaction 'office'
|
||||
option sysContact 'bofh@example.com'
|
||||
option sysName 'HeartOfGold'
|
||||
# option sysServices 72
|
||||
option sysDescr 'adult playground'
|
||||
# option sysObjectID '1.2.3.4'
|
||||
|
||||
config exec filedescriptors
|
||||
option prog /bin/cat
|
||||
option args /proc/sys/fs/file-nr
|
||||
# option miboid 1.2.3.4
|
||||
|
||||
|
@ -9,6 +9,21 @@ RUN_D=/var/run
|
||||
PID_F=$RUN_D/snmpd.pid
|
||||
RUN_C=$RUN_D/snmpd.conf
|
||||
|
||||
snmpd_system_add() {
|
||||
local cfg="$1"
|
||||
config_get syslocation "$cfg" sysLocation
|
||||
[ -n "$syslocation" ] && echo "sysLocation $syslocation" >> $RUN_C
|
||||
config_get syscontact "$cfg" sysContact
|
||||
[ -n "$syscontact" ] && echo "sysContact $syscontact" >> $RUN_C
|
||||
config_get sysname "$cfg" sysName
|
||||
[ -n "$sysname" ] && echo "sysName $sysname" >> $RUN_C
|
||||
config_get sysservice "$cfg" sysService
|
||||
[ -n "$sysservice" ] && echo "sysService $sysservice" >> $RUN_C
|
||||
config_get sysdescr "$cfg" sysDescr
|
||||
[ -n "$sysdescr" ] && echo "sysDescr $sysdescr" >> $RUN_C
|
||||
config_get sysobjectid "$cfg" sysObjectID
|
||||
[ -n "$sysobjectid" ] && echo "sysObjectID $sysobjectid" >> $RUN_C
|
||||
}
|
||||
snmpd_com2sec_add() {
|
||||
local cfg="$1"
|
||||
config_get secname "$cfg" secname
|
||||
@ -65,7 +80,7 @@ snmpd_access_add() {
|
||||
snmpd_pass_add() {
|
||||
local cfg="$1"
|
||||
local pass='pass'
|
||||
|
||||
|
||||
config_get miboid "$cfg" miboid
|
||||
[ -n "$miboid" ] || return 0
|
||||
config_get prog "$cfg" prog
|
||||
@ -76,19 +91,30 @@ snmpd_pass_add() {
|
||||
priority=${priority:+-p $priority}
|
||||
echo "$pass $priority $miboid $prog" >> $RUN_C
|
||||
}
|
||||
snmpd_exec_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get prog "$cfg" prog
|
||||
[ -n "$prog" ] || return 0
|
||||
config_get args "$cfg" args
|
||||
config_get miboid "$cfg" miboid
|
||||
echo "exec $cfg $miboid $prog $args" >> $RUN_C
|
||||
}
|
||||
start() {
|
||||
[ -d $LIB_D ] || mkdir -p $LIB_D
|
||||
[ -d $LOG_D ] || mkdir -p $LOG_D
|
||||
[ -d $RUN_D ] || mkdir -p $RUN_D
|
||||
[ -f $RUN_C ] && rm -f $RUN_C
|
||||
|
||||
|
||||
config_load snmpd
|
||||
|
||||
|
||||
config_foreach snmpd_system_add system
|
||||
config_foreach snmpd_com2sec_add com2sec
|
||||
config_foreach snmpd_group_add group
|
||||
config_foreach snmpd_view_add view
|
||||
config_foreach snmpd_access_add access
|
||||
config_foreach snmpd_pass_add pass
|
||||
config_foreach snmpd_exec_add exec
|
||||
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
$DEBUG /usr/sbin/snmpd $OPTIONS
|
||||
|
Loading…
x
Reference in New Issue
Block a user