Debian Codegraph @

utils/munin/replication_delay

raw
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 # Copyright (c) 2007 - 2023 by mod_tile contributors (see AUTHORS file)
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; If not, see http://www.gnu.org/licenses/.
24
25 if [ "$1" = "config" ]; then
26
27 echo 'graph_title Data import lag'
28 echo 'graph_args --base 1000 -l 0'
29 echo 'graph_vlabel minutes'
30 echo 'graph_category renderd'
31 echo 'age.label DB import age'
32 echo 'age.type GAUGE'
33 echo 'age.cdef age,60,/'
34 exit 0
35 fi
36
37 tstamp=$(sed -e '/^timestamp=/!d' -e 's/.*=//' -e 's/Z//' -e 's/T/Z/' -e 's/\\\\//' -e 's/\\\\//' -e q ${REPLICATION_STATE:-/home/osm/replicate/state.txt})
38 tstampsec=$(date --date=$tstamp +%s)
39 nowsec=$(date +%s)
40
41 echo "age.value " $(expr $nowsec - $tstampsec)