CMK version: 2.4.0p17 community version OS version:Rocky Linux 9.7
i have a brother printer which shows the following alert:
unknown alert group 0#0: Slaapstand
i think the problem is related to the dutch word of Slaapstand instead of sleep and is shown as UNKN or unknown
i tried to create an overwrite in the file ~/local/lib/check_mk/plugins/agent_based/printer_alerts.py after copy of the original file but this failed. I think because the check is SNMP based and not agent based
can someone help me to change the alert to an known ok state ?
i am no crack in omd so please be gentle and give me exact pointers where i need to change what
Hope that someone is kind enough to help with this one
I donât think the Dutch Slaapstand is causing the warning, but more the code / value attached to it. There is a rule called Setup > Services > Service monitoring rules > Translation of service descriptions, but the help suggests that it will only make user friendly descriptions, the state will remain the same.
I also found the rule Setup > Services > Service monitoring rules > Generic String, but it lacks real documentation or examples what it actually does.
Checkmk AI says folllowing about it, which gives a bit of hope:
The generic string rule in Checkmk is used to define how string values from checks are processed and interpreted. It allows you to specify patterns and conditions to match string output from checks and then assign states, labels, or other attributes based on those matches.
In essence, the generic string rule helps you customize the interpretation of string results from various checks, enabling more precise monitoring and alerting based on textual data.
I tried this rule on my printer so stuff would go to a warning state when KYOCERA is mentioned, but I canât get it to work on my 2.1.0.p5.cre.
wow, perfect explanation .. many thanks for that. I tried it but i am not quite sure how the string is interpreted. I tried using exact string value like Slaapstand and using wildcards e.g. *Slaapstand * but the status will not change
I donât understand how the string is interpreted either. I would assume it does exact string or a regular expression. But result is the same as yours, the status remains unchanged.
I set this rule explicit on my printer host, so I wouldnât have weird outcomes on other hosts. But the weird thing is, the rule is not to be found in the hamburger menus Parameters for this ... of the host and its services, which lists all the rules that affect it.
since @Yggy mentioned my name, I got aware of this thread.
Iâm not sure if Checkmk picks up your check in that path. I overwrite checks (and borough parts of checks) regularly and I have no problem even with redirecting this to other âpartsâ of Checkmk (e.g. I redirect the serials from the plugin outputs to the inventory of the host).
The correct path for 2.4 should be: ~/local/lib/python3/cmk_addons/plugins/kyocera_alerts/agent_based/printer_alerts.py
âkyocera_alertsâ can be named different if you like.
many thanks for the share, just to be sure i follow it correctly and what i did so far:
sudo su <mysite>
mkdir -p ~/local/lib/python3/cmk_addons/plugins/brother_alerts/agent_based
cp ~/lib/check_mk/plugins/collection/agent_based/printer_alerts.py ~/local/lib/python3/cmk_addons/plugins/brother_alerts/agent_based/
vi ~/local/lib/python3/cmk_addons/plugins/brother_alerts/agent_based/printer_alerts.py
I added in the file under PRINTER_CODE_MAP: Final the following section:
PRINTER_ALERTS_TEXT_MAP: Final = {
âEnergiesparenâ: State.OK,
âSleepâ: State.OK,
âSlaapstandâ: State.OK,
}
now when i run cmk -R i get the following error:
OMD[lexit]:~$ cmk -R Error in agent based plugin: cmk_addons.plugins.brother_alerts.agent_based.printer_alerts:snmp_section_printer_alerts: plug-in âprinter_alertsâ already defined at cmk.plugins.collection.agent_based.printer_alerts:snmp_section_printer_alerts Error in agent based plugin: cmk_addons.plugins.brother_alerts.agent_based.printer_alerts:check_plugin_printer_alerts: plug-in âprinter_alertsâ already defined at cmk.plugins.collection.agent_based.printer_alerts:check_plugin_printer_alerts Generating configuration for core (type nagios)âŚ
So at least i am now getting information that the file will be read and used which i never got before but now it is complaining that the alerts are allready defined.
Do i need to create an emtpy file with just my changes ? or did i do something wrong ?
to be sure i removed my initial trial file ~/local/lib/check_mk/plugins/collection/printer_alerts.py so this could not get in the way
i did the following: sudo su - <sitename> mkdir -p ~/local/lib/check_mk/plugins/collection/agent_based/ cp ~/lib/check_mk/plugins/collection/agent_based/printer_alerts.py ~/local/lib/check_mk/plugins/collection/agent_based/printer_alerts.py
vi ~/local/lib/check_mk/plugins/collection/agent_based/printer_alerts.py
in this section i added the line âSlaapstandâ: State.OK,
saved the file and run cmk -R
and checked using cmk -nv brtl3550cdw
where brtl3550cdw is the name of my printer device in checkmk
the warning was nog gone and the check entered the Ok state
just to be sure to test if the file is interpreted i added first the following code in the python file before i did any changes: import sys sys.stderr.write(â### USING LOCAL printer_alerts OVERRIDE ###\nâ)
when running the check command cmk -nv brtl3550cdw it finaly showed the text ### USING LOCAL printer_alerts OVERRIDE ###so i knew the file was used. After this i removed the message and changed my check and presto
many thanks for the support and hopefully someone else can take the lessons learned