Skip to content

Commit a09b569

Browse files
committed
snmp: script: add snmpd extend for counting security updates
alongside the total osupdate counting
1 parent 539a10d commit a09b569

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

snmp/securityupdate

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
################################################################
3+
# copy this script to /etc/snmp/ and make it executable: #
4+
# chmod +x /etc/snmp/securityupdate #
5+
# ------------------------------------------------------------ #
6+
# edit your snmpd.conf and include: #
7+
# extend securityupdate /etc/snmp/securityupdate #
8+
#--------------------------------------------------------------#
9+
# restart snmpd and activate the app for desired host #
10+
#--------------------------------------------------------------#
11+
# please make sure you have the path/binaries below #
12+
################################################################
13+
BIN_WC='/usr/bin/env wc'
14+
BIN_GREP='/usr/bin/env grep'
15+
CMD_GREP='-c'
16+
CMD_WC='-l'
17+
BIN_APT='/usr/bin/env apt-get'
18+
CMD_APT='-qq -s upgrade'
19+
20+
################################################################
21+
# Don't change anything unless you know what are you doing #
22+
################################################################
23+
if command -v apt-get &>/dev/null ; then
24+
# Debian / Devuan / Ubuntu
25+
# shellcheck disable=SC2086
26+
UPDATES=$($BIN_APT $CMD_APT | $BIN_GREP 'Inst' | $BIN_GREP $CMD_GREP '-security')
27+
if [ "$UPDATES" -ge 1 ]; then
28+
echo "$UPDATES";
29+
else
30+
echo "0";
31+
fi
32+
else
33+
echo "0";
34+
fi

0 commit comments

Comments
 (0)