So, it’s mostly working, however some hosts that match the scan function, and respond to all the appropriate OIDs aren’t registering in the GUI. From the CLI it’s running and seeing it:
OMD[network]:~/ks_junk$ cmk -nv --no-cache --debug --checks endrun_clock -II clock3
Discovering services on: clock3
clock3:
+ FETCHING DATA
[snmp] Execute data source
[piggyback] Execute data source
+ EXECUTING DISCOVERY PLUGINS (1)
1 endrun_clock
SUCCESS - Found 1 services
The check itself
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
def inventory_endrun_clock(info):
return [(None, {})]
def check_endrun_clock(item, params, info):
for timeFigureOfMerit, ptpAccuracy, sigState in info:
status = 0
snmp_status = ''
if int(timeFigureOfMerit) > 8:
snmp_status += 'Time error is > 10ms:'
status = 2
if int(ptpAccuracy) > 1000:
snmp_status += 'PTP Clock Accuracy greater than 1 milisecond (%s):' % ptpAccuracy
status = 2
if sigState <> 'LKD':
snmp_status += 'CDMA signal status not locked! Currently=%s:' % sigState
status = 2
if (status == 0) and (int(ptpAccuracy) > 500):
snmp_status += 'PTP Clock Accuracy greater than 500 microseconds (%s):' % ptpAccuracy
status = 1
if status == 0:
snmp_status="CDMA signal locked: Time error of %s: PTP Accuracy of %s" % (timeFigureOfMerit, ptpAccuracy)
return (status, "Status: %s" % snmp_status, [('timeFigureOfMerit', timeFigureOfMerit), ('ptpAccuracy', ptpAccuracy)])
check_info['endrun_clock'] = {
'check_function': check_endrun_clock,
'inventory_function': inventory_endrun_clock,
'service_description': "endrun clock",
'snmp_scan_function': lambda oid: 'Sonoma' in oid(".1.3.6.1.2.1.1.1.0") and oid(".1.3.6.1.2.1.1.1.0") != None,
'has_perfdata': True,
}
# endrun base 1.3.6.1.4.1.13827
# .11.1.11.0 Integer time figure of merrit, timeFigureOfMerit
# .11.4.16.0 Integer PTP Clock Accuracy, ptpAccuracy
# .11.2.6.0 string CMD Signal State, sigState
snmp_info['endrun_clock'] = ('.1.3.6.1.4.1.13827', ['11.1.11.0', '11.4.16.0', '11.2.6.0'])