Projet

Général

Profil

Révision bda87a37

IDbda87a3756d8e52850fbc1f641155c20575b01de
Parent 8e18199f
Enfant 9518ffa1

Ajouté par Tobias il y a presque 11 ans

Added multigraph capabilities and fixed regex

Voir les différences:

plugins/ups/apc_status
1 1
#!/bin/sh
2 2
#
3
# (c) Andreas Kreisl
3
# (c) Andreas Kreisl extended by Tobias Schramm
4 4
#
5 5
# Link name will be used as title: apc_{$title}
6 6
#
7 7
# env.keys LOADPCT BCHARGE LINEV BATTV TIMELEFT
8
# env.unit % or Volt or Minutes
9 8
#
10 9

  
11

  
12 10
if [ -z "$keys" ]; then
13
        keys="TIMELEFT"
11
        keys="LINEV LOADPCT BCHARGE NUMXFERS TIMELEFT"
14 12
fi
15 13

  
14
apcinfo=`/sbin/apcaccess`
15

  
16 16
if [ "$1" = "config" ]; then
17 17
        title=`basename $0 | sed 's/^apc_//g' | awk '{ sub(/^./,toupper(substr($0,1,1))); print; }'`
18
        echo "graph_title APC Status - $title"
19
        echo 'graph_args --base 1000 -l 0 '
20
        echo "graph_vlabel $unit"
21
        echo 'graph_category sensors'
18
        echo 'multigraph apc_status'
19
        echo "graph_title UPS Status - $title"
20
        echo 'graph_args --base 1000'
21
        echo 'graph_category hardware'
22 22
        title=`/sbin/apcaccess | egrep "^MODEL" | awk '{print $3" "$4" "$5" "$6" "$7" "$8" "$9;}'`
23 23
        echo "graph_info $title"
24 24
        for key in $keys; do
25 25
                echo "$key.label $key"
26
                echo "$key.info Value of $key."
27
                echo "$key.draw LINE2"
26
                echo "$key.info Value of $key"
27
                echo "$key.draw LINE1"
28
        done
29
        for key in $keys; do
30
                key_lower=`echo "$key" | awk '{print tolower($0);}'`
31
                unit=`echo "$apcinfo" | egrep "^$key" | awk '{print $4;}'`
32
                echo "multigraph apc_status.$key_lower"
33
                echo "graph_title $key"
34
                echo 'graph_args --base 1000'
35
                if [ -n "$unit" ]; then
36
                        echo "graph_vlabel $unit"
37
                fi
38
                echo 'graph_category hardware'
39
                echo "$key.label $key"
40
                echo "$key.info $key."
41
                echo "$key.draw LINE1"
28 42
        done
29 43
        exit 0
30 44
fi
31 45

  
32
searchkey=`echo "$keys" | tr " " "\|"`
33
/sbin/apcaccess | egrep "$searchkey" | awk '{print $1".value "$3;}'
46
echo 'multigraph apc_status'
47
for key in $keys; do
48
        echo "$apcinfo" | egrep "^$key" | awk '{print $1".value "$3;}'
49
done
50
for key in $keys; do
51
        key_lower=`echo "$key" | awk '{print tolower($0)}'`
52
        echo "multigraph apc_status.$key_lower"
53
        echo "$apcinfo" | egrep "^$key" | awk '{print $1".value "$3;}'
54
done
55

  

Formats disponibles : Unified diff