root / plugins / smstools / smstools_ @ 17f78427
Historique | Voir | Annoter | Télécharger (3,83 ko)
| 1 | 79d779d4 | Andreas Thienemann | #!/bin/bash |
|---|---|---|---|
| 2 | |||
| 3 | # Copyright (C) 2009 Andreas Thienemann <andreas@bawue.net> |
||
| 4 | # |
||
| 5 | # This program is free software; you can redistribute it and/or modify |
||
| 6 | # it under the terms of the GNU Library General Public License as published by |
||
| 7 | # the Free Software Foundation; version 2 only |
||
| 8 | # |
||
| 9 | # This program is distributed in the hope that it will be useful, |
||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | # GNU Library General Public License for more details. |
||
| 13 | # |
||
| 14 | # You should have received a copy of the GNU Library General Public License |
||
| 15 | # along with this program; if not, write to the Free Software |
||
| 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 17 | # |
||
| 18 | |||
| 19 | 17f78427 | Lars Kruse | # |
| 20 | 79d779d4 | Andreas Thienemann | # Plugin to monitor an smstools installation |
| 21 | # |
||
| 22 | # Usage: Link or copy into the munin-node plugin directory, name it according |
||
| 23 | # to your SMS Modem as known to smsd. e.g. smstools_GSM1 |
||
| 24 | # |
||
| 25 | # |
||
| 26 | # Installation: |
||
| 27 | # |
||
| 28 | # SMSD: |
||
| 29 | # Configure smsd to output his statistics by adding the following to /etc/smsd.conf: |
||
| 30 | # |
||
| 31 | # stats = /var/log/smsd_stats |
||
| 32 | # stats_interval = 300 |
||
| 33 | # |
||
| 34 | # |
||
| 35 | # Munin: |
||
| 36 | # If your statistics directory is non-standard, configure it as |
||
| 37 | # statsdir in the munin-plugin configuration |
||
| 38 | # In case you do not want your statistics-dump from smsd deleted after reading, |
||
| 39 | # set env.cleanup to false. If you want cleanup to work, run the plugin as root. |
||
| 40 | # |
||
| 41 | # [smstools*] |
||
| 42 | # user root |
||
| 43 | # env.statsdir /var/log/smsd_stats |
||
| 44 | # env.cleanup true |
||
| 45 | # |
||
| 46 | # |
||
| 47 | # Magic markers (optional - only used by munin-config and some |
||
| 48 | # installation scripts): |
||
| 49 | # |
||
| 50 | #%# family=contrib |
||
| 51 | #%# capabilities=autoconf suggest |
||
| 52 | # |
||
| 53 | |||
| 54 | STATSDIR=${statsdir:-/var/log/smsd_stats}
|
||
| 55 | CLEANUP=${cleanup:-false}
|
||
| 56 | MODEM=`basename $0 | sed 's/^smstools_//g'` |
||
| 57 | |||
| 58 | if [ "$1" = "autoconf" ]; then |
||
| 59 | if [ -d $STATSDIR ]; then |
||
| 60 | echo yes |
||
| 61 | exit 0 |
||
| 62 | else |
||
| 63 | echo "no ($STATSDIR not found)" |
||
| 64 | exit 1 |
||
| 65 | fi |
||
| 66 | fi |
||
| 67 | |||
| 68 | if [ "$1" = "suggest" ]; then |
||
| 69 | if [ -d $STATSDIR ]; then |
||
| 70 | # Find the newest statistics file |
||
| 71 | FILE=$(ls -rt ${STATSDIR}/[0-9]*.[0-9]* | tail -n 1)
|
||
| 72 | |||
| 73 | awk ' |
||
| 74 | FS="," {
|
||
| 75 | if (NR > 4) {
|
||
| 76 | print $1 |
||
| 77 | } |
||
| 78 | } |
||
| 79 | ' < $FILE |
||
| 80 | exit 0 |
||
| 81 | else |
||
| 82 | exit 1 |
||
| 83 | fi |
||
| 84 | fi |
||
| 85 | |||
| 86 | |||
| 87 | # If run with the "config"-parameter, give out information on how the |
||
| 88 | 17f78427 | Lars Kruse | # graphs should look. |
| 89 | |||
| 90 | 79d779d4 | Andreas Thienemann | if [ "$1" = "config" ]; then |
| 91 | echo 'graph_title SMSTools Report for '${MODEM}
|
||
| 92 | echo 'graph_args --base 1000 -l 0' |
||
| 93 | echo 'graph_vlabel ' |
||
| 94 | echo 'graph_scale no' |
||
| 95 | 34eeebbe | Lars Kruse | echo 'graph_category chat' |
| 96 | 79d779d4 | Andreas Thienemann | echo 'graph_info SMSTools Statistics' |
| 97 | echo 'graph_oder succeeded received failed multiple_failed rejected' |
||
| 98 | echo 'rejected.label Rejected' |
||
| 99 | echo 'rejected.info Number of rejected SMS' |
||
| 100 | echo 'succeeded.label Succeeded' |
||
| 101 | fba800ae | Veres Lajos | echo 'succeeded.info Number of successfully sent SMS' |
| 102 | 79d779d4 | Andreas Thienemann | echo 'failed.label Failed' |
| 103 | echo 'failed.info Number of failed SMS' |
||
| 104 | echo 'received.label Received' |
||
| 105 | echo 'received.info Number of received SMS' |
||
| 106 | echo 'multiple_failed.label Consecutive failures' |
||
| 107 | echo 'multiple_failed.info Number of consecutive failures' |
||
| 108 | # echo 'usage_s.label Time sent' |
||
| 109 | # echo 'usage_s.info Modem time sending' |
||
| 110 | # echo 'usage_r.label Time sent' |
||
| 111 | # echo 'usage_r.info Modem time receiving' |
||
| 112 | |||
| 113 | # Last, if run with the "config"-parameter, quit here (don't |
||
| 114 | # display any data) |
||
| 115 | exit 0 |
||
| 116 | fi |
||
| 117 | |||
| 118 | # Find the newest statistics file |
||
| 119 | FILE=$(ls -rt ${STATSDIR}/[0-9]*.[0-9]* | tail -n 1)
|
||
| 120 | |||
| 121 | awk ' |
||
| 122 | FS="," {
|
||
| 123 | if (NR == 2) |
||
| 124 | a[0] = "rejected.value " $2 |
||
| 125 | |||
| 126 | if (NR > 4 && $1 == "'$MODEM'") {
|
||
| 127 | a[1] = "succeeded.value " $2 |
||
| 128 | a[2] = "failed.value " $3 |
||
| 129 | a[3] = "received.value " $4 |
||
| 130 | a[4] = "multiple_failed.value " $5 |
||
| 131 | a[5] = "usage_s.value " $6 |
||
| 132 | a[6] = "usage_r.value " $7 |
||
| 133 | } |
||
| 134 | |||
| 135 | # Did we actually get more then just the rejected.value line? |
||
| 136 | # Then we must have parsed the right modem, output everything |
||
| 137 | if (1 in a) {
|
||
| 138 | for (i = 0; i < 7; i++) {
|
||
| 139 | print a[i] |
||
| 140 | } |
||
| 141 | } |
||
| 142 | } |
||
| 143 | ' < $FILE |
||
| 144 | |||
| 145 | if [ ${CLEANUP} == "true" ]; then
|
||
| 146 | rm -f $FILE |
||
| 147 | fi |
