Hi everyone,
I’ve currently developed more or less two special agents (iobroker homematic and deconz)(not completly finished yet)
Now I did a third one which should talk to the pihole api etc.
special agent plugin works as desired also the configuration via wato.
now I’m on the agent_based plugin part.
I registered the agent section and the data is processable in the parse function.
So far so good.
But it seems that the discovery function is not triggered and as I think I did nothing different then before I have no clue why this is not working
So, the special agent output looks like this:
<<<pihole_summaryRaw:sep(0)>>>
{"domains_being_blocked": 81590, "dns_queries_today": 213399, "ads_blocked_today": 34986, "ads_percentage_today": 16.394642, "unique_domains": 7447, "queries_forwarded": 76777, "queries_cached": 99316, "clients_ever_seen": 30, "unique_clients": 28, "dns_queries_all_types": 213246, "reply_NODATA": 27044, "reply_NXDOMAIN": 14808, "reply_CNAME": 52306, "reply_IP": 113740, "privacy_level": 0, "status": "enabled", "gravity_last_updated": {"file_exists": true, "absolute": 1621774377, "relative": {"days": 226, "hours": 0, "minutes": 8}}, "check_source_query": "summaryRaw"}
Just the section header and a one-liner json output
the part of the agent_based plugin looks like this
def parse__pihole_stats(string_table):
data = {}
for line, in string_table:
str2obj = json.loads(line)
data[str2obj["check_source_query"]] = str2obj
pprint(data)
return data
register.agent_section(
name = "pihole_summaryRaw",
parse_function = parse__pihole_stats
)
def discover__pihole_stats(section):
pprint(section)
for item in section:
yield Service(item=item)
#def check__pihole_stats(item, params, section):
def check__pihole_stats(item, section):
yield Result(
state = State.OK,
summary = f"item: {section[item]}"
)
register.check_plugin(
name = "pihole_stats",
service_name = "Pihole %s",
discovery_function = discover__pihole_stats,
#check_default_parameters={},
check_function = check__pihole_stats,
#check_ruleset_name="pihole_stats",
)
If I run "cmk --debug -vII --plugins pihole_stats " I get only this, no result, ouput or even a execution of the discovery part.
Discovering services and host labels on: <HOSTNAME>
<HOSTNAME>:
+ FETCHING DATA
Using data from cache file /omd/sites/cmk/tmp/check_mk/cache/<HOSTNAME>
[TCPFetcher] Use cached data
Using data from cache file /omd/sites/cmk/tmp/check_mk/data_source_cache/special_pihole/<HOSTNAME>
[ProgramFetcher] Use cached data
No piggyback files for '<HOSTNAME>'. Skip processing.
No piggyback files for '<IP>'. Skip processing.
[PiggybackFetcher] Execute data source
+ PARSE FETCHER RESULTS
Storing piggyback data for: 7182957b8703
Storing piggyback data for: 43e9c319f2f1
Storing piggyback data for: 47b733547e92
Storing piggyback data for: 428e360bd489
Storing piggyback data for: 649ca77ebd98
Storing piggyback data for: 17cdcc629f22
Storing piggyback data for: b79474b1ed53
Storing piggyback data for: d31d1261104e
Storing piggyback data for: 070215af6014
Storing piggyback data for: 649db183b542
Received piggyback data for 10 hosts
+ EXECUTING HOST LABEL DISCOVERY
{'summaryRaw': {'ads_blocked_today': 35060,
'ads_percentage_today': 16.382183,
'check_source_query': 'summaryRaw',
'clients_ever_seen': 30,
'dns_queries_all_types': 213860,
'dns_queries_today': 214013,
'domains_being_blocked': 81590,
'gravity_last_updated': {'absolute': 1621774377,
'file_exists': True,
'relative': {'days': 226,
'hours': 0,
'minutes': 12}},
'privacy_level': 0,
'queries_cached': 99642,
'queries_forwarded': 76987,
'reply_CNAME': 52443,
'reply_IP': 114054,
'reply_NODATA': 27140,
'reply_NXDOMAIN': 14856,
'status': 'enabled',
'unique_clients': 28,
'unique_domains': 7447}}
+ PERFORM HOST LABEL DISCOVERY
+ EXECUTING DISCOVERY PLUGINS (0)
SUCCESS - Found no services, 2 host labels
I’ve got the feeling that I’m missing something.
I appriciate every hint