Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snmp: script: add snmpd extend for counting security updates #435

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions snmp/securityupdate
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
################################################################
# copy this script to /etc/snmp/ and make it executable: #
# chmod +x /etc/snmp/securityupdate #
# ------------------------------------------------------------ #
# edit your snmpd.conf and include: #
# extend securityupdate /etc/snmp/securityupdate #
#--------------------------------------------------------------#
# restart snmpd and activate the app for desired host #
#--------------------------------------------------------------#
# please make sure you have the path/binaries below #
################################################################
BIN_WC='/usr/bin/env wc'
BIN_GREP='/usr/bin/env grep'
CMD_GREP='-c'
CMD_WC='-l'
BIN_APT='/usr/bin/env apt-get'
CMD_APT='-qq -s upgrade'

################################################################
# Don't change anything unless you know what are you doing #
################################################################
if command -v apt-get &>/dev/null ; then
# Debian / Devuan / Ubuntu
# shellcheck disable=SC2086
UPDATES=$($BIN_APT $CMD_APT | $BIN_GREP 'Inst' | $BIN_GREP $CMD_GREP '-security')
if [ "$UPDATES" -ge 1 ]; then
echo "$UPDATES";
else
echo "0";
fi
else
echo "0";
fi