Projet

Général

Profil

Révision 30779549

ID307795493a64e4317e2ad173699806e2610dcb2f
Parent 5c983dbc
Enfant cf44597b

Ajouté par cortices il y a presque 5 ans

Add openstack_swift_stats_ plugin

Voir les différences:

plugins/openstack_swift/openstack_swift_stats_
1
#!/bin/bash
2

  
3
ME="${0##*/}"
4
CONTAINER=$(printf "$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
[ -n "${STAT_OUTPUT[1]}" ] && [ "${STAT_OUTPUT[1]}" -eq "${STAT_OUTPUT[1]}" ] 2>/dev/null
49
if [ $? -ne 0 ]; then
50
    printf "size.value 0\n"
51
    printf "Error: no usable size value from swift command.\n" 1>&2
52
    exit 1
53
fi
54

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

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

  
60
[ -n "${STAT_OUTPUT[0]}" ] && [ "${STAT_OUTPUT[0]}" -eq "${STAT_OUTPUT[0]}" ] 2>/dev/null
61
if [ $? -ne 0 ]; then
62
    printf "objects.value 0\n"
63
    printf "Error: no usable objects value from swift command.\n" 1>&2
64
    exit 1
65
fi
66

  
67
printf "objects.value ${STAT_OUTPUT[0]}\nobjgrowth.value ${STAT_OUTPUT[0]}\n"
68

  
69

  
plugins/openstack_swift/openstack_swift_stats_.pod
1
=cut
2

  
3
=head1 NAME
4

  
5
openstack_swift_stats_ -- Plugin to monitor size of OpenStack Swift containers
6

  
7
=head1 ABOUT
8

  
9
Multigraph plugin. Graphs the following statistics about an OpenStack Swift container:
10
- Size in bytes
11
- Growth in size per graph period (hour by default)
12

  
13
- Number of objects
14
- Growth in objects per graph period (hour by default)
15

  
16
=head1 CONFIGURATION
17

  
18
Configuration values are mandatory. Names are identical to the environment values used by the Swift commands and passed directly to it.
19
They can be copied from the openrc.sh file provided by your OpenStack hosting provider, along with the password.
20

  
21
OS_AUTH_URL
22
OS_IDENTITY_API_VERSION
23
OS_REGION_NAME
24
OS_USER_DOMAIN_NAME
25
OS_PROJECT_DOMAIN_NAME
26
OS_TENANT_ID
27
OS_TENANT_NAME
28
OS_USERNAME
29
OS_PASSWORD
30

  
31
Configuration example for OVH:
32

  
33
[openstack_swift_size_*]
34
  env.OS_AUTH_URL https://auth.cloud.ovh.net/v3/
35
  env.OS_IDENTITY_API_VERSION 3
36
  env.OS_REGION_NAME SYD
37
  env.OS_USER_DOMAIN_NAME Default
38
  env.OS_PROJECT_DOMAIN_NAME Default
39
  
40
  env.OS_TENANT_ID {{Redacted}}
41
  env.OS_TENANT_NAME {{Redacted}}
42
  env.OS_USERNAME user-{{Redacted}}
43
  env.OS_PASSWORD {{Redacted}}
44

  
45
=head1 USAGE
46
 
47
- Place the plugin in your plugins storage directory (/usr/share/munin/plugins)
48
- Symlink it into the active plugins directory (/etc/munin/plugins) with the name of your container after the last underscore
49
  (e.g. ln -s /usr/share/munin/plugins/openstack_swift_stats_ /etc/munin/plugins/openstack_swift_stats_mycontainer)
50
- Copy the OpenStack login environment variables from the openrc.sh file provided by your hosting provider to your plugin config file as shown in the configuration section.
51
- Add the OS_PASSWORD value for the chosen user.
52

  
53
=head1 AUTHOR
54

  
55
Copyright (C) 2020 Sophie Parker (dev@cortices.me)
56

  
57
=head1 LICENSE
58

  
59
This program is free software; you can redistribute it and/or
60
modify it under the terms of the GNU General Public License
61
as published by the Free Software Foundation; version 2 dated June,
62
1991.
63

  
64
This program is distributed in the hope that it will be useful,
65
but WITHOUT ANY WARRANTY; without even the implied warranty of
66
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
67
GNU General Public License for more details.
68

  
69
You should have received a copy of the GNU General Public License
70
along with this program; if not, write to the Free Software
71
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
72

  
73
=head1 MAGIC MARKERS
74

  
75
#%# family=manual
76

  
77
=cut

Formats disponibles : Unified diff