Projet

Général

Profil

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

root / plugins / sge / sge_queue_ @ 17f78427

Historique | Voir | Annoter | Télécharger (3,33 ko)

1
#!/bin/bash
2
#
3
# Wildcard-plugin to monitor Sun Grid Engine queue state.
4
# To monitor a queue, link sge_queue_<queue> to this file. E.g.
5
#
6
#   ln -s /usr/share/munin/plugins/sge_queue_ /etc/munin/plugins/sge_queue_all.q
7
#
8
# Based on the condor_queue_ plugin by Šarūnas Burdulis.
9
#
10
# Runs 'qstat -g c' for the specified queue and gets the number of
11
# used, reserved, unavailable and free queue slots.
12
# Free slots are defined as available slots minus reserved slots.
13
# Unavailable slots have queue states Disabled/Suspended/Error/Ambiguous config/Unknown
14
#
15
# Parameters understood:
16
#
17
#   config   (required)
18
#   autoconf (optional - used by munin-config)
19
#   suggest  (optional - used by munin-config)
20
#
21
# Configurable variables:
22
#
23
#   env.sge_settings - Path to SGE settings.sh script, defaults to /opt/sge/default/common/settings.sh
24
#   env.title        - Graph title, overrides "SGE Queue state".
25
#   env.options      - Additional command line options to qstat.
26
#
27
# Revisions:
28
#   v1.0 2009-07-19
29
#
30
# Magic markers
31
#%# family=contrib
32
#%# capabilities=autoconf suggest
33

    
34
# env.sge_settings -- alternatively you can just modify the path below
35
if [ ! -z "$sge_settings" ]; then
36
    SGE_SETTINGS="$sge_settings"
37
else
38
    SGE_SETTINGS=/opt/sge/default/common/settings.sh
39
fi
40

    
41
# queue name in symlink
42
QUEUE=`basename $0 | sed 's/^sge_queue_//g'`
43
if [ -z "$QUEUE" ]; then
44
    QUEUE="all.q"
45
fi
46

    
47
# env.title
48
if [ ! -z "$title" ]; then
49
    GRAPHTITLE="$title"
50
else
51
    GRAPHTITLE="SGE Queue state (${QUEUE})"
52
fi
53

    
54
if [ "$1" = "config" ]; then
55
    echo "graph_title "$GRAPHTITLE""
56
    echo "graph_order used reserved unavailable free"
57
    echo "graph_args --lower-limit 0 "
58
    echo "graph_vlabel Queue slots"
59
    echo "graph_scale no"
60
    echo "graph_info Shows global Sun Grid Engine queue state."
61
    echo "graph_category htc"
62
    echo "graph_period minute"
63
    echo "used.label Used"
64
    echo "used.draw AREA"
65
    echo "used.type GAUGE"
66
    echo "used.info Currently used slots."
67
    echo "unavailable.label Unavailable"
68
    echo "unavailable.draw STACK"
69
    echo "unavailable.type GAUGE"
70
    echo "unavailable.info Queue state Disabled/Suspended/Error/Ambiguous config/Unknown."
71
    echo "reserved.label Reserved"
72
    echo "reserved.draw STACK"
73
    echo "reserved.type GAUGE"
74
    echo "reserved.info Reserved slots."
75
    echo "free.label Free"
76
    echo "free.draw STACK"
77
    echo "free.type GAUGE"
78
    echo "free.info Free slots."
79
    exit 0
80
fi
81

    
82
# source settings script, needed for qstat
83
if [ -f "$SGE_SETTINGS" ]; then
84
    source "$SGE_SETTINGS"
85
fi
86

    
87
if [ "$1" = "suggest" ]; then
88
    qstat -g c | tail -n +3 | cut -d ' ' -f 1
89
    exit 0
90
fi
91

    
92
if [ "$1" = "autoconf" ]; then
93
    if which qstat > /dev/null; then
94
        echo "yes"
95
        exit 0
96
    else
97
        echo "no"
98
        exit 1
99
    fi
100
fi
101

    
102
# env.options
103
OPTIONS="-g c -q $QUEUE $options"
104

    
105
# qstat -g c example output:
106
# CLUSTER QUEUE                   CQLOAD   USED    RES  AVAIL  TOTAL aoACDS  cdsuE
107
# --------------------------------------------------------------------------------
108
# all.q                             0.00     16      8     48     64      0      0
109
qstat $OPTIONS | tail -n 1 | awk '{print "unavailable.value " $8 "\nreserved.value " $4 "\nused.value " $3 "\nfree.value " $5-$4}'
110

    
111
# for SGE 6.1 or earlier use this:
112
# qstat $OPTIONS | tail -n 1 | awk '{print "unavailable.value " $7 "\nreserved.value 0"  "\nused.value " $3 "\nfree.value " $4}'