forked from bezibaerchen/prtgscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-apt.sh
16 lines (10 loc) · 868 Bytes
/
check-apt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## Please check GitHub repository for updates to that script: https://github.com/bezibaerchen/prtgscripts
## Script to monitor available updates via PRTG
#!/bin/bash
numberofupdates=`apt-get update >/dev/null 2>&1 && apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "PROGRAM: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | wc -l`
if [ "$numberofupdates" == "0" ]; then
listofupdates="None"
else
listofupdates=`apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "$1: $2 --> $3\n"}'`
fi
echo -e "<prtg>\n<result>\n<channel>Available updates</channel>\n<value>$numberofupdates</value>\n<unit>Count</unit>\n</result>\n<text>$listofupdates</text>\n</prtg>"