mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-08-03 14:48:22 +00:00
Cater for newer OS dependencies - python and ceph updates
system default python is now usually python3 - better make our code compliant with it `ceph` CLI itself has some slightly different usage and outputs jq used instead of cut in a few places, because was easier to work out what the original commands were intending to grab, now that those outputs have moved location. Yes, jq is a new dependency for some of the plugins, but it was already implicitly depended upon in ceph_osd plugin
This commit is contained in:
parent
9c17efc39b
commit
5b1300aebf
3 changed files with 25 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
: << =cut
|
||||
|
@ -96,9 +96,10 @@ def read_osd(filename):
|
|||
try:
|
||||
s=socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
|
||||
s.connect(filename)
|
||||
s.send("{\"prefix\": \"perf dump\"}\0")
|
||||
s.send(b'{"prefix": "perf dump"}\0')
|
||||
result=s.recv(102400)
|
||||
result=result[4:]
|
||||
result=result.decode('utf-8')
|
||||
return json.loads(result)
|
||||
except:
|
||||
pass
|
||||
|
@ -134,7 +135,7 @@ osds.sort()
|
|||
for key in osds:
|
||||
data[key]=collapse_one(data[key])
|
||||
|
||||
graphlist=[item[1].keys() for item in data.items()]+settings_graph.keys()
|
||||
graphlist=[item[1].keys() for item in data.items()]+list(settings_graph.keys())
|
||||
graphlist=list(set(itertools.chain(*graphlist)))
|
||||
|
||||
if (sys.argv.__len__()>1) and (sys.argv[1]=="config"):
|
||||
|
@ -149,26 +150,26 @@ if (sys.argv.__len__()>1) and (sys.argv[1]=="config"):
|
|||
gr_pretty=graph.replace("_"," ").title()
|
||||
gr=graph.replace("-","_").replace(":","_")
|
||||
graphdefaults={"graph_title":gr_pretty,"graph_vlabel":gr_pretty,"graph_category":"fs"}
|
||||
graphsettings=dict(graphdefaults.items()+graphsettings.items())
|
||||
print "multigraph %s" % (gr_simple)
|
||||
print "\n".join(["%s %s" % setting for setting in graphsettings.items()])
|
||||
graphsettings=dict(list(graphdefaults.items())+list(graphsettings.items()))
|
||||
print ("multigraph %s" % (gr_simple))
|
||||
print ("\n".join(["%s %s" % setting for setting in graphsettings.items()]))
|
||||
for osd in sortlist(data.keys()):
|
||||
print "osd%s_%s.label osd %s" % (osd,gr_simple,osd)
|
||||
print ("osd%s_%s.label osd %s" % (osd,gr_simple,osd))
|
||||
if subgraphs:
|
||||
for osd in sortlist(data.keys()):
|
||||
print "multigraph %s.osd%s" % (gr_simple,osd)
|
||||
thisrecord=dict(graphsettings.items()+[("graph_title","%s - OSD %s" % (graphsettings["graph_title"],osd),)])
|
||||
print ("multigraph %s.osd%s" % (gr_simple,osd))
|
||||
thisrecord=dict(list(graphsettings.items())+[("graph_title","%s - OSD %s" % (graphsettings["graph_title"],osd),)])
|
||||
#print thisrecord
|
||||
if ("%s.osd*" % (graph) in settings_graph):
|
||||
thisrecord=dict(thisrecord.items()+settings_graph["%s.osd%s" % (graph,osd)].items())
|
||||
if ("%s.osd%s" % (graph,osd) in settings_graph):
|
||||
thisrecord=dict(thisrecord.items()+settings_graph["%s.osd%s" % (graph,osd)].items())
|
||||
print "\n".join(["%s %s" % setting for setting in thisrecord.items()])
|
||||
print "osd%s_%s.label osd %s" % (osd,gr_simple,osd)
|
||||
print ("\n".join(["%s %s" % setting for setting in thisrecord.items()]))
|
||||
print ("osd%s_%s.label osd %s" % (osd,gr_simple,osd))
|
||||
else:
|
||||
for graph in graphlist:
|
||||
gr=graph.replace("-","_").replace(":","_")
|
||||
print "multigraph %s" % gr
|
||||
print ("multigraph %s" % gr)
|
||||
for osd in osds:
|
||||
if type(data[osd][graph])==dict:
|
||||
if data[osd][graph]["avgcount"]==0:
|
||||
|
@ -177,8 +178,8 @@ else:
|
|||
data[osd][graph]=float(data[osd][graph]["sum"])/float(data[osd][graph]["avgcount"])
|
||||
for osd in osds:
|
||||
value=data[osd][graph]
|
||||
print "osd%s_%s.value %s" % (osd,gr,data[osd][graph])
|
||||
print ("osd%s_%s.value %s" % (osd,gr,data[osd][graph]))
|
||||
if subgraphs:
|
||||
for osd in osds:
|
||||
print "multigraph %s.osd%s" % (gr,osd)
|
||||
print "osd%s_%s.value %s" % (osd,gr,data[osd][graph])
|
||||
print ("multigraph %s.osd%s" % (gr,osd))
|
||||
print ("osd%s_%s.value %s" % (osd,gr,data[osd][graph]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue