Thanks Andreas! I finished to write the plugin with all sections needed (I hope).
from .agent_based_api.v1 import *
from pprint import pprint
def parse_damocles_in(string_table):
section = []
for line in string_table:
alarm = int(line[3])
if alarm != 0:
section.append(line)
return section
def discover_damocles_in(section):
for line in section:
yield Service(item=line[1])
def check_damocles_in(item, section):
for id, check, state, enable, pulseCount in section:
if check == item:
perfdata = [("pulseCount", pulseCount, None, None, None)]
if state == "0":
yield Result(state=State.OK)
yield Metric(perfdata)
else:
yield Result(state=State.CRIT)
yield Metric(perfdata)
register.snmp_section(
name = "damocles_in",
detect = startswith(".1.3.6.1.2.1.1.1.0", "Damocles"),
parse_function=parse_damocles_in,
fetch = SNMPTree(
base = '.1.3.6.1.4.1.21796.3.4.1.1',
oids = [
OIDEnd(),
'3', # Sensor Name
'2', # Sensor Value
'4', # Sensor alarm State (ON/OFF)
'6', # Sensor Pulse Counter
],
),
)
register.check_plugin(
name="damocles_in",
service_name="%s",
discovery_function=discover_damocles_in,
check_function=check_damocles_in,
)
Now the cmk command work as expected:
cmk --detect-plugins=damocles_in -vnII IT1-Damocles-Ingresso
Discovering services and host labels on: IT1-Damocles-Ingresso
IT1-Damocles-Ingresso:
+ FETCHING DATA
[SNMPFetcher] Execute data source
No piggyback files for 'IT1-Damocles-Ingresso'. Skip processing.
No piggyback files for '192.168.70.17'. Skip processing.
[PiggybackFetcher] Execute data source
+ PARSE FETCHER RESULTS
Received no piggyback data
+ EXECUTING HOST LABEL DISCOVERY
+ PERFORM HOST LABEL DISCOVERY
+ EXECUTING DISCOVERY PLUGINS (1)
7 damocles_in
SUCCESS - Found 7 services, no host labels
But without “–detect-plugins” it doesn’t:
Discovering services and host labels on: IT1-Damocles-Ingresso
IT1-Damocles-Ingresso:
+ FETCHING DATA
[SNMPFetcher] Execute data source
ERROR: SNMP error
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.232.2.2.4.2.0
ERROR: SNMP error
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.2.1.25.1.1.0
ERROR: SNMP error
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.2036.2.1.1.4.0
ERROR: SNMP error
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.6302.2.1.1.1.0
ERROR: SNMP error
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.14848.2.1.1.1.0
ERROR: SNMP error
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: .1.3.6.1.4.1.30155.2.1.1.0
No piggyback files for 'IT1-Damocles-Ingresso'. Skip processing.
No piggyback files for '192.168.70.17'. Skip processing.
[PiggybackFetcher] Execute data source
+ PARSE FETCHER RESULTS
Received no piggyback data
+ EXECUTING HOST LABEL DISCOVERY
+ PERFORM HOST LABEL DISCOVERY
+ EXECUTING DISCOVERY PLUGINS (3)
1 snmp_info
1 uptime
SUCCESS - Found 2 services, no host labels