root / plugins / mongodb / mongo_conn @ c6f88968
Historique | Voir | Annoter | Télécharger (1,1 ko)
| 1 | 276169a6 | Alban | #!/usr/bin/env python |
|---|---|---|---|
| 2 | """ |
||
| 3 | =head1 NAME |
||
| 4 | c6f88968 | Lars Kruse | |
| 5 | mongo_conn - MongoDB connections Plugin |
||
| 6 | 9045f18d | Eliot Horowitz | |
| 7 | 276169a6 | Alban | =head1 APPLICABLE SYSTEMS |
| 8 | |||
| 9 | c6f88968 | Lars Kruse | Works until MongoDB 3.6. The httpinterface was later removed. |
| 10 | 276169a6 | Alban | |
| 11 | =head1 CONFIGURATION |
||
| 12 | |||
| 13 | [mongo_lock] |
||
| 14 | env.MONGO_DB_URI mongodb://user:password@host:port/dbname |
||
| 15 | |||
| 16 | =head1 AUTHOR |
||
| 17 | |||
| 18 | c6f88968 | Lars Kruse | Original script there : https://github.com/comerford/mongo-munin |
| 19 | |||
| 20 | Doc added by Alban Espie-Guillon <alban.espie@alterway.fr> |
||
| 21 | |||
| 22 | =cut |
||
| 23 | 276169a6 | Alban | """ |
| 24 | 9045f18d | Eliot Horowitz | |
| 25 | import urllib2 |
||
| 26 | import sys |
||
| 27 | |||
| 28 | try: |
||
| 29 | import json |
||
| 30 | except ImportError: |
||
| 31 | import simplejson as json |
||
| 32 | |||
| 33 | |||
| 34 | def getServerStatus(): |
||
| 35 | raw = urllib2.urlopen( "http://127.0.0.1:28017/_status" ).read() |
||
| 36 | return json.loads( raw )["serverStatus"] |
||
| 37 | |||
| 38 | name = "connections" |
||
| 39 | |||
| 40 | |||
| 41 | def doData(): |
||
| 42 | print name + ".value " + str( getServerStatus()["connections"]["current"] ) |
||
| 43 | |||
| 44 | def doConfig(): |
||
| 45 | |||
| 46 | print "graph_title MongoDB current connections" |
||
| 47 | print "graph_args --base 1000 -l 0" |
||
| 48 | print "graph_vlabel connections" |
||
| 49 | 99542938 | dipohl | print "graph_category db" |
| 50 | 9045f18d | Eliot Horowitz | |
| 51 | print name + ".label " + name |
||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | if __name__ == "__main__": |
||
| 59 | if len(sys.argv) > 1 and sys.argv[1] == "config": |
||
| 60 | doConfig() |
||
| 61 | else: |
||
| 62 | doData() |
