]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/replication_delay
f6cd317a92faeb00a72e06ab38cce6cac377e740
[chef.git] / cookbooks / munin / files / default / plugins / replication_delay
1 #!/bin/sh
2 #
3 # Plugin to monitor the age of the imported data in the rendering db
4 #
5 # Parameters:
6 #
7 #       config   (required)
8 #       autoconf (optional - used by munin-config)
9 #
10
11 if [ "$1" = "config" ]; then
12
13         echo 'graph_title Data import lag'
14         echo 'graph_args --base 1000 -l 0'
15         echo 'graph_vlabel minutes'
16         echo 'graph_category renderd'
17         echo 'age.label DB import age'
18         echo 'age.type GAUGE'
19         echo 'age.cdef age,60,/'
20         echo 'age.warning :600'
21         echo 'age.critical :3600'
22         exit 0
23 fi
24
25 latest_changes=$(ls /var/lib/replicate/changes-*.osc.gz | sort --version-sort | tail -1)
26 tstamp=$(osmium fileinfo --extended --get=data.timestamp.last ${latest_changes})
27 tstampsec=$(date --date=${tstamp} +%s)
28 nowsec=$(date +%s)
29
30 echo "age.value " `expr $nowsec - $tstampsec`