Projet

Général

Profil

Révision 05d8c7c8

ID05d8c7c8089f17b2b7e7e032dd2f198c8f4308a4
Parent 3fab7aca
Enfant 1140fef1

Ajouté par @RubenKelevra il y a plus de 9 ans

add a servername to the graph to support multiple graphs per munin-node

Voir les différences:

plugins/rethinkdb/rethinkdb_node_io
1 1
#!/usr/bin/env python3
2 2
"""
3
  rethinkdb_node_io - A munin plugin for Linux to monitor the io count 
3
  rethinkdb_node_io - A munin plugin for Linux to monitor the io count
4 4
  per second on the local node
5 5

  
6 6
  This plugin is licensed under the AGPL 3.0 license
7 7

  
8 8
  AGPL 3.0 RubenKelevra
9 9
  Author: @RubenKelevra - <ruben@vfn-nrw.de>
10

10

  
11 11
  This plugin is written with the known limitation to a single instance per
12 12
  host. Patches which remove this limitation are very welcome.
13
  
14
  If your port / host is somewhat else than the default 
15
  localhost:28015, and/or your database-server differes in name from 
13

  
14
  If your port / host is somewhat else than the default
15
  localhost:28015, and/or your database-server differes in name from
16 16
  `hostname` (short hostname), you can add rethinkdb-node-io config vars
17 17
  like:
18 18
	  [rethinkdb_*]
......
35 35
from sys import exit as fatal_
36 36
from sys import stderr
37 37

  
38

  
38 39
# functions
39 40
def fatal(status):
40 41
    fatal_("ERROR: " + status)
......
64 65
        return e
65 66

  
66 67

  
67
def print_config():
68
    print("graph_title RethinkDB - Local Database IOPS and Queries")
68
def print_config(servername):
69
    print("graph_title RethinkDB on '%s'- Local Database IOPS and Queries" % servername)
69 70
    print("graph_args --base 1000 -l 0")
70 71
    print("graph_vlabel Operations / second")
71 72
    print("graph_category rethinkdb")
72 73
    print("total_qps.label queries per sec")
73 74
    print("total_qps.type COUNTER")
74 75
    print("total_rdps.label read docs per sec")
75
    print("total_rdps.type COUNTER")  
76
    print("total_rdps.type COUNTER")
76 77
    print("total_wdps.label written docs per sec")
77
    print("total_wdps.type COUNTER")  
78
    print("total_wdps.type COUNTER")
78 79
    exit(0)
79 80

  
80 81

  
......
86 87

  
87 88

  
88 89
if __name__ == '__main__':
90
    try:
91
        RETHINKDB_SERVERNAME = env['rethinkdb_servername']
92
    except:
93
        RETHINKDB_SERVERNAME = gethostname()
94

  
89 95
    if len(argv) > 2:
90 96
        fatal("unsupported argument count")
91 97
    elif len(argv) == 2:
92 98
        if str(argv[1]) == "config":
93
            print_config()
99
            print_config(RETHINKDB_SERVERNAME)
94 100
        elif str(argv[1]) == "autoconf":
95 101
            if check_autoconf():
96 102
                print("yes")
......
119 125
        RETHINKDB_HOST = "localhost"
120 126

  
121 127
    try:
122
        RETHINKDB_SERVERNAME = env['rethinkdb_servername']
123
    except:
124
        RETHINKDB_SERVERNAME = gethostname()
125

  
126
    try:
127 128
        conn = connect(RETHINKDB_HOST, RETHINKDB_PORT)
128 129
    except:
129 130
        fatal("connection attempt to the rethinkdb-host \"%s\" via port \"%s\" failed" % (

Formats disponibles : Unified diff