Zabbix监控oxidized备份状态
分类:运维技术日期:2021-04-16 - 14:15:38作者:老谢
原理是利用oxidized的hooks功能调用zabbix_sender推送数据给zabbix_server。
oxidized的config部分
hooks: node_success: type: exec events: [node_success] cmd: ' /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k oxidized.datetime -o `date +%s`; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k oxidized.status -o 0; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_EVENT -o $OX_EVENT; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_JOB_STATUS -o $OX_JOB_STATUS; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_JOB_TIME -o $OX_JOB_TIME; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_IP -o $OX_NODE_IP; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_MODEL -o $OX_NODE_MODEL; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_NAME -o $OX_NODE_NAME' async: false timeout: 120 node_fail: type: exec events: [node_fail] cmd: ' /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k oxidized.datetime -o `date +%s`; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_EVENT -o $OX_EVENT; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_JOB_STATUS -o $OX_JOB_STATUS; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_JOB_TIME -o $OX_JOB_TIME; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_IP -o $OX_NODE_IP; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_MODEL -o $OX_NODE_MODEL; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_NAME -o $OX_NODE_NAME; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k oxidized.status -o 1' async: false timeout: 120 post_store: type: exec events: [post_store] cmd: ' /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k oxidized.datetime -o `date +%s`; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_EVENT -o $OX_EVENT; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_JOB_STATUS -o $OX_JOB_STATUS; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_JOB_TIME -o $OX_JOB_TIME; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_IP -o $OX_NODE_IP; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_MODEL -o $OX_NODE_MODEL; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k OX_NODE_NAME -o ${OX_NODE_NAME}; /usr/local/zabbix/bin/zabbix_sender -z zabbix_server_ip -s zabbix_agentd(server_name) -k oxidized.status -o 2' async: false timeout: 120 |
zabbix_oxidized模板
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>5.2</version> <date>2021-04-16T06:03:29Z</date> <groups> <group> <name>Templates</name> </group> </groups> <templates> <template> <template>Template Application - Oxidized</template> <name>Template Application - Oxidized</name> <description>This template allows traps to be sent to Zabbix using Oxidized Hooks. See https://github.com/clontarfx/zabbix-template-oxidized for more information.</description> <groups> <group> <name>Templates</name> </group> </groups> <applications> <application> <name>Oxidized Backup Status</name> </application> <application> <name>Oxidized Information</name> </application> </applications> <items> <item> <name>Backup Time</name> <type>TRAP</type> <key>oxidized.datetime</key> <delay>0</delay> <units>unixtime</units> <applications> <application> <name>Oxidized Backup Status</name> </application> </applications> </item> <item> <name>Backup Status</name> <type>TRAP</type> <key>oxidized.status</key> <delay>0</delay> <applications> <application> <name>Oxidized Backup Status</name> </application> </applications> </item> <item> <name>Event</name> <type>TRAP</type> <key>OX_EVENT</key> <delay>0</delay> <trends>0</trends> <value_type>TEXT</value_type> <applications> <application> <name>Oxidized Information</name> </application> </applications> </item> <item> <name>Job Status</name> <type>TRAP</type> <key>OX_JOB_STATUS</key> <delay>0</delay> <trends>0</trends> <value_type>TEXT</value_type> <applications> <application> <name>Oxidized Information</name> </application> </applications> </item> <item> <name>Job Runtime</name> <type>TRAP</type> <key>OX_JOB_TIME</key> <delay>0</delay> <value_type>FLOAT</value_type> <units>s</units> <applications> <application> <name>Oxidized Information</name> </application> </applications> </item> <item> <name>Node IP</name> <type>TRAP</type> <key>OX_NODE_IP</key> <delay>0</delay> <trends>0</trends> <value_type>TEXT</value_type> <inventory_link>OOB_IP</inventory_link> <applications> <application> <name>Oxidized Information</name> </application> </applications> </item> <item> <name>Node Model</name> <type>TRAP</type> <key>OX_NODE_MODEL</key> <delay>0</delay> <trends>0</trends> <value_type>TEXT</value_type> <applications> <application> <name>Oxidized Information</name> </application> </applications> </item> <item> <name>Node Name</name> <type>TRAP</type> <key>OX_NODE_NAME</key> <delay>0</delay> <trends>0</trends> <value_type>TEXT</value_type> <applications> <application> <name>Oxidized Information</name> </application> </applications> </item> </items> <macros> <macro> <macro>{$OXIDIZED_AGE_WARNING}</macro> <value>24h</value> </macro> <macro> <macro>{$OXIDIZED_RUNTIME_SLOW}</macro> <value>60</value> </macro> </macros> </template> </templates> <triggers> <trigger> <expression>{Template Application - Oxidized:OX_NODE_NAME.last()}=0 or {Template Application - Oxidized:oxidized.status.last(#1)}=1</expression> <recovery_mode>NONE</recovery_mode> <name>Oxidized {ITEM.VALUE} Configuration Backup Failed</name> <priority>WARNING</priority> <type>MULTIPLE</type> <manual_close>YES</manual_close> </trigger> <trigger> <expression>{Template Application - Oxidized:OX_NODE_NAME.last()}=0 or {Template Application - Oxidized:oxidized.status.last(#1)}=2</expression> <recovery_mode>NONE</recovery_mode> <name>Oxidized {ITEM.VALUE} Configuration Changed</name> <priority>INFO</priority> <description>Oxidized has reported that the backup for {HOST.NAME} ({HOST.IP}) has failed. The last failure reason was {{HOST.HOST}:OX_REASON.last()}.</description> <type>MULTIPLE</type> <manual_close>YES</manual_close> </trigger> </triggers> </zabbix_export> |
参考:
https://cloud.tencent.com/developer/article/1657025
https://github.com/clontarfx/zabbix-template-oxidized
https://github.com/ytti/oxidized/blob/master/docs/Hooks.md
https://www.opscaff.com/2018/04/23/oxidized-%E6%9C%80%E5%A5%BD%E7%94%A8%E7%9A%84%E7%BD%91%E7%BB%9C%E8%AE%BE%E5%A4%87%E5%A4%87%E4%BB%BD%E7%B3%BB%E7%BB%9F%E4%BA%8C/
尽管不知道干啥的,还是来顶一下