Hi,
I am creating a custom plugins for an SNMP card which monitors our HVAC. After doing the following commands, there was no error on CLI however in CHeckmk dashboard it shows UNKNOWN state. Can anyone help me on this issue?
- cmk --detect-plugins=hvac_C2 -vl hvac-2
- cmk --debug -II --detect-plugins=hvac_C2 -vl hvac-2
- cmk -vv --debug --detect-plugins=hvac_C2 hvac-2
These are the code
import re
from .agent_based_api.v1 import *
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
get_value_store,
)
def discover_hvac_C2(section):
yield Service()
def check_hvac_C2(section):
hvac_snmp_C2 = int(section[0][0])
##Compressor 1
if hvac_snmp_C2 == 0:
hvac_snmp_value_converted = "Off"
summary_hvac_C2 = "Compressor2 Status: " + str(hvac_snmp_value_converted)
#yield Result(state=State.OK,summary=summary_hvac_C2)
else:
hvac_snmp_value_converted = "On"
summary_hvac_C2 = "Compressor2 Status: " + str(hvac_snmp_value_converted)
#yield Result(state=State.CRIT,summary=summary_hvac_C2)
yield Result(state=State.CRIT,summary=summary_hvac_C2)
hvac_snmp_C2_name = "Compressor_Status"
yield Metric(hvac_snmp_C2_name,hvac_snmp_C2)
register.snmp_section(
name = "hvac_C2",
#detect = contains(".1.3.6.1.2.1.1.1.0","licheepi-zero"),
detect = exists(".1.3.6.1.4.1.7416.1.2.30019.0"),
fetch = SNMPTree(
base = '.1.3.6.1.4.1.7416.1.2',
oids = ['31.0'],
),
)
##register plugins
register.check_plugin(
name = "hvac_C2",
sections = ["hvac_C2"],
service_name='HVAC Compressor 2',
discovery_function= discover_hvac_C2,
check_function= check_hvac_C2,
)
Result from * cmk -vv --debug --detect-plugins=hvac_C2 hvac-2
OMD[cmkvm]:~/local/share/check_mk/checks$ cmk --detect-plugins=hvac_C2 -vl hvac-2
cmk --debug -II --detect-plugins=hvac_C2 -vl hvac-2
Discovering services and host labels on: hvac-2
hvac-2:
+ FETCHING DATA
[SNMPFetcher] Execute data source
[PiggybackFetcher] Execute data source
No piggyback files for 'hvac-2'. Skip processing.
No piggyback files for '10.224.1.35'. Skip processing.
+ ANALYSE DISCOVERED HOST LABELS
SUCCESS - Found no host labels
+ ANALYSE DISCOVERED SERVICES
+ EXECUTING DISCOVERY PLUGINS (1)
1 hvac_C2
SUCCESS - Found 1 services
OMD[cmkvm]:~/local/share/check_mk/checks$ cmk -vv --debug --detect-plugins=hvac_C2 hvac-2
Checkmk version 2.1.0p2
Try license usage history update.
Trying to acquire lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
Got lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
Trying to acquire lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Got lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Next run time has not been reached yet. Abort.
Releasing lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Released lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Releasing lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
Released lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
+ FETCHING DATA
Source: SourceType.HOST/FetcherType.SNMP
[cpu_tracking] Start [7f202da369d0]
[SNMPFetcher] Fetch with cache settings: SNMPFileCache(hvac-2, base_path=/omd/sites/cmkvm/tmp/check_mk/data_source_cache/snmp, max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=False, use_outdated=False, simulation=False)
Not using cache (Mode Mode.FORCE_SECTIONS)
[SNMPFetcher] Execute data source
hvac_C2: Fetching data (SNMP walk cache cleared)
Executing BULKWALK of ".1.3.6.1.4.1.7416.1.2.31" on hvac-2
.1.3.6.1.4.1.7416.1.2.31.0 => [b'0'] 'INTEGER'
Not using cache (Mode Mode.FORCE_SECTIONS)
[cpu_tracking] Stop [7f202da369d0 - Snapshot(process=posix.times_result(user=0.08999999999999986, system=0.020000000000000018, children_user=0.0, children_system=0.0, elapsed=0.15000000223517418))]
Source: SourceType.HOST/FetcherType.PIGGYBACK
[cpu_tracking] Start [7f202da0b850]
[PiggybackFetcher] Fetch with cache settings: NoCache(hvac-2, base_path=/omd/sites/cmkvm/tmp/check_mk/data_source_cache/piggyback, max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=True, use_outdated=False, simulation=False)
Not using cache (Cache usage disabled)
[PiggybackFetcher] Execute data source
No piggyback files for 'hvac-2'. Skip processing.
No piggyback files for '10.224.1.35'. Skip processing.
Not using cache (Cache usage disabled)
[cpu_tracking] Stop [7f202da0b850 - Snapshot(process=posix.times_result(user=0.0, system=0.010000000000000009, children_user=0.0, children_system=0.0, elapsed=0.009999997913837433))]
+ PARSE FETCHER RESULTS
Source: SourceType.HOST/FetcherType.SNMP
No persisted sections
-> Add sections: ['hvac_C2']
Source: SourceType.HOST/FetcherType.PIGGYBACK
No persisted sections
-> Add sections: []
Received no piggyback data
Received no piggyback data
[cpu_tracking] Start [7f202da0b640]
value store: synchronizing
Trying to acquire lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Got lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
value store: loading from disk
Releasing lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Released lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
value store: synchronizing
Trying to acquire lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Got lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
value store: already loaded
Releasing lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Released lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
[cpu_tracking] Stop [7f202da0b640 - Snapshot(process=posix.times_result(user=0.0, system=0.010000000000000009, children_user=0.0, children_system=0.0, elapsed=0.019999999552965164))]
[snmp] Success, execution time 0.2 sec | execution_time=0.180 user_time=0.090 system_time=0.040 children_user_time=0.000 children_system_time=0.000 cmk_time_snmp=0.040 cmk_time_agent=0.000
OMD[cmkvm]:~/local/share/check_mk/checks$ cmk -vv --debug --detect-plugins=hvac_C2 hvac-2
Checkmk version 2.1.0p2
Try license usage history update.
Trying to acquire lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
Got lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
Trying to acquire lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Got lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Next run time has not been reached yet. Abort.
Releasing lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Released lock on /omd/sites/cmkvm/var/check_mk/license_usage/history.json
Releasing lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
Released lock on /omd/sites/cmkvm/var/check_mk/license_usage/next_run
+ FETCHING DATA
Source: SourceType.HOST/FetcherType.SNMP
[cpu_tracking] Start [7f3a044e2d60]
[SNMPFetcher] Fetch with cache settings: SNMPFileCache(hvac-2, base_path=/omd/sites/cmkvm/tmp/check_mk/data_source_cache/snmp, max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=False, use_outdated=False, simulation=False)
Not using cache (Mode Mode.FORCE_SECTIONS)
[SNMPFetcher] Execute data source
hvac_C2: Fetching data (SNMP walk cache cleared)
Executing BULKWALK of ".1.3.6.1.4.1.7416.1.2.31" on hvac-2
.1.3.6.1.4.1.7416.1.2.31.0 => [b'0'] 'INTEGER'
Not using cache (Mode Mode.FORCE_SECTIONS)
[cpu_tracking] Stop [7f3a044e2d60 - Snapshot(process=posix.times_result(user=0.0, system=0.08000000000000007, children_user=0.0, children_system=0.0, elapsed=0.12000000104308128))]
Source: SourceType.HOST/FetcherType.PIGGYBACK
[cpu_tracking] Start [7f3a043e4490]
[PiggybackFetcher] Fetch with cache settings: NoCache(hvac-2, base_path=/omd/sites/cmkvm/tmp/check_mk/data_source_cache/piggyback, max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=True, use_outdated=False, simulation=False)
Not using cache (Cache usage disabled)
[PiggybackFetcher] Execute data source
No piggyback files for 'hvac-2'. Skip processing.
No piggyback files for '10.224.1.35'. Skip processing.
Not using cache (Cache usage disabled)
[cpu_tracking] Stop [7f3a043e4490 - Snapshot(process=posix.times_result(user=0.0, system=0.0, children_user=0.0, children_system=0.0, elapsed=0.0))]
+ PARSE FETCHER RESULTS
Source: SourceType.HOST/FetcherType.SNMP
No persisted sections
-> Add sections: ['hvac_C2']
Source: SourceType.HOST/FetcherType.PIGGYBACK
No persisted sections
-> Add sections: []
Received no piggyback data
Received no piggyback data
[cpu_tracking] Start [7f3a043e45b0]
value store: synchronizing
Trying to acquire lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Got lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
value store: loading from disk
Releasing lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Released lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
HVAC Compressor 2 Compressor2 Status: Off
value store: synchronizing
Trying to acquire lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Got lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
value store: already loaded
Releasing lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
Released lock on /omd/sites/cmkvm/tmp/check_mk/counters/hvac-2
[cpu_tracking] Stop [7f3a043e45b0 - Snapshot(process=posix.times_result(user=0.0, system=0.0, children_user=0.0, children_system=0.0, elapsed=0.010000001639127731))]
[snmp] Success, execution time 0.1 sec | execution_time=0.130 user_time=0.000 system_time=0.080 children_user_time=0.000 children_system_time=0.000 cmk_time_snmp=0.040 cmk_time_agent=0.000