Created
December 12, 2011 08:42
-
-
Save sts/1465973 to your computer and use it in GitHub Desktop.
CheckMK Apt Check Agent Plugin v0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -e /etc/debian_version && `which apt-get` ]] &>/dev/null ; then | |
cache_time_ref=/var/cache/apt/pkgcache.bin | |
delta=0 | |
# Only try to manually update the cache, if cron-apt is not installed. | |
if [[ `dpkg-query -W -f='${Status}\n' cron-apt` != "install ok installed" ]] &>/dev/null ; then | |
now=`date +%s` | |
mtime=`stat -c %Y $cache_time_ref` | |
delta=$((now - mtime)) | |
if [[ $delta -gt 3600 ]] ; then | |
waitmax 120 apt-get update &>/dev/null | |
delta=0 | |
fi | |
fi | |
echo "<<<apt>>>" | |
echo $delta | |
cat /etc/debian_version | |
waitmax 25 apt-get -s dist-upgrade -y | awk '/^Inst/ { print $2 " " $5}' || echo "timeout_apt_get Debian-Security:X.X/DUMMY)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment