Add steps for dhcp and unbound extends
This commit is contained in:
80
seqs/snmp.sh
80
seqs/snmp.sh
@@ -391,6 +391,86 @@ step_40() {
|
||||
exe service snmpd restart
|
||||
}
|
||||
distroExtendLoc="${toolConfigLoc}/distro"
|
||||
|
||||
|
||||
step_42_info() {
|
||||
echo "Gather dhcp information from a dhcpd lease file"
|
||||
echoinfo "pi-hole lease file not supported"
|
||||
}
|
||||
step_42_alias() { ALIAS="dhcp"; }
|
||||
step_42() {
|
||||
local locExtName="dhcpstats"
|
||||
local locExtUrl="https://github.com/librenms/librenms-agent/raw/master/snmp/dhcp.py"
|
||||
local locExtLoc="${toolConfigLoc}/dhcp.py"
|
||||
|
||||
checkExtend $locExtName
|
||||
[ $? -ne 0 ] && return 0
|
||||
|
||||
exe apt install dhcpd-pools
|
||||
endReturn -o $? "Install dhcpd-pools failed"
|
||||
|
||||
exe wget $locExtUrl -O "${locExtLoc}"
|
||||
endReturn -o $? "Download $locExtName script failed"
|
||||
exe chmod +x "$locExtLoc"
|
||||
|
||||
echoseq " [I] Create extend for $locExtName"
|
||||
addConf -a "extend $locExtName ${locExtLoc}" "$toolConfig"
|
||||
|
||||
echoseq " [I] Create config for $locExtName"
|
||||
addConf -s "$dhcpExtendConfig" "$dhcpExtendConfigLoc"
|
||||
|
||||
echo " [W] Adapt config $dhcpExtendConfigLoc manually and restart snmpd"
|
||||
}
|
||||
dhcpExtendConfigLoc="${toolConfigLoc}/dhcp.json"
|
||||
dhcpExtendConfig="{\"leasefile\": \"/var/lib/dhcp/dhcpd.leases\"
|
||||
}"
|
||||
|
||||
step_44_info() {
|
||||
echo "Extend unbound stats"
|
||||
}
|
||||
step_44_alias() { ALIAS="unbound"; }
|
||||
step_44() {
|
||||
local locExtName="unbound"
|
||||
local locExtUrl="https://github.com/librenms/librenms-agent/raw/master/snmp/unbound"
|
||||
local locExtLoc="${toolConfigLoc}/unbound"
|
||||
|
||||
checkExtend $locExtName
|
||||
[ $? -ne 0 ] && return 0
|
||||
|
||||
exe wget $locExtUrl -O "${locExtLoc}"
|
||||
endReturn -o $? "Download $locExtName script failed"
|
||||
exe chmod +x "$locExtLoc"
|
||||
|
||||
echoseq " [I] Create extend for $locExtName"
|
||||
addConf -a "extend /usr/bin/sudo $locExtName ${locExtLoc}" "$toolConfig"
|
||||
|
||||
echoseq " [I] Create config for $locExtName"
|
||||
addConf -s "$unboundExtendConfig" "$unboundExtendConfigLoc"
|
||||
|
||||
exe systemctl restart unbound.service
|
||||
exe systemctl restart snmpd.service
|
||||
}
|
||||
unboundExtendConfigLoc="/etc/unbound/unbound.conf.d/extended-stats.conf"
|
||||
unboundExtendConfig=$(cat <<UB_EOF
|
||||
# Enable extended statistics
|
||||
server:
|
||||
extended-statistics: yes
|
||||
statistics-cumulative: yes
|
||||
|
||||
remote-control:
|
||||
control-enable: yes
|
||||
control-interface: 127.0.0.1
|
||||
UB_EOF
|
||||
)
|
||||
|
||||
step_45_info() { echo "Set sudoers file to execute unbount-control"; }
|
||||
step_45() {
|
||||
addConf -s "$unboundSudoer" "$unboundSudoerLoc"
|
||||
}
|
||||
unboundSudoerLoc="/etc/sudoers.d/snmpunbound"
|
||||
unboundSudoer="Debian-snmp ALL=(ALL) NOPASSWD: /usr/sbin/unbound-control, ${toolConfigLoc}/unbound"
|
||||
|
||||
|
||||
checkExtend() {
|
||||
# adding dry run output for clarification
|
||||
if [ $DRY -ne 0 ] ; then
|
||||
|
Reference in New Issue
Block a user