#!/bin/bash MONDIR=/var/lib/mon #resolution of modify times is only 2 second on some filesystems, so prevent race conditions by touching it now and sleeping 2 seconds touch $MONDIR/.send-time echo "Sleeping..." sleep 2 #traveled back in time? (e.g. systemclock is adjusted) if [ $MONDIR/.send-time -ot $MONDIR/send-latest ]; then #remove it (this triggers a send) rm $MONDIR/send-latest fi #Find all facility states that have changed since last succesfull send cd $MONDIR/alerts for FACILITY in *; do #NOTE: msg-modifytime only changes if something actually changed, while state-modifytime always changes when syn3-state is called. if [ $FACILITY/msg -nt $MONDIR/send-latest ]; then echo "Facility $FACILITY has changed since last send." cd /usr/webint/htdocs/monitoring/ php cli.php --send_all_states || exit 1 mv $MONDIR/.send-time $MONDIR/send-latest echo "Status succesfully uploaded to SYN-3 monitoring system" exit 0 fi done echo "No changes found"