Skip to content

Commit

Permalink
Merge pull request #8 from opsdis/aha_dev
Browse files Browse the repository at this point in the history
aha dev
  • Loading branch information
thenodon authored Nov 4, 2019
2 parents 7179b4d + 00e837f commit bf9a729
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 46 deletions.
104 changes: 74 additions & 30 deletions test_data/perfdata.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,89 @@
[
{
{
"name": "google.se",
"custom_variables": {
"ENV": "production"
},
"perf_data": {
"pkt": {
"value": 1,
"warn": "0",
"crit": "0",
"min": 0,
"max": 5
},
"rta": {
"value": 3.08,
"warn": "2000.000",
"crit": "2000.000"
},
"pl": {
"value": 0,
"unit": "%",
"warn": "95",
"crit": "100",
"min": 0,
"max": 100
}
},
"check_command": "check-host-alive",
"state": 0,
"services": [{
"host": {
"name": "google.se"
},
"description": "disk_root",
"perf_data": {
"/": {
"value": 46139,
"unit": "MB",
"warn": "3806897",
"crit": "3806902",
"min": 0,
"max": 3806907
}
},
"check_command": "check_disk_local_mb!10!5!/",
"state": 0
}, {
"host": {
"name": "dn.se",
"scheduled_downtime_depth": 0
"name": "google.se"
},
"description": "PING",
"description": "disk_run",
"perf_data": {
"/run": {
"value": 25,
"unit": "MB",
"warn": "7927",
"crit": "7932",
"min": 0,
"max": 7937
}
},
"check_command": "check_disk_local_mb!10!5!/run",
"state": 0
}, {
"host": {
"name": "google.se"
},
"description": "pingit",
"perf_data": {
"rta": {
"value": 0.944,
"value": 2.319,
"unit": "ms",
"warn": "100.000",
"warn": "0.000",
"crit": "500.000",
"min": 0
},
"pl": {
"value": 0,
"unit": "%",
"warn": "20",
"crit": "60",
"warn": "40",
"crit": "80",
"min": 0,
"max": 100
}
},
"check_command": "check_ping!100,20%!500,60%",
"scheduled_downtime_depth": 0
},
{
"host": {
"name": "dn.se",
"scheduled_downtime_depth": 0
},
"description": "https",
"perf_data": {
"time": {
"value": 0.001476,
"unit": "s",
"min": 0,
"max": 10
}
},
"check_command": "check_tcp!443",
"scheduled_downtime_depth": 0
}
]
"check_command": "check_ping",
"state": 1
}]
}
9 changes: 0 additions & 9 deletions test_data/perflabels.json

This file was deleted.

14 changes: 7 additions & 7 deletions tests/test_perfdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ def test_get_perfdata_from_monitor(self):
mcon = Monitor.MonitorConfig(self.config)

# Create Mock
mcon.get_perfdata = AsyncMock(return_value=get_perf_mock_file())
mcon.get_host_data = AsyncMock(return_value=get_custom_vars_mock_file())
mcon.get_host_data = AsyncMock(return_value=get_perf_mock_file())
#mcon.get_perfdata = AsyncMock(return_value=get_custom_vars_mock_file())

perf = perfdata.Perfdata(mcon, 'dn.se')
perf = perfdata.Perfdata(mcon, 'google.se')

# Get the data from Monitor
monitor_data = _run(perf.get_perfdata())
self.assertEqual(len(monitor_data), 3)
self.assertEqual(len(monitor_data), 11)

self.assertTrue(
'monitor_check_ping_rta_seconds{hostname="dn.se", service="PING", environment="prod", dc="sto"}' in monitor_data)
'monitor_host_state{hostname="google.se", environment="production"}' in monitor_data)
self.assertTrue(
'monitor_check_ping_pl_ratio{hostname="dn.se", service="PING", environment="prod", dc="sto"}' in monitor_data)
'monitor_check_disk_local_mb_slash_bytes{hostname="google.se", service="disk_root", environment="production"}' in monitor_data)
self.assertTrue(
'monitor_check_tcp_time_seconds{hostname="dn.se", service="https", environment="prod", dc="sto"}' in monitor_data)
'monitor_check_ping_rta_seconds{hostname="google.se", service="pingit", environment="production"}' in monitor_data)

def _run(coro):
return asyncio.get_event_loop().run_until_complete(coro)
Expand Down

0 comments on commit bf9a729

Please sign in to comment.