Projet

Général

Profil

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

root / plugins / swift / swift-async_ @ d112f623

Historique | Voir | Annoter | Télécharger (1,51 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 object async pending %s" % swift_server
38
        print "graph_category swift"
39
        print "async_pending.type GAUGE"
40
        print "async_pending.label Async pending"
41
        print "async_pending.draw AREA"
42
    sys.exit(0)
43
except IndexError:
44
    pass
45

    
46
async_r = requests.get("http://%s:%d/recon/async" \
47
                           % (swift_server, os.getenv("SWIFT_OBJECT_PORT", 6000)))
48
print "async_pending.value %d" % json.loads(async_r.text)['async_pending']