Skip to content

Instantly share code, notes, and snippets.

@sts
Created December 12, 2011 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sts/1465973 to your computer and use it in GitHub Desktop.
Save sts/1465973 to your computer and use it in GitHub Desktop.
CheckMK Apt Check Agent Plugin v0.1
#!/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