Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / cm2 @ 7e562477

Historique | Voir | Annoter | Télécharger (2,21 ko)

1 fed6c275 Tom Yates
#!/bin/bash
2
3
#
4
# (c) Tom Yates / Gatekeeper Technology Ltd. 2008
5
#  with thanks to ipaccess.com who paid for this to be
6
#  written, and permitted its redistribution under GPL (v3)
7
8
# plugin must be linked as climate_FQDN_VAR, where FQDN is that
9
#  of climate server and VAR is the variable (temp, rh, air, light, sound)
10
#  you wish to retrieve
11
# eg climate_mycm2.foo.com_temp
12
13
# HOST is the hostname of the climate server, must be in /etc/hosts
14
HOST=`basename $0 | cut -f2 -d_`
15
16
# VAR is variable to grab (temp, rh, air, light, sound)
17
VAR=`basename $0 | cut -f3 -d_`
18
19
# it will retrieve and make available five data,
20
#  temp (Temperature), rh (relative humidity), air (Air Flow), light
21
#  (Light Level) and sound (Sound Level)
22
23
24
# CONFIG
25
case $1 in
26
   config)
27
echo host_name $HOST
28
case $VAR in
29
  temp)
30
    echo graph_title Temperature 
31
    echo graph_vlabel degrees C
32
    echo temp.notify_alias Temperature
33
    echo temp.warning 26
34
    echo temp.critical 31
35
    echo "temp.label Temperature (degrees C)" ;;
36
  rh)
37
    echo graph_title Relative Humidity 
38
    echo graph_vlabel per cent
39
    echo rh.notify_alias Relative Humidity
40
    echo "rh.label Relative Humidity (%)" ;;
41
  air)
42
    echo graph_title Airflow 
43
    echo air.notify_alias Airflow
44
    echo air.label Airflow ;;
45
  light)
46
    echo graph_title Light level 
47
    echo light.notify_alias Light Level
48
    echo light.label Light level ;;
49
  sound)
50
    echo graph_title Sound level 
51
    echo sound.notify_alias Sound Level
52
    echo sound.label Sound Level ;;
53
esac
54
echo  graph_category Other
55
exit 0;;
56
57
esac
58
59
60
61
# FETCH
62
case $VAR in
63
  temp)
64
VALUE=`lynx --source http://${HOST}/ | grep -A 1 "Temperature" | tail -1 | \
65
 sed 's/[^0-9.]//g' `
66
echo temp.value $VALUE ;;
67
68
  rh)
69
VALUE=`lynx --source http://${HOST}/ | grep -A 1 "Relative Humidity" | \
70
 tail -1 | sed 's/[^0-9.]//g' `
71
echo rh.value $VALUE ;;
72
73
  air)
74
VALUE=`lynx --source http://${HOST}/ | grep -A 1 "Air Flow" | tail -1 | \
75
 sed 's/[^0-9.]//g' `
76
echo air.value $VALUE ;;
77
78
  light)
79
VALUE=`lynx --source http://${HOST}/ | grep -A 1 "Light Level" | tail -1 | \
80
 sed 's/[^0-9.]//g' `
81
echo light.value $VALUE ;;
82
83
  sound)
84
VALUE=`lynx --source http://${HOST}/ | grep -A 1 "Sound Level" | tail -1 | \
85
 sed 's/[^0-9.]//g' `
86
echo sound.value $VALUE ;;
87
88
esac
89