Projet

Général

Profil

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

root / plugins / glassfish / glassfish_counters_ @ 2580942b

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

1
#!/bin/bash
2
# -*- sh -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
glassfish_counters_ - Wildcard-plugin to monitor counters in GlassFish
9

    
10
=head1 CONFIGURATION
11

    
12
This plugin does need the full path to the asadmin script:
13
  [glassfish_counters_*]
14
        env.ASADMIN /usr/local/glassfish/bin/asadmin
15

    
16
This is a wildcard plugin. To monitor an subtree, link
17
glassfish_counters_<subtree> to this file. E.g.
18

    
19
  ln -s /usr/share/munin/plugins/glassfish_counters_ \
20
        /etc/munin/plugins/glassfish_counters_server.web.request
21

    
22
...will monitor server.web.request.*
23

    
24
To ignore certain counters, just add more "IGNORE" lines on top of
25
the awk script. (XXX: Fixme for env.)
26

    
27
=head1 AUTHOR
28
Philipp Buehler
29

    
30
=head1 LICENSE
31

    
32
BSD 2-clause
33

    
34
=head1 VERSION
35

    
36
  $Id: glassfish_counters_.in$
37
  0.0.1
38

    
39
=cut
40
[ -z $ASADMIN ] && {
41
        echo "ASADMIN not set in node configuration"
42
        exit 1
43
        } || MUN_AS_ADMIN=${ASADMIN}
44

    
45
check_link () {
46
        scriptname=${0##*/}
47
        myself=${scriptname##*_}
48
        if [ "x$myself" = "x" ] ; then
49
                echo "plugin must be symlinked, e.g. to glassfish_counters_server.web.request"
50
                exit 1
51
        fi
52
}
53

    
54
SUBTREE=${0##*glassfish_counters_}
55

    
56
case $1 in
57
    suggest)
58
                echo "not implemented"
59
                exit 0
60
        ;;
61
    config)
62
                check_link
63
                $MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \
64
                awk 'BEGIN{ FS="[ = ]"}
65
                        /requestcount/ { next; } # IGNORE
66
                        /dotted-name/ { myself = $NF
67
                                print "graph_title GlassFish", myself
68
                                print "graph_vlabel count"
69
                                print "graph_category glassfish"
70
                                print "graph_info this shows available counters from", myself
71
                                next
72
                                }
73
                        /-name / { nwhat = split($1, what, ".")
74
                                gsub(/-name/, "", what[nwhat])
75
                                print what[nwhat] ".label " $NF
76
                                print what[nwhat] ".type GAUGE"
77
                                }
78
                        /-description / { nwhat = split($1, what, ".")
79
                                gsub(/-description/, "", what[nwhat])
80
                                $1 = ""; line = $0
81
                                gsub(/^   /,"", line)
82
                                print what[nwhat] ".info " line
83
                                }
84
                '
85
                exit 0
86
        ;;
87
esac
88

    
89
check_link
90
$MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \
91
awk 'BEGIN{ FS="[ = ]" }
92
        /requestcount/ { next;} # IGNORE
93
        /-count / { nwhat = split($1, what, ".")
94
                gsub(/-count/, "", what[nwhat])
95
                print what[nwhat] ".value=" $NF}
96
'