Projet

Général

Profil

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

root / plugins / swift / swift-quarantined_ @ c5ab6538

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

1
#!/usr/bin/env python
2
# -*- encoding: utf-8 -*-
3
#
4
# Swift monitoring script for munin
5
#
6
# Copyright © 2012 eNovance <licensing@enovance.com>
7
#
8
# Author: Julien Danjou <julien@danjou.info>
9
#
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
14
#
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
#
23

    
24
import sys
25
import json
26
import os
27
import requests
28

    
29
try:
30
    swift_server = sys.argv[0].split("_", 1)[1]
31
except:
32
    print "E: Cannot find server name using script name"
33
    sys.exit(1)
34

    
35
try:
36
    if sys.argv[1] == 'config':
37
        print "graph_title Swift objects quarantined %s" % swift_server
38
        print "graph_category swift"
39
        print "quarantined_objects.type GAUGE"
40
        print "quarantined_objects.draw AREA"
41
        print "quarantined_objects.label Quarantined objects"
42
        print "quarantined_containers.type GAUGE"
43
        print "quarantined_containers.area STACK"
44
        print "quarantined_containers.label Quarantined containers"
45
        print "quarantined_accounts.type GAUGE"
46
        print "quarantined_accounts.draw STACK"
47
        print "quarantined_accounts.label Quarantined accounts"
48
    sys.exit(0)
49
except IndexError:
50
    pass
51

    
52
quarantined = json.loads(requests.get("http://%s:%d/recon/quarantined" \
53
                                          % (swift_server, os.getenv("SWIFT_OBJECT_PORT", 6000))).text)
54
print "quarantined_objects.value %d" % quarantined['objects']
55
print "quarantined_containers.value %d" % quarantined['containers']
56
print "quarantined_accounts.value %d" % quarantined['accounts']