mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Merge pull request #1393 from spacelama/ceph_updates
Cater for newer OS dependencies - python and ceph updates
This commit is contained in:
commit
89bd7114e1
3 changed files with 25 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
: << =cut
|
: << =cut
|
||||||
|
@ -96,9 +96,10 @@ def read_osd(filename):
|
||||||
try:
|
try:
|
||||||
s=socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
|
s=socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
|
||||||
s.connect(filename)
|
s.connect(filename)
|
||||||
s.send("{\"prefix\": \"perf dump\"}\0")
|
s.send(b'{"prefix": "perf dump"}\0')
|
||||||
result=s.recv(102400)
|
result=s.recv(102400)
|
||||||
result=result[4:]
|
result=result[4:]
|
||||||
|
result=result.decode('utf-8')
|
||||||
return json.loads(result)
|
return json.loads(result)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -134,7 +135,7 @@ osds.sort()
|
||||||
for key in osds:
|
for key in osds:
|
||||||
data[key]=collapse_one(data[key])
|
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)))
|
graphlist=list(set(itertools.chain(*graphlist)))
|
||||||
|
|
||||||
if (sys.argv.__len__()>1) and (sys.argv[1]=="config"):
|
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_pretty=graph.replace("_"," ").title()
|
||||||
gr=graph.replace("-","_").replace(":","_")
|
gr=graph.replace("-","_").replace(":","_")
|
||||||
graphdefaults={"graph_title":gr_pretty,"graph_vlabel":gr_pretty,"graph_category":"fs"}
|
graphdefaults={"graph_title":gr_pretty,"graph_vlabel":gr_pretty,"graph_category":"fs"}
|
||||||
graphsettings=dict(graphdefaults.items()+graphsettings.items())
|
graphsettings=dict(list(graphdefaults.items())+list(graphsettings.items()))
|
||||||
print "multigraph %s" % (gr_simple)
|
print ("multigraph %s" % (gr_simple))
|
||||||
print "\n".join(["%s %s" % setting for setting in graphsettings.items()])
|
print ("\n".join(["%s %s" % setting for setting in graphsettings.items()]))
|
||||||
for osd in sortlist(data.keys()):
|
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:
|
if subgraphs:
|
||||||
for osd in sortlist(data.keys()):
|
for osd in sortlist(data.keys()):
|
||||||
print "multigraph %s.osd%s" % (gr_simple,osd)
|
print ("multigraph %s.osd%s" % (gr_simple,osd))
|
||||||
thisrecord=dict(graphsettings.items()+[("graph_title","%s - OSD %s" % (graphsettings["graph_title"],osd),)])
|
thisrecord=dict(list(graphsettings.items())+[("graph_title","%s - OSD %s" % (graphsettings["graph_title"],osd),)])
|
||||||
#print thisrecord
|
#print thisrecord
|
||||||
if ("%s.osd*" % (graph) in settings_graph):
|
if ("%s.osd*" % (graph) in settings_graph):
|
||||||
thisrecord=dict(thisrecord.items()+settings_graph["%s.osd%s" % (graph,osd)].items())
|
thisrecord=dict(thisrecord.items()+settings_graph["%s.osd%s" % (graph,osd)].items())
|
||||||
if ("%s.osd%s" % (graph,osd) in settings_graph):
|
if ("%s.osd%s" % (graph,osd) in settings_graph):
|
||||||
thisrecord=dict(thisrecord.items()+settings_graph["%s.osd%s" % (graph,osd)].items())
|
thisrecord=dict(thisrecord.items()+settings_graph["%s.osd%s" % (graph,osd)].items())
|
||||||
print "\n".join(["%s %s" % setting for setting in thisrecord.items()])
|
print ("\n".join(["%s %s" % setting for setting in thisrecord.items()]))
|
||||||
print "osd%s_%s.label osd %s" % (osd,gr_simple,osd)
|
print ("osd%s_%s.label osd %s" % (osd,gr_simple,osd))
|
||||||
else:
|
else:
|
||||||
for graph in graphlist:
|
for graph in graphlist:
|
||||||
gr=graph.replace("-","_").replace(":","_")
|
gr=graph.replace("-","_").replace(":","_")
|
||||||
print "multigraph %s" % gr
|
print ("multigraph %s" % gr)
|
||||||
for osd in osds:
|
for osd in osds:
|
||||||
if type(data[osd][graph])==dict:
|
if type(data[osd][graph])==dict:
|
||||||
if data[osd][graph]["avgcount"]==0:
|
if data[osd][graph]["avgcount"]==0:
|
||||||
|
@ -177,8 +178,8 @@ else:
|
||||||
data[osd][graph]=float(data[osd][graph]["sum"])/float(data[osd][graph]["avgcount"])
|
data[osd][graph]=float(data[osd][graph]["sum"])/float(data[osd][graph]["avgcount"])
|
||||||
for osd in osds:
|
for osd in osds:
|
||||||
value=data[osd][graph]
|
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:
|
if subgraphs:
|
||||||
for osd in osds:
|
for osd in osds:
|
||||||
print "multigraph %s.osd%s" % (gr,osd)
|
print ("multigraph %s.osd%s" % (gr,osd))
|
||||||
print "osd%s_%s.value %s" % (osd,gr,data[osd][graph])
|
print ("osd%s_%s.value %s" % (osd,gr,data[osd][graph]))
|
||||||
|
|
|
@ -35,6 +35,8 @@ fi
|
||||||
WARNING_LEVEL=${warning_level:-"80"}
|
WARNING_LEVEL=${warning_level:-"80"}
|
||||||
CRITICAL_LEVEL=${critical_level:-"90"}
|
CRITICAL_LEVEL=${critical_level:-"90"}
|
||||||
|
|
||||||
|
CEPH_STATUS=$(ceph -s --format=json)
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
|
|
||||||
echo 'graph_title CEPH capacity'
|
echo 'graph_title CEPH capacity'
|
||||||
|
@ -43,7 +45,7 @@ if [ "$1" = "config" ]; then
|
||||||
echo 'graph_info CEPH cluster capacity'
|
echo 'graph_info CEPH cluster capacity'
|
||||||
echo 'graph_args --base 1000 -l 0'
|
echo 'graph_args --base 1000 -l 0'
|
||||||
|
|
||||||
CAPACITY=$(ceph -s | grep pgmap | cut -d ';' -f 2 | cut -d ',' -f 3 | cut -d '/' -f 2 | awk '{ print $1 }')
|
CAPACITY=$(echo "$CEPH_STATUS" | jq '.pgmap.bytes_total')
|
||||||
WARNING=$(echo "scale=2;$CAPACITY * ($WARNING_LEVEL/100)" | bc -l | cut -d '.' -f 1)
|
WARNING=$(echo "scale=2;$CAPACITY * ($WARNING_LEVEL/100)" | bc -l | cut -d '.' -f 1)
|
||||||
CRITICAL=$(echo "scale=2;$CAPACITY * ($CRITICAL_LEVEL/100)" | bc -l | cut -d '.' -f 1)
|
CRITICAL=$(echo "scale=2;$CAPACITY * ($CRITICAL_LEVEL/100)" | bc -l | cut -d '.' -f 1)
|
||||||
echo "capacity.label Capacity"
|
echo "capacity.label Capacity"
|
||||||
|
@ -57,6 +59,6 @@ if [ "$1" = "config" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "capacity.value $(ceph -s | grep pgmap | cut -d ';' -f 2 | cut -d ',' -f 3 | cut -d '/' -f 2 | awk '{ print $1 }')"
|
echo "capacity.value $(echo "$CEPH_STATUS" | jq '.pgmap.bytes_total')"
|
||||||
echo "used.value $(ceph -s | grep pgmap | cut -d ';' -f 2 | cut -d ',' -f 2 | awk '{ print $1 }')"
|
echo "used.value $(echo "$CEPH_STATUS" | jq '.pgmap.bytes_used')"
|
||||||
echo "data.value $(ceph -s | grep pgmap | cut -d ';' -f 2 | cut -d ',' -f 1 | awk '{ print $1 }')"
|
echo "data.value $(echo "$CEPH_STATUS" | jq '.pgmap.data_bytes')" # no idea of the intention of this metric; could be bytes_avail
|
||||||
|
|
|
@ -50,6 +50,6 @@ fi
|
||||||
|
|
||||||
CEPH_STATUS=$(ceph -s --format=json)
|
CEPH_STATUS=$(ceph -s --format=json)
|
||||||
|
|
||||||
echo "osds.value $(echo "$CEPH_STATUS" | jq '.osdmap.osdmap.num_osds')"
|
echo "osds.value $(echo "$CEPH_STATUS" | jq '.osdmap.num_osds')"
|
||||||
echo "up.value $(echo "$CEPH_STATUS" | jq '.osdmap.osdmap.num_up_osds')"
|
echo "up.value $(echo "$CEPH_STATUS" | jq '.osdmap.num_up_osds')"
|
||||||
echo "in.value $(echo "$CEPH_STATUS" | jq '.osdmap.osdmap.num_in_osds')"
|
echo "in.value $(echo "$CEPH_STATUS" | jq '.osdmap.num_in_osds')"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue