root / plugins / postgresql / slony_lag_events_ @ 17f78427
Historique | Voir | Annoter | Télécharger (2,59 ko)
| 1 | c1ab8e31 | radar@aol.pl | #!/bin/bash |
|---|---|---|---|
| 2 | # |
||
| 3 | # plugin to monitor difference between st_last_event and st_last_received |
||
| 4 | # in sl_status table (based on slony_ and slony_lag_) |
||
| 5 | # |
||
| 6 | # http://blog.endpoint.com/2009/07/slony-slstatus-and-diagnosing.html |
||
| 7 | # |
||
| 8 | # st_origin: the local slony system |
||
| 9 | # st_received: the slony instance that sent an event |
||
| 10 | # st_last_event: the sequence number of the last event received from that origin/received pair |
||
| 11 | # st_last_event_ts: the timestamp on the last event received |
||
| 12 | # st_last_received: the sequence number of the last sl_event + sl_confirm pair received |
||
| 13 | # st_last_received_ts: the timestamp on the sl_confirm in that pair |
||
| 14 | # st_last_received_event_ts: the timestamp on the sl_event in that pair |
||
| 15 | # st_lag_num_events: difference between st_last_event and st_last_received |
||
| 16 | # st_lag_time: difference between st_last_event_ts and st_last_received_ts |
||
| 17 | 17f78427 | Lars Kruse | # |
| 18 | c1ab8e31 | radar@aol.pl | # |
| 19 | # Configuration variables: |
||
| 20 | # |
||
| 21 | # PGHOST - Database server to use. |
||
| 22 | # PGUSER - User to connect as. |
||
| 23 | # PGPASSWORD - Password to use. |
||
| 24 | # PGSCHEMA - Replication schema. |
||
| 25 | # |
||
| 26 | # Configuration example: |
||
| 27 | # |
||
| 28 | # munin-node: |
||
| 29 | # |
||
| 30 | # [slony*] |
||
| 31 | # user slony |
||
| 32 | # env.PGHOST localhost |
||
| 33 | # env.PGUSER slony |
||
| 34 | # env.PGPASSWORD password |
||
| 35 | # env.PGSCHEMA _slony |
||
| 36 | # |
||
| 37 | # postgresql.conf: |
||
| 38 | # |
||
| 39 | # standard_conforming_strings = on |
||
| 40 | # |
||
| 41 | # ln -s /usr/share/munin/plugins/slony_lag_events_/etc/munin/plugins/slony_lag_events_PGDATABASE |
||
| 42 | # |
||
| 43 | # |
||
| 44 | # Magic markers (optional - only used by munin-config and some installation scripts): |
||
| 45 | #%# family=contrib |
||
| 46 | |||
| 47 | |||
| 48 | PGDATABASE=$(basename $0 | sed 's/^slony_lag_events_//g') |
||
| 49 | |||
| 50 | if [ "$1" = "config" ]; then |
||
| 51 | echo "graph_args --base 1000 -l 0" |
||
| 52 | 30685b4c | dipohl | echo "graph_category db" |
| 53 | c1ab8e31 | radar@aol.pl | echo "graph_info Slony st_lag_num_events for ${PGDATABASE}"
|
| 54 | echo "graph_title Slony lag events for ${PGDATABASE}"
|
||
| 55 | echo 'graph_vlabel event' |
||
| 56 | |||
| 57 | 17f78427 | Lars Kruse | psql -h ${PGHOST} -d ${PGDATABASE} -U ${PGUSER} -tc "SELECT no_id,regexp_replace(pa_conninfo, '.*host=(.*?) .*$', '\\1') FROM ${PGSCHEMA}.sl_node JOIN ${PGSCHEMA}.sl_path ON (pa_server=no_id) WHERE pa_client=${PGSCHEMA}.getlocalnodeid('${PGSCHEMA}'::name);" | while read node_id sep host
|
| 58 | c1ab8e31 | radar@aol.pl | do |
| 59 | test -z "${node_id}" && continue
|
||
| 60 | echo "${node_id}.label ${host}"
|
||
| 61 | echo "${node_id}.type GAUGE"
|
||
| 62 | echo "${node_id}.draw LINE2"
|
||
| 63 | echo "${node_id}.info difference between st_last_event and st_last_received"
|
||
| 64 | echo "${node_id}.warning 150"
|
||
| 65 | echo "${node_id}.critical 200"
|
||
| 66 | done |
||
| 67 | exit 0 |
||
| 68 | fi |
||
| 69 | |||
| 70 | psql -h ${PGHOST} -d ${PGDATABASE} -U ${PGUSER} -tc "SELECT st_received, st_lag_num_events FROM ${PGSCHEMA}.sl_status ORDER BY 1;" | while read node_id sep event
|
||
| 71 | 17f78427 | Lars Kruse | do |
| 72 | c1ab8e31 | radar@aol.pl | test -z "${node_id}" && continue
|
| 73 | echo "${node_id}.value ${event}"
|
||
| 74 | done |
