File: apc_envunit_.in

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (78 lines) | stat: -rwxr-xr-x 1,837 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# Plugin to monitor APC environmental units (temperature/humidity)
#
# Usage: Copy or link into /etc/munin/node.d/
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#
# Config variables:
#
#       units     - DNS names of environmental units
#       oid       - OID Prefix for humidity probes
#       community - Community to use to access the APC unit
#

#
# Configuration for temperature or humidity probes 
#

type=`echo $0 | sed -e 's/.*_\(.*\)/\1/'`
if [ "${type}" = temperature ] ; then
  TOID="enterprises.318.1.1.10.3.13.1.1.3"
  NAME="temperature"
  LABEL="Celsius Degrees"
  LETTER="t"
else
  if [ "${type}" = humidity ] ; then
   TOID="enterprises.318.1.1.10.3.13.1.1.6"
   NAME="humidity"
   LABEL="Humidity %"
   LETTER="h"
  else 
    exit 1
  fi
fi

UNITS=""
COMMUNITY="public"
SNMPGET=`which snmpget`

if [ "$units" ]; then UNITS=$units ; fi
if [ "$oid" ]; then TOID=$oid ; fi
if [ "$community" ]; then COMMUNITY=$community ; fi

UNITS="rg20-sonde b105-sonde"
COMMUNITY="zorglub"
SNMPOPTS="-Ov -Oq -v1 -c ${COMMUNITY}"

if [ "$1" = "autoconf" ]; then
  if [ -z "${UNITS}" -o -z "${SNMPGET}" ] ; then echo "no" ; exit 1 ; fi
  for m in ${UNITS} ; do
    if ping -c1 -q $m  >/dev/null 2>&1 ; then continue ; fi
    echo "no" ; exit 1
  done
  echo "yes" ; exit 0
fi

if [ "$1" = "config" ]; then
  echo "graph_title Environmental units (${NAME} probes)"
  echo "graph_vlabel ${LABEL}"
  for m in ${UNITS} ; do
    mm=`echo ${m} | tr '-' '_'`
    echo "${mm}_${LETTER}1.label $m ${NAME} #1"
    echo "${mm}_${LETTER}2.label $m ${NAME} #2"
  done
  exit 0
fi

for m in ${UNITS} ; do
  v1=`${SNMPGET} ${SNMPOPTS} $m ${TOID}.1`
  v2=`${SNMPGET} ${SNMPOPTS} $m ${TOID}.2`
  mm=`echo ${m} | tr '-' '_'`
  echo "${mm}_${LETTER}1.value $v1"
  echo "${mm}_${LETTER}2.value $v2"
done