From e479e08ee08a52c0ea402d6a43e814170fdb8e9b Mon Sep 17 00:00:00 2001 From: Holger Sielaff Date: Wed, 1 Oct 2025 12:20:19 +0200 Subject: [PATCH] ... --- .../zabbix/zabbix_agentd.d/python-exceptions.conf | 3 ++- .../doc/zabbix-python-monitoring/example_usage.py | 13 +++++-------- .../zabbix_template_python_exceptions.yaml | 5 +++-- 3 files changed, 10 insertions(+), 11 deletions(-) rename example_usage.py => src/usr/share/doc/zabbix-python-monitoring/example_usage.py (82%) diff --git a/src/etc/zabbix/zabbix_agentd.d/python-exceptions.conf b/src/etc/zabbix/zabbix_agentd.d/python-exceptions.conf index b9cb87b..715a6d7 100644 --- a/src/etc/zabbix/zabbix_agentd.d/python-exceptions.conf +++ b/src/etc/zabbix/zabbix_agentd.d/python-exceptions.conf @@ -56,4 +56,5 @@ UserParameter=python.exception.log.accessible,[ -r /var/log/zabbix/python.except UserParameter=python.exception.handler.active,python3 -c "import sys; sys.path.insert(0, '/usr/lib/python3.12'); import zabbix_exception_handler; print('1')" 2>/dev/null || echo "0" # Alternative check: Prüfe ob Handler-Modul existiert -UserParameter=python.exception.handler.available,[ -f /usr/lib/python3.12/zabbix_exception_handler.py ] && echo "1" || echo "0" \ No newline at end of file +UserParameter=python.exception.handler.available,[ -f /usr/lib/python3.12/zabbix_exception_handler.py ] && echo "1" || echo "0" + diff --git a/example_usage.py b/src/usr/share/doc/zabbix-python-monitoring/example_usage.py similarity index 82% rename from example_usage.py rename to src/usr/share/doc/zabbix-python-monitoring/example_usage.py index 3b94684..8b46b2b 100644 --- a/example_usage.py +++ b/src/usr/share/doc/zabbix-python-monitoring/example_usage.py @@ -8,16 +8,13 @@ This demonstrates how to use the Zabbix exception monitoring in your Python appl import sys import os -# Add the Zabbix module path -sys.path.insert(0, '/usr/lib/python3.12') +# Optional: Add the Zabbix module path +# sys.path.insert(0, '/usr/lib/python3.12') # Method 1: Import the main handler (auto-initializes) -import zabbix_exception_handler +from zabbix_monitor import zabbix_monitor -# Method 2: Alternative simple import (also auto-initializes) -# import zabbix_monitor - -# Method 3: Manual initialization (if you want more control) +# Method 2: Manual initialization (if you want more control) # from zabbix_exception_handler import ZabbixPythonExceptionHandler # ZabbixPythonExceptionHandler.init() @@ -59,4 +56,4 @@ if __name__ == "__main__": demonstrate_file_error() else: print("No exception generated. Handler is still active for any future exceptions.") - print("Your application can continue normally...") \ No newline at end of file + print("Your application can continue normally...") diff --git a/src/usr/share/doc/zabbix-python-monitoring/zabbix_template_python_exceptions.yaml b/src/usr/share/doc/zabbix-python-monitoring/zabbix_template_python_exceptions.yaml index 3dc6df9..511959f 100644 --- a/src/usr/share/doc/zabbix-python-monitoring/zabbix_template_python_exceptions.yaml +++ b/src/usr/share/doc/zabbix-python-monitoring/zabbix_template_python_exceptions.yaml @@ -66,7 +66,7 @@ zabbix_export: } triggers: - uuid: 9df96b18c230490a9a0a9e2307226352 - expression: 'length(last(/Python Exceptions Monitoring/python.exception.latest)) > 15' + expression: 'length(last(/Python Exceptions Monitoring/python.exception.latest)) > 15 and change(/Python Exceptions Monitoring/python.exception.latest) <> 0' name: 'Python Exception Detected' event_name: 'New Python Exception Logged' priority: HIGH @@ -106,6 +106,7 @@ zabbix_export: value: application - tag: component value: python + recovery_mode: NONE - uuid: 8df96b18c230490a9a0a9e2307226343 name: 'Python Exception Log Size' type: ZABBIX_PASSIVE @@ -130,4 +131,4 @@ zabbix_export: - tag: scope value: availability - tag: component - value: python \ No newline at end of file + value: python