Extend printer_alerts plugin

Since it is not possible to set WATO parameters for the Service “Alerts” provided by the printer_alerts plugin I would like to either extend the plugin or implement some “Post-Summary Hook”.

When the service summary contains “out of paper (a4)” the service should have state “WARN”, when there are two alerts which contain this string the service should have a state of “CRIT”.

So far I’ve tried to generate messages in the event console. But this makes it necessary that our monitoring users check another dashboard (event console) and even acknowledge/process these events. Changing the state of the service would be much more viable since in this case, someone fills up the paper and the state returns back to green on its own.

I tried copying /opt/omd/versions/xyz/share/check_mk/checks/printer_alerts to /usr/lib/check_mk_agent/plugins/printer_alerts_test and changing all appearences of printer_alerts in the new file to printer_alerts_test. Further the plan was to change the behaviour of this for-loop, so the state matches what i want:

for sev, group, group_index, code, desc in alerts:

        code_txt, state = printer_code_map.get(code, ('unknown alert code: %s' % code, 3))

        if desc in printer_alerts_test_text_map:
            state = printer_alerts_test_text_map[desc]
            if state != 0:
                sum_state = max(state, sum_state)
                sum_txt.append(desc)
            continue
.....

But in the end my Plugin wasn’t visible in “Catalog of check plugins” and therefore unusable.

Appreciate any tips and alternatives to solve this.

By the name/path of the plugin I asume you are using CMK 1.6 or 2.0. In any case the path for your own (cmk16 style) checks is

/opt/omd/versions/xyz/local/share/check_mk/checks

Your check will then replace/override the original check, so no need to change it to printer_alerts _test, just change it to your likings.

1 Like

Thanks for taking your time to respond.

It worked :slight_smile: