Devenv: use zabbix LTS version 5.0
This commit is contained in:
18
devenv/zabbix50/bootstrap/Dockerfile
Normal file
18
devenv/zabbix50/bootstrap/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM python:3
|
||||
|
||||
ENV ZBX_API_URL=http://zabbix-web
|
||||
ENV ZBX_API_USER="Admin"
|
||||
ENV ZBX_API_PASSWORD="zabbix"
|
||||
ENV ZBX_CONFIG="zbx_export_hosts_5.xml"
|
||||
ENV ZBX_BOOTSTRAP_SCRIPT="bootstrap_config.py"
|
||||
|
||||
RUN pip install pyzabbix
|
||||
|
||||
WORKDIR /
|
||||
|
||||
ADD ./${ZBX_CONFIG} /${ZBX_CONFIG}
|
||||
ADD ./bootstrap_config.py /bootstrap_config.py
|
||||
# RUN cp ./${ZBX_CONFIG} /${ZBX_CONFIG}
|
||||
|
||||
# Run bootstrap_config.py when the container launches
|
||||
CMD ["python", "/bootstrap_config.py"]
|
||||
93
devenv/zabbix50/bootstrap/bootstrap_config.py
Normal file
93
devenv/zabbix50/bootstrap/bootstrap_config.py
Normal file
@@ -0,0 +1,93 @@
|
||||
import os
|
||||
from time import sleep
|
||||
from pyzabbix import ZabbixAPI, ZabbixAPIException
|
||||
|
||||
zabbix_url = os.environ['ZBX_API_URL']
|
||||
zabbix_user = os.environ['ZBX_API_USER']
|
||||
zabbix_password = os.environ['ZBX_API_PASSWORD']
|
||||
print(zabbix_url, zabbix_user, zabbix_password)
|
||||
|
||||
zapi = ZabbixAPI(zabbix_url, timeout=5)
|
||||
|
||||
for i in range(10):
|
||||
print("Trying to connected to Zabbix API %s" % zabbix_url)
|
||||
try:
|
||||
zapi.login(zabbix_user, zabbix_password)
|
||||
print("Connected to Zabbix API Version %s" % zapi.api_version())
|
||||
break
|
||||
except ZabbixAPIException as e:
|
||||
print(e)
|
||||
sleep(10)
|
||||
except:
|
||||
print("Waiting")
|
||||
sleep(10)
|
||||
|
||||
|
||||
zapi.timeout = 600
|
||||
|
||||
config_path = os.environ['ZBX_CONFIG']
|
||||
import_rules = {
|
||||
'applications': {
|
||||
'createMissing': True,
|
||||
},
|
||||
'discoveryRules': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
'graphs': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
'groups': {
|
||||
'createMissing': True
|
||||
},
|
||||
'hosts': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
'images': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
'items': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
'maps': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
# 'screens': {
|
||||
# 'createMissing': True,
|
||||
# 'updateExisting': True
|
||||
# },
|
||||
'templateLinkage': {
|
||||
'createMissing': True,
|
||||
},
|
||||
'templates': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
# 'templateScreens': {
|
||||
# 'createMissing': True,
|
||||
# 'updateExisting': True
|
||||
# },
|
||||
'triggers': {
|
||||
'createMissing': True,
|
||||
'updateExisting': True
|
||||
},
|
||||
}
|
||||
|
||||
print("Importing Zabbix config from %s" % config_path)
|
||||
with open(config_path, 'r') as f:
|
||||
config = f.read()
|
||||
|
||||
try:
|
||||
# https://github.com/lukecyca/pyzabbix/issues/62
|
||||
import_result = zapi.confimport("xml", config, import_rules)
|
||||
print(import_result)
|
||||
except ZabbixAPIException as e:
|
||||
print(e)
|
||||
|
||||
for h in zapi.host.get(output="extend"):
|
||||
print(h['name'])
|
||||
407
devenv/zabbix50/bootstrap/zbx_export_hosts_5.xml
Normal file
407
devenv/zabbix50/bootstrap/zbx_export_hosts_5.xml
Normal file
@@ -0,0 +1,407 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<zabbix_export>
|
||||
<version>5.0</version>
|
||||
<date>2021-09-10T12:42:13Z</date>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Backend</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Database</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Frontend</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Linux servers</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Zabbix servers</name>
|
||||
</group>
|
||||
</groups>
|
||||
<hosts>
|
||||
<host>
|
||||
<host>backend01</host>
|
||||
<name>backend01</name>
|
||||
<templates>
|
||||
<template>
|
||||
<name>Template ZAS Agent</name>
|
||||
</template>
|
||||
</templates>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Backend</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Linux servers</name>
|
||||
</group>
|
||||
</groups>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<useip>NO</useip>
|
||||
<dns>zas_backend_01</dns>
|
||||
<interface_ref>if1</interface_ref>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<inventory_mode>DISABLED</inventory_mode>
|
||||
</host>
|
||||
<host>
|
||||
<host>backend02</host>
|
||||
<name>backend02</name>
|
||||
<templates>
|
||||
<template>
|
||||
<name>Template ZAS Agent</name>
|
||||
</template>
|
||||
</templates>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Backend</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Linux servers</name>
|
||||
</group>
|
||||
</groups>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<useip>NO</useip>
|
||||
<dns>zas_backend_02</dns>
|
||||
<interface_ref>if1</interface_ref>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<inventory_mode>DISABLED</inventory_mode>
|
||||
</host>
|
||||
<host>
|
||||
<host>frontend01</host>
|
||||
<name>frontend01</name>
|
||||
<templates>
|
||||
<template>
|
||||
<name>Template ZAS Agent</name>
|
||||
</template>
|
||||
</templates>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Frontend</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Linux servers</name>
|
||||
</group>
|
||||
</groups>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<useip>NO</useip>
|
||||
<dns>zas_frontend_01</dns>
|
||||
<interface_ref>if1</interface_ref>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<inventory_mode>DISABLED</inventory_mode>
|
||||
</host>
|
||||
<host>
|
||||
<host>frontend02</host>
|
||||
<name>frontend02</name>
|
||||
<templates>
|
||||
<template>
|
||||
<name>Template ZAS Agent</name>
|
||||
</template>
|
||||
</templates>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Frontend</name>
|
||||
</group>
|
||||
<group>
|
||||
<name>Linux servers</name>
|
||||
</group>
|
||||
</groups>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<useip>NO</useip>
|
||||
<dns>zas_frontend_02</dns>
|
||||
<interface_ref>if1</interface_ref>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<inventory_mode>DISABLED</inventory_mode>
|
||||
</host>
|
||||
<host>
|
||||
<host>Zabbix server</host>
|
||||
<name>Zabbix server</name>
|
||||
<templates>
|
||||
<template>
|
||||
<name>Template OS Linux by Zabbix agent</name>
|
||||
</template>
|
||||
<template>
|
||||
<name>Template App Zabbix Server</name>
|
||||
</template>
|
||||
</templates>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Zabbix servers</name>
|
||||
</group>
|
||||
</groups>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<interface_ref>if1</interface_ref>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<inventory_mode>DISABLED</inventory_mode>
|
||||
</host>
|
||||
</hosts>
|
||||
<templates>
|
||||
<template>
|
||||
<template>Template ZAS Agent</template>
|
||||
<name>Template ZAS Agent</name>
|
||||
<templates>
|
||||
<template>
|
||||
<name>Template App Zabbix Agent</name>
|
||||
</template>
|
||||
</templates>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Templates</name>
|
||||
</group>
|
||||
</groups>
|
||||
<applications>
|
||||
<application>
|
||||
<name>CPU</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Filesystems</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>General</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Memory</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Network interfaces</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>OS</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Performance</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Processes</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Security</name>
|
||||
</application>
|
||||
</applications>
|
||||
<items>
|
||||
<item>
|
||||
<name>Incoming network traffic on eth0</name>
|
||||
<key>net.if.in[eth0]</key>
|
||||
<history>1d</history>
|
||||
<units>bps</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Network interfaces</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
</item>
|
||||
<item>
|
||||
<name>Outgoing network traffic on eth0</name>
|
||||
<key>net.if.out[eth0]</key>
|
||||
<history>1d</history>
|
||||
<units>bps</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Network interfaces</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
</item>
|
||||
<item>
|
||||
<name>Processor load (1 min average per core)</name>
|
||||
<key>system.cpu.load[percpu,avg1]</key>
|
||||
<history>1d</history>
|
||||
<value_type>FLOAT</value_type>
|
||||
<description>The processor load is calculated as system CPU load divided by number of CPU cores.</description>
|
||||
<applications>
|
||||
<application>
|
||||
<name>CPU</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Performance</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
<triggers>
|
||||
<trigger>
|
||||
<expression>{last(0)}>2</expression>
|
||||
<name>Processor load is too high on {HOST.NAME}</name>
|
||||
<priority>WARNING</priority>
|
||||
</trigger>
|
||||
</triggers>
|
||||
</item>
|
||||
<item>
|
||||
<name>Processor load (15 min average per core)</name>
|
||||
<key>system.cpu.load[percpu,avg15]</key>
|
||||
<history>1d</history>
|
||||
<value_type>FLOAT</value_type>
|
||||
<description>The processor load is calculated as system CPU load divided by number of CPU cores.</description>
|
||||
<applications>
|
||||
<application>
|
||||
<name>CPU</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Performance</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
</item>
|
||||
<item>
|
||||
<name>CPU $2 time</name>
|
||||
<key>system.cpu.util[,iowait]</key>
|
||||
<history>1d</history>
|
||||
<value_type>FLOAT</value_type>
|
||||
<units>%</units>
|
||||
<description>Amount of time the CPU has been waiting for I/O to complete.</description>
|
||||
<applications>
|
||||
<application>
|
||||
<name>CPU</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Performance</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
<triggers>
|
||||
<trigger>
|
||||
<expression>{avg(5m)}>20</expression>
|
||||
<name>Disk I/O is overloaded on {HOST.NAME}</name>
|
||||
<priority>WARNING</priority>
|
||||
<description>OS spends significant time waiting for I/O (input/output) operations. It could be indicator of performance issues with storage system.</description>
|
||||
</trigger>
|
||||
</triggers>
|
||||
</item>
|
||||
<item>
|
||||
<name>CPU $2 time</name>
|
||||
<key>system.cpu.util[,system]</key>
|
||||
<history>1d</history>
|
||||
<value_type>FLOAT</value_type>
|
||||
<units>%</units>
|
||||
<description>The time the CPU has spent running the kernel and its processes.</description>
|
||||
<applications>
|
||||
<application>
|
||||
<name>CPU</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Performance</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
</item>
|
||||
<item>
|
||||
<name>CPU $2 time</name>
|
||||
<key>system.cpu.util[,user]</key>
|
||||
<history>1d</history>
|
||||
<value_type>FLOAT</value_type>
|
||||
<units>%</units>
|
||||
<description>The time the CPU has spent running users' processes that are not niced.</description>
|
||||
<applications>
|
||||
<application>
|
||||
<name>CPU</name>
|
||||
</application>
|
||||
<application>
|
||||
<name>Performance</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
</item>
|
||||
</items>
|
||||
</template>
|
||||
<template>
|
||||
<template>Template App Zabbix Agent</template>
|
||||
<name>Template App Zabbix Agent</name>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Templates</name>
|
||||
</group>
|
||||
</groups>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Zabbix agent</name>
|
||||
</application>
|
||||
</applications>
|
||||
<items>
|
||||
<item>
|
||||
<name>Host name of zabbix_agentd running</name>
|
||||
<key>agent.hostname</key>
|
||||
<delay>1h</delay>
|
||||
<history>1w</history>
|
||||
<trends>0</trends>
|
||||
<value_type>CHAR</value_type>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Zabbix agent</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
<triggers>
|
||||
<trigger>
|
||||
<expression>{diff(0)}>0</expression>
|
||||
<name>Host name of zabbix_agentd was changed on {HOST.NAME}</name>
|
||||
<priority>INFO</priority>
|
||||
</trigger>
|
||||
</triggers>
|
||||
</item>
|
||||
<item>
|
||||
<name>Agent ping</name>
|
||||
<key>agent.ping</key>
|
||||
<history>1w</history>
|
||||
<description>The agent always returns 1 for this item. It could be used in combination with nodata() for availability check.</description>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Zabbix agent</name>
|
||||
</application>
|
||||
</applications>
|
||||
<valuemap>
|
||||
<name>Zabbix agent ping status</name>
|
||||
</valuemap>
|
||||
<request_method>POST</request_method>
|
||||
<triggers>
|
||||
<trigger>
|
||||
<expression>{nodata(5m)}=1</expression>
|
||||
<name>Zabbix agent on {HOST.NAME} is unreachable for 5 minutes</name>
|
||||
<priority>AVERAGE</priority>
|
||||
</trigger>
|
||||
</triggers>
|
||||
</item>
|
||||
<item>
|
||||
<name>Version of zabbix_agent(d) running</name>
|
||||
<key>agent.version</key>
|
||||
<delay>1h</delay>
|
||||
<history>1w</history>
|
||||
<trends>0</trends>
|
||||
<value_type>CHAR</value_type>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Zabbix agent</name>
|
||||
</application>
|
||||
</applications>
|
||||
<request_method>POST</request_method>
|
||||
<triggers>
|
||||
<trigger>
|
||||
<expression>{diff(0)}>0</expression>
|
||||
<name>Version of zabbix_agent(d) was changed on {HOST.NAME}</name>
|
||||
<priority>INFO</priority>
|
||||
</trigger>
|
||||
</triggers>
|
||||
</item>
|
||||
</items>
|
||||
</template>
|
||||
</templates>
|
||||
<value_maps>
|
||||
<value_map>
|
||||
<name>Zabbix agent ping status</name>
|
||||
<mappings>
|
||||
<mapping>
|
||||
<value>1</value>
|
||||
<newvalue>Up</newvalue>
|
||||
</mapping>
|
||||
</mappings>
|
||||
</value_map>
|
||||
</value_maps>
|
||||
</zabbix_export>
|
||||
Reference in New Issue
Block a user