osm_db_lag 676 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bash
  2. # If you want munin monitoring then please copy this file to /etc/munin/plugins
  3. if [[ "$1" = "config" ]]; then
  4. {
  5. echo 'graph_title Lag to OSM main database'
  6. echo 'graph_vlabel seconds'
  7. echo "osm_db_lag.label osm_base"
  8. echo "osm_db_lag.warning 300"
  9. echo "osm_db_lag.critical 3600"
  10. exit 0
  11. }; fi
  12. DB_DATE=`cat /OVERPASS_DB_DIR/osm_base_version` # adapt directory
  13. CUR_DATE=`date -u +%T`
  14. DB_SECONDS=$((10#${DB_DATE:11:2}*3600 + 10#${DB_DATE:15:2}*60 + 10#${DB_DATE:19:2}))
  15. CUR_SECONDS=$((10#${CUR_DATE:0:2}*3600 + 10#${CUR_DATE:3:2}*60 + 10#${CUR_DATE:6:2}))
  16. LAG=$(( ( $CUR_SECONDS + 86400 - $DB_SECONDS ) % 86400 ))
  17. echo "osm_db_lag.value $LAG"