Wie muss ein Python-Script unter der Enterprise Version 1.5.0p11 mindestens beschaffen sein, damit es als Alert-Handler fehlerfrei ausgeführt wird und man nicht nur eine Fehlermeldung erhält derart:
“Could not find platform independent libraries \nCould not find platform dependent libraries <exec_prefix>\nConsider setting $PYTHONHOME to [:<exec_prefix>]\nImportError: No module named site”
Beim Gebrauch von : #!/usr/lib/python als erster Zeile eines Scripts erscheint die o.g. Fehlermeldung zwar nicht mehr, sondern der selbst geschriebene Python-Handler wird von Check_MK gar nicht ausgeführt, weil es im Python Code der Datei /cee/alert_handling.py Zeile 385 das Directory nicht gefunden werden kann:
Auszug aus dem Log:
2020-05-20 17:17:01 Got raw alert (TEST-FE2;TCP Connections) context with 62 variables
2020-05-20 17:17:01 Rule ‘Test’…
2020-05-20 17:17:01 Event type is wr
2020-05-20 17:17:01 -> matches!
2020-05-20 17:17:01 Executing alert handler transfer_to_vine_db.py for TEST-FE2;TCP Connections
2020-05-20 17:17:01 Spawned event handler with PID 43692
2020-05-20 17:17:01 1 running alert handlers:
2020-05-20 17:17:01 transfer_to_vine_db.py[43692]: TEST-FE2;TCP Connections - timeout in 59s, kill in 119s
2020-05-20 17:17:01 ERROR [Errno 2] No such file or directory
Traceback (most recent call last):
File “/omd/sites/vine/lib/python/cmk_base/events.py”, line 112, in event_keepalive
event_function(context)
File “/omd/sites/vine/lib/python/cmk_base/cee/alert_handling.py”, line 194, in process_alert
execute_alert_rules(raw_context)
File “/omd/sites/vine/lib/python/cmk_base/cee/alert_handling.py”, line 205, in execute_alert_rules
execute_alert_handler_rule(rule, context)
File “/omd/sites/vine/lib/python/cmk_base/cee/alert_handling.py”, line 281, in execute_alert_handler_rule
run_process_alert_handler(handler_name, handler_params, context)
File “/omd/sites/vine/lib/python/cmk_base/cee/alert_handling.py”, line 340, in run_process_alert_handler
extra_environment)
File “/omd/sites/vine/lib/python/cmk_base/cee/alert_handling.py”, line 385, in run_alert_handler_async
os.execv(handler_path, command_line_arguments)
OSError: [Errno 2] No such file or directory
2020-05-20 17:17:01 CMC has closed the connection. Shutting down.
2020-05-20 17:17:03 1 running alert handlers:
2020-05-20 17:17:03 transfer_to_vine_db.py[43692]: TEST-FE2;TCP Connections - timeout in 57s, kill in 117s
2020-05-20 17:17:03 Handler [43692] transfer_to_vine_db.py TEST-FE2;TCP Connections stopped: *