-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrrd-monitor.sh
executable file
·53 lines (33 loc) · 1.3 KB
/
rrd-monitor.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
##Author Sean Mancini
##Purpose This script will monitor a RRD file to ensure it is being updated to ensure graphing is working
#Version 1.0
#/bin/bash
##User settings
path_to_rrd="rrd_file_to_monitor"
logging_file="path_to_log"
enable_email="" # enter Y to enable
email_address=""
##Get details from rrdtool
rrd_update="$(rrdtool lastupdate $path_to_rrd | awk '{print$1}' | grep -o '[0-9]\+')"
sleep 30
rrd_lastupdate="$(rrdtool lastupdate $path_to_rrd | awk '{print$1}' | grep -o '[0-9]\+')"
if [[ "$rrd_update" = "$rrd_lastupdate" ]]
then
i=1
echo "equal"
else
i=0
fi
##Logging messeges
if [ $i == 1 ]
then
#echo "Graphs are not updating" $('date') >> $logging_file
echo $('date') "WARNING: Graphs are not updating" >> $logging_file ##Uncomment this line to showup nicely in cacti log
else
#echo "Graphs are updating" $('date') >> $logging_file
echo $('date') "SYSTEM STATS: Graphs are updating" >> $logging_file ##Uncomment this line to showup nicely in cacti log
fi
###Email alarm to admin (requires ssmtp)
if [ $i == 1 ] && [ $enable_email == "y" ]
then (echo "Subject: !!!Cacti Graphing Alert!!!"; echo "From: "email" "; echo "To: Me <$email_address>"; echo ""; echo "Graphs are not updating") | /usr/sbin/ssmtp -vv $email_address
fi