fix check load / memory def
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
- pip3 install requests
|
- pip3 install requests
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '0.5.0'
|
__version__ = '0.5.1'
|
||||||
__author__ = 'anima'
|
__author__ = 'anima'
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
@@ -97,10 +97,10 @@ class DockerSwarmCoresResource(nagiosplugin.Resource):
|
|||||||
nagiosplugin.Metric: single metric element (return)
|
nagiosplugin.Metric: single metric element (return)
|
||||||
"""
|
"""
|
||||||
data = self.api.statistics()
|
data = self.api.statistics()
|
||||||
memory = data['memory']
|
cpu = data['cpu']
|
||||||
memory_usage_percent = round(memory['usage'], 2)
|
cpu_usage_percent = round(cpu['usage'], 2)
|
||||||
|
|
||||||
return nagiosplugin.Metric(name='load', value=memory_usage_percent, uom='%', context='scalar_context')
|
return nagiosplugin.Metric(name='load', value=cpu_usage_percent, uom='%', context='scalar_context')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -117,11 +117,10 @@ class DockerSwarmMemoryResource(nagiosplugin.Resource):
|
|||||||
nagiosplugin.Metric: single metric element (return)
|
nagiosplugin.Metric: single metric element (return)
|
||||||
"""
|
"""
|
||||||
data = self.api.statistics()
|
data = self.api.statistics()
|
||||||
print(data)
|
memory = data['memory']
|
||||||
cpu = data['cpu']
|
memory_usage_percent = round(memory['usage'], 2)
|
||||||
cpu_usage_percent = round((cpu['usage'] / cpu['cores']) * 100, 2)
|
|
||||||
|
|
||||||
return nagiosplugin.Metric(name='memory', value=cpu_usage_percent, uom='%', context='scalar_context')
|
return nagiosplugin.Metric(name='memory', value=memory_usage_percent, uom='%', context='scalar_context')
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user