root / plugins / sensors / sequoia_websens @ ef960abc
Historique | Voir | Annoter | Télécharger (1,99 ko)
| 1 | 072743b5 | Mohammad Ali | #!/bin/sh |
|---|---|---|---|
| 2 | # |
||
| 3 | # Copyright (C) 2010 Mohammad ALI. All rights reserved. |
||
| 4 | # |
||
| 5 | # munin plugin that logs temperature and humidity from EM01b-STN (Sequoia Websensor) |
||
| 6 | # |
||
| 7 | # To install the plugin, copy or move the plugin to /usr/share/munin/plugins/ set |
||
| 8 | # the chmod to 755 and create a symbolic link: |
||
| 9 | # ln -s /usr/share/munin/plugins/sequoia_websens /etc/munin/plugins/sequoia_websens |
||
| 10 | # |
||
| 11 | # Configuration variables: |
||
| 12 | # |
||
| 13 | # host - host (default "localhost") |
||
| 14 | # port - port (default "80") |
||
| 15 | # |
||
| 16 | # If your environment has a average temperature which differs from the default |
||
| 17 | # waring and critical value than feel free to configure the warning and critical value |
||
| 18 | 96418fa5 | Kenyon Ralph | # |
| 19 | 072743b5 | Mohammad Ali | # |
| 20 | # Author |
||
| 21 | # Mohammad Ali |
||
| 22 | # |
||
| 23 | # Version 1.0 |
||
| 24 | # March 19, 2010 |
||
| 25 | 96418fa5 | Kenyon Ralph | # 01:17:14 PM |
| 26 | 072743b5 | Mohammad Ali | # |
| 27 | #%# family=auto |
||
| 28 | #%# capabilities=autoconf |
||
| 29 | |||
| 30 | # These variables are defined in /etc/munin/plugin-conf.d/munin-node |
||
| 31 | # Define the host (hostname or IP) and the port |
||
| 32 | host=${host:-localhost}
|
||
| 33 | port=${port:-80}
|
||
| 34 | |||
| 35 | # Configuration of Munin for graphs and fetching data |
||
| 36 | if [ "$1" = "config" ]; then |
||
| 37 | echo "graph_title Sequoia Websensor" |
||
| 38 | echo "graph_info This graph shows the temperature and humidity" |
||
| 39 | echo "graph_category sensor" |
||
| 40 | echo "graph_args -l 0 -u 100 -r" |
||
| 41 | echo "graph.scale no" |
||
| 42 | 96418fa5 | Kenyon Ralph | echo "graph_vlabel % and C°" |
| 43 | 072743b5 | Mohammad Ali | echo "tempsens.label Temperature" |
| 44 | echo "humsens.label Humidity" |
||
| 45 | echo "tempsens.warning 19:24" |
||
| 46 | echo "humsens.warning :50" |
||
| 47 | echo "tempsens.critical 18:25" |
||
| 48 | echo "humsens.critical :60" |
||
| 49 | exit 0 |
||
| 50 | 96418fa5 | Kenyon Ralph | fi |
| 51 | 072743b5 | Mohammad Ali | |
| 52 | # HTTP GET REQUEST to retrieve the data from the WebSensor |
||
| 53 | WEBSENS_DATA_FULL=$(printf "GET $host/index.html?em345678 HTTP/1.0 \n\n" | nc $host $port ) |
||
| 54 | |||
| 55 | # Selecting line of output (in this case body) |
||
| 56 | WEBSENS_DATA=$(echo "$WEBSENS_DATA_FULL" | grep body) |
||
| 57 | |||
| 58 | # Custom formatting for each type to trace only necessary |
||
| 59 | WEBSENS_TEMP=$(echo "$WEBSENS_DATA" | cut -d ' ' -f11 | cut -d 'H' -f1) |
||
| 60 | WEBSENS_HUM=$(echo "$WEBSENS_DATA" | cut -d ' ' -f11 | cut -d ':' -f2 | cut -d '%' -f1) |
||
| 61 | |||
| 62 | # Sending custom formatted data to munin to create the graphs |
||
| 63 | echo "tempsens.value $WEBSENS_TEMP" |
||
| 64 | 96418fa5 | Kenyon Ralph | echo "humsens.value $WEBSENS_HUM" |
