Alexandros Kosiaris has submitted this change and it was merged. Change subject: add monitoring for Ubuntu mirror being in sync ......................................................................
add monitoring for Ubuntu mirror being in sync see RT #3793 for an issue in 2012 when this was not updated and went unnoticed for a long time Matanya added a script that i slightly fixed in I4d6e47ed7776a This commit replaces that script entirely with a much better version that has no fetching stuff for remote urls and as such is more secure This is a slightly modified version of the script found in: https://wiki.ubuntu.com/Mirrors/Monitoring%20Scripts moving that around to run via NRPE and adding it to installserver module, Ubuntu mirror class Change-Id: I6024b3b57906ba0b023a94ba1375be71174a6e72 --- D files/icinga/check_apt_mirror M manifests/role/install-server.pp A modules/install-server/files/check_apt_mirror M modules/install-server/manifests/ubuntu-mirror.pp 4 files changed, 52 insertions(+), 30 deletions(-) Approvals: Alexandros Kosiaris: Looks good to me, approved jenkins-bot: Verified diff --git a/files/icinga/check_apt_mirror b/files/icinga/check_apt_mirror deleted file mode 100755 index 67360b4..0000000 --- a/files/icinga/check_apt_mirror +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Plugin to check if ubuntu mirror is up to date with upstream -# by Matanya Moses ([email protected]) -# -########################################################## -hostname=$(hostname) -upstreamdate=$(curl -s https://launchpad.net/ubuntu/+mirror/ubuntu.wikimedia.org-archive |grep UTC| cut -f2 -d'"') -t1=$(date --date="$upstreamdate" +%s) - -dt2=$(date +%Y-%m-%d\ %H:%M:%S) -t2=$(date --date="$dt2" +%s) - -let "tDiff=$t2-$t1" - -let "dDiff=$tDiff/86400" - -if [ "$dDiff" -le "2" ]; then - echo "OK: Ubuntu mirror sync on $hostname is $dDiff days behind upstream" - exit 0 - elif [ "$dDiff" -gt "2" ]; then - echo "Critical: Ubuntu mirror sync on $hostname is $dDiff days behind upstream" - exit 2 - else - echo "Unknown" - exit 3 -fi - diff --git a/manifests/role/install-server.pp b/manifests/role/install-server.pp index 2036e27..43e37aa 100644 --- a/manifests/role/install-server.pp +++ b/manifests/role/install-server.pp @@ -33,10 +33,15 @@ include base::firewall include backup::host - include install-server::ubuntu-mirror include install-server::apt-repository include install-server::preseed-server + include install-server::ubuntu-mirror + nrpe::monitor_service {'check_apt_mirror': + description => 'Ubuntu mirror in sync with upstream', + nrpe_command => '/usr/local/lib/nagios/plugins/check_apt_mirror' + } + include install-server::tftp-server ferm::rule { 'tftp': rule => 'proto udp dport tftp { saddr $ALL_NETWORKS ACCEPT; }' diff --git a/modules/install-server/files/check_apt_mirror b/modules/install-server/files/check_apt_mirror new file mode 100755 index 0000000..de81912 --- /dev/null +++ b/modules/install-server/files/check_apt_mirror @@ -0,0 +1,36 @@ +#!/bin/sh + +. /usr/lib/nagios/plugins/utils.sh + +# Where the archive is. +TO=/srv/ubuntu +HOSTNAME=$(hostname -f) +STAMP=${TO}/project/trace/${HOSTNAME} +WARN=6 +CRITICAL=12 + +while [ $# -gt 0 ] +do + case "$1" in + -c|--critical) CRITICAL=$2; shift; shift;; + -w|--warn) WARN=$2; shift; shift;; + --) shift; break;; + -*) echo "You lost me at '$1'"; exit 1;; + *) STAMP=$1; shift; break;; + esac +done + +HOUR=3600 #seconds +NOW=$(date +%s) # Unix time +STAMPAGE=$(( $NOW - $(stat -c %Y ${STAMP}) )) +STAMPHOURS=$(( $STAMPAGE / $HOUR )) + +echo "$STAMP is over $STAMPHOURS hours old." + +if [ $STAMPHOURS -lt $WARN ]; then + exit $STATE_OK +elif [ $STAMPHOURS -lt $CRITICAL ]; then + exit $STATE_WARNING +else + exit $STATE_CRITICAL +fi diff --git a/modules/install-server/manifests/ubuntu-mirror.pp b/modules/install-server/manifests/ubuntu-mirror.pp index fc8d72a..ea2532b 100644 --- a/modules/install-server/manifests/ubuntu-mirror.pp +++ b/modules/install-server/manifests/ubuntu-mirror.pp @@ -39,5 +39,14 @@ minute => '43', require => File['/usr/local/sbin/update-ubuntu-mirror'], } -} + # monitoring for Ubuntu mirror being + # in sync with upstream (RT #3793) + file { '/usr/local/lib/nagios/plugins/check_apt_mirror': + ensure => 'present', + owner => 'root', + group => 'root', + mode => '0555', + source => 'puppet:///modules/install-server/check_apt_mirror'; + } +} -- To view, visit https://gerrit.wikimedia.org/r/125956 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6024b3b57906ba0b023a94ba1375be71174a6e72 Gerrit-PatchSet: 5 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Dzahn <[email protected]> Gerrit-Reviewer: Alexandros Kosiaris <[email protected]> Gerrit-Reviewer: Andrew Bogott <[email protected]> Gerrit-Reviewer: ArielGlenn <[email protected]> Gerrit-Reviewer: Dzahn <[email protected]> Gerrit-Reviewer: Gage <[email protected]> Gerrit-Reviewer: Matanya <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
