Projet

Général

Profil

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

root / plugins / openstack_swift / openstack_swift_stats_ @ 099d7821

Historique | Voir | Annoter | Télécharger (1,61 ko)

1
#!/bin/bash
2

    
3
ME="${0##*/}"
4
CONTAINER=$(printf "%s" "$ME" | cut -d'_' -f4 -)
5
# printf "$CONTAINER\n"
6

    
7
case $1 in
8
   config)
9
        cat <<EOM
10
multigraph openstack_swift_stats_size
11
graph_title Swift container size ($CONTAINER)
12
graph_category cloud
13
graph_vlabel bytes
14
graph_args --base=1024 -l 0
15
graph_period hour
16
size.label Size
17
size.type GAUGE
18
size.draw AREA
19
size.min 0
20
growth.label Growth/\${graph_period}
21
growth.type DERIVE
22
growth.min 0
23

    
24
multigraph openstack_swift_stats_objects
25
graph_title Swift container object count ($CONTAINER)
26
graph_category cloud
27
graph_vlabel 
28
graph_args --base=1000 -l 0
29
graph_period hour
30
objects.label Objects
31
objects.type GAUGE
32
objects.draw AREA
33
objects.min 0
34
objgrowth.label Growth/\${graph_period}
35
objgrowth.type DERIVE
36
objgrowth.min 0
37
EOM
38
        exit 0;;
39
esac
40

    
41
IFS=" "
42
STAT_OUTPUT=( $(swift stat "$CONTAINER" | awk 'NR>=3&&NR<=4 {print $2}' FS=": " ORS=" ") )
43

    
44
# Size graph
45
printf "multigraph openstack_swift_stats_size\n"
46

    
47
# Check value is an integer.
48
if [ -z "${STAT_OUTPUT[1]}" ] || [ "${STAT_OUTPUT[1]}" != "${STAT_OUTPUT[1]}" ] 2>/dev/null; then
49
    printf "size.value 0\n"
50
    printf "Error: no usable size value from swift command.\n" 1>&2
51
    exit 1
52
fi
53

    
54
printf "size.value %s\ngrowth.value %s\n" "${STAT_OUTPUT[1]}" "${STAT_OUTPUT[1]}"
55

    
56
# Objects graph
57
printf "multigraph openstack_swift_stats_objects\n"
58

    
59
if [ -z "${STAT_OUTPUT[0]}" ] || [ "${STAT_OUTPUT[0]}" != "${STAT_OUTPUT[0]}" ] 2>/dev/null; then
60
    printf "objects.value 0\n"
61
    printf "Error: no usable objects value from swift command.\n" 1>&2
62
    exit 1
63
fi
64

    
65
printf "objects.value %s\nobjgrowth.value %s\n" "${STAT_OUTPUT[0]}" "${STAT_OUTPUT[0]}"
66

    
67