Zabbix: Difference between revisions
No edit summary Tag: visualeditor |
|||
| (40 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
==Add Client== | |||
Optional: Test if Zabbix Port (10050/tcp) is open (Zabbix Server to Client): | |||
zabbix_get -s <IP / DNS> -p 10050 -k "agent.ping" | |||
===Install Zabbix Agent or Zabbix Agent 2 === | |||
* Make sure, Zabbix Agent (1) is not installed: (https://manage.accuwebhosting.com/knowledgebase/2983/How-to-removeoruninstall-Zabbix-Agent-from-Windows-and-CentOS.html#:~:text=zabbix_agentd.exe%20%2D%2Duninstall,Zabbix%20agent%20from%20Zabbix%20Server) | |||
* Optional: Test if Zabbix Port (10050/tcp) is open (Client to Zabbix Server): | |||
nc -zvw3 zabbix 10050 | |||
* Download the right Zabbix Agent on/for the Client Machine: https://www.zabbix.com/de/download_agents and install. | |||
* Configure Zabbix Agent (Unix (like): "/etc/zabbix/zabbix_agent2.conf"; Windows (like): \Program Files\zabbix\zabbix_agentd.conf) | |||
* Set Configuration options: | |||
** Server=zabbix | |||
** ServerActive=zabbix | |||
**[[#Host_name|Hostname]]={Hostname configured in Zabbix Server} | |||
**[[#Tags|HostMetadata]] | |||
* Restart Zabbix Service (e.g. service zabbix-agent2 restart) and debug with logfile (like): cat /var/log/zabbix/zabbix_agent2.log or \Program Files\zabbix2\zabbix_agent2.log | |||
==Maintenance== | ==Maintenance== | ||
Query most triggered items | Query most triggered items | ||
SELECT DISTINCT `history_uint`.`itemid`, count(`history_uint`.`itemid`) AS CountOf, `items`.`itemid`, `items`.`name` FROM `history_uint` LEFT JOIN `items` ON `history_uint`.`itemid` = `items`.`itemid` GROUP BY `history_uint`.`itemid` ORDER BY CountOf DESC | |||
SELECT DISTINCT `history_uint`.`itemid`, count(`history_uint`.`itemid`) AS CountOf, `items`.`itemid`, `items`.`name` FROM `history_uint` LEFT JOIN `items` ON `history_uint`.`itemid` = `items`.`itemid` GROUP BY `history_uint`.`itemid` ORDER BY CountOf DESC | |||
< | |||
login to the MySQL. | |||
Select your database (Which is used for zabbix) | |||
Run below commands (Please change the interval day as your requirement) | |||
DELETE FROM history_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY)); | |||
DELETE FROM history WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY)); | |||
DELETE FROM trends_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY)); | |||
DELETE FROM trends WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY)); | |||
DELETE FROM events WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY)); | |||
DELETE FROM alerts WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY)); | |||
In my case I am keeping only last 35 Days data, so change as per your requirement. | |||
==Configuration== | ==Configuration== | ||
=== | === Tags === | ||
The clients can be configured with tags in the zabbix_agentd.conf (for Agent) or zabbix_agent2.conf (for Agent 2), so the clients will be assigned to the right Host Group and Template Group. To do so, you need to add the predefined tags under HostMetadata. | |||
Example: | |||
/etc/zabbix/zabbix_agentd.conf (Zabbix Agent) | |||
HostMetadata=win,vfx,psl,dus | |||
<br />OR | |||
/etc/zabbix/zabbix_agent2.conf (Zabbix Agent 2) | |||
HostMetadata=linux,websrv,psl,dus,247 | |||
the following tags are predefined: | |||
{| class="wikitable" | |||
!Tag | |||
!Meaning | |||
|- | |||
|win | |||
|Windows | |||
|- | |||
|linux | |||
|Linux | |||
|- | |||
|psl | |||
|Company Parasol Island | |||
|- | |||
|capm | |||
|Company Capture Media | |||
|- | |||
|dus | |||
|Location Düsseldorf | |||
|- | |||
|ber | |||
|Location Berlin | |||
|- | |||
|fs75 | |||
|Florastr. 75 | |||
|- | |||
|rds26 | |||
|Rudi-Dutschke-Straße 26 | |||
|- | |||
|rs64 | |||
|Rethelstraße 64 | |||
|- | |||
|env | |||
|Type Environmental | |||
|- | |||
|websrv | |||
|Type Webserver | |||
|- | |||
|winsrv | |||
|Type Windows Server | |||
|- | |||
|erp | |||
|Type ERP | |||
|- | |||
|firewall | |||
|Type Firewall | |||
|- | |||
|hotspot | |||
|Type Hotspot | |||
|- | |||
|hypervisor | |||
|Type Hypervisor | |||
|- | |||
|network | |||
|Type Network | |||
|- | |||
|render | |||
|Type Rendernode | |||
|- | |||
|storage | |||
|Type Storage | |||
|- | |||
|switch | |||
|Type Switch | |||
|- | |||
|vfx | |||
|Type VFX Workstation | |||
|- | |||
|vm | |||
|Type Virtual Machine | |||
|- | |||
|printer | |||
|Type Printer | |||
|- | |||
|cisco | |||
|Vendor Cisco | |||
|- | |||
|hp | |||
|Vendor HP | |||
|- | |||
|ibm | |||
|Vendor IBM | |||
|- | |||
|juniper | |||
|Vendor Juniper | |||
|- | |||
|105 | |||
|Availability 10/5 | |||
|- | |||
|247 | |||
|Availability 24/7 | |||
|- | |||
|test | |||
|Test Group | |||
|- | |||
|apache2 | |||
|Apache Service | |||
|- | |||
|mariadb | |||
|MariaDB Service | |||
|} | |||
===Location=== | |||
SNMP Devices usually offer to configure a location (OID: .1.3.6.1.2.1.1.6.0). Our Location Pattern is: | |||
{country}.{city}.{location}.{floor}.{...drilldown to the device location}. Example: | |||
de.dus.fs75.gf.kitchen | |||
=== | ==Monitoring== | ||
===SQL=== | |||
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent2 | |||
* | '''On the Host (Zabbix Agent installed)''' | ||
* | * mysql | ||
* | <syntaxhighlight lang="mysql"> | ||
* | CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>'; | ||
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%'; | |||
</syntaxhighlight> | |||
* configure "/etc/zabbix/zabbix_agent2.conf" | |||
** Plugins.Mysql.Sessions.mysql01.Uri=unix:/var/run/mysqld/mysqld.sock | |||
** Plugins.Mysql.Sessions.mysql01.User=zbx_monitor | |||
** Plugins.Mysql.Sessions.mysql01.Password=b1RhaAh43ZALR | |||
* service zabbix-agent2 restart | |||
'''In Zabbix''' | |||
= | * Marco: {$MYSQL.DSN} = mysql01 | ||
=== | ===Apache2=== | ||
Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/apache_agent | |||
'''On the Host (Zabbix Agent installed)''' | |||
# a2enmod status | |||
= | # Create "/etc/apache2/conf-available/zabbix.conf", e.g. "nano /etc/apache2/conf-available/zabbix.conf" | ||
<syntaxhighlight lang="apache"> | |||
<Location "/server-status"> | |||
SetHandler server-status | |||
Require host localhost | |||
Require ip 127.0.0.1 | |||
Require ip 192.168 | |||
Require ip 10 | |||
</Location> | |||
</syntaxhighlight> | |||
# a2enconf zabbix | |||
# service apache2 restart | |||
'''In Zabbix''' | |||
# Enable Template: "Template App Apache by Zabbix agent" | |||
=== Webseiten === | |||
{| class="wikitable" | |||
|+ '''Zabbix Host''' | |||
|- | |||
| Host name || www.irgendwas.de | |||
|- | |||
| Templates || | |||
Website certificate by Zabbix agent 2<br> | |||
Website Check by Parasol | |||
|- | |||
| Host groups || | |||
Web SSL<br> | |||
External/ Web<br> | |||
Websites | |||
|- | |||
| Interfaces || | |||
Agent 10.1.10.52 | |||
|- | |||
| Macros || | |||
{$CERT.WEBSITE.HOSTNAME} = www.irgendwas.de<br> | |||
{$WEBSITE.CHECK.HOSTADDRESS} = <nowiki>https://www.irgendwas.de</nowiki> | |||
|- | |||
| Tags || | |||
contact: webmaster | |||
|} | |||
=== | ==Snippets== | ||
https:// | ===RegEx Replace Text Output to Int=== | ||
https://www.schatenseite.de/2018/04/05/zabbix-item-preprocessing-und-regular-expressions/ | |||
(.*) > \1:Off=0:On=1 | |||
(On|Off)(?=.*:\1=(\d)) > \2 | |||
[[File:Screenshot 2020-03-09 at 08.48.50.png|800px]] | |||
=Customization= | |||
==Graphs== | |||
Incoming/Rx: Green (00FF00)<br> | |||
OutgoingTx: Blue (0000FF) | |||
==All templates/ Generic SNMP== | |||
{| | |||
|+ Caption text | |||
|- | |||
! Header text !! Header text !! Header text | |||
|- | |||
| System OS (Full details) || system.os.details.full || iso.3.6.1.2.1.1.1.0 | |||
|- | |||
| Example || Example || Example | |||
|- | |||
| Example || Example || Example | |||
|} | |||
=Deprecared= | |||
===Host name=== | |||
{psl}.{ber|dus}.{ns125|rds26}.{vh|hh|fb|hh|...}.{ug|eg|1og|...}.{kind e.g. vserver}.{machine name, e.g. pslsrv32}. Example: | |||
psl.dus.ns125.fb.1ug.vserver.pslsrv15 | |||
===Visible name=== | |||
{PSL} | {BER|DUS} | {NS125|RDS26} | {VH|HH|FB|HH|...} | {UG|EG|1OG|...} | {kind e.g. vServer} | {machine name, e.g. PSLSRV15} ({Short Description}). Example: | |||
PSL | DUS | NS125 | FB | 1UG | vServer | PSLSRV15 (Preview Webserver) | |||
===Hostgroups=== | |||
* By Type, e.g. "HGRP | PSL | TYPE | WEBSERVER" , "HGRP | PSL | TYPE | PRINTER" | |||
* By Logical Group, e.g. "HGRP | PSL | LOGIC | DUS" , "HGRP | PSL | LOGIC | BER" | |||
* By Purpose, e.g. "HGRP | PSL | TYPE | RENDERNODE" , "HGRP | PSL | TYPE | NETWORK" | |||
* By Availability Level, e.g. "HGRP | PSL | AVAILABILITY | 24/7" , "HGRP | CAPM | AVAILABILITY | 10/5" | |||
* By Vendor, e.g. "HGRP | PSL | VENDOR | OKI" , "HGRP | PSL | VENDOR | HP" | |||
=== Template Groups/Template === | |||
* The Template Group is a group of multiple templates that are linked to the Template Group. | |||
* The Template has defined Applications, Trigger, Items, Discovery, Dashboards and Graphs. | |||
* For Example: TGRP | WINDOWS has the following templates linked | |||
{| class="wikitable" | |||
|<nowiki>TPL | WINDOWS | CPU</nowiki> | |||
|- | |||
|<nowiki>TPL | WINDOWS | FILESYSTEMS</nowiki> | |||
|- | |||
|<nowiki>TPL | WINDOWS | GENERIC</nowiki> | |||
|- | |||
|<nowiki>TPL | WINDOWS | MEMORY</nowiki> | |||
|- | |||
|<nowiki>TPL | WINDOWS | NETWORK</nowiki> | |||
|- | |||
|<nowiki>TPL | WINDOWS | PHYSICAL DISKS</nowiki> | |||
|- | |||
|<nowiki>TPL | WINDOWS | SERVICES</nowiki> | |||
|- | |||
|<nowiki>TPL | ZABBIX AGENT| PASSIVE</nowiki> | |||
|} | |||
https://blog.zabbix.com/support-of-whitelists-and-blacklists-for-metrics-on-agent-side/11878/ | |||
Latest revision as of 08:54, 16 July 2025
Add Client
[edit]Optional: Test if Zabbix Port (10050/tcp) is open (Zabbix Server to Client):
zabbix_get -s <IP / DNS> -p 10050 -k "agent.ping"
Install Zabbix Agent or Zabbix Agent 2
[edit]- Make sure, Zabbix Agent (1) is not installed: (https://manage.accuwebhosting.com/knowledgebase/2983/How-to-removeoruninstall-Zabbix-Agent-from-Windows-and-CentOS.html#:~:text=zabbix_agentd.exe%20%2D%2Duninstall,Zabbix%20agent%20from%20Zabbix%20Server)
- Optional: Test if Zabbix Port (10050/tcp) is open (Client to Zabbix Server):
nc -zvw3 zabbix 10050
- Download the right Zabbix Agent on/for the Client Machine: https://www.zabbix.com/de/download_agents and install.
- Configure Zabbix Agent (Unix (like): "/etc/zabbix/zabbix_agent2.conf"; Windows (like): \Program Files\zabbix\zabbix_agentd.conf)
- Set Configuration options:
- Server=zabbix
- ServerActive=zabbix
- Hostname={Hostname configured in Zabbix Server}
- HostMetadata
- Restart Zabbix Service (e.g. service zabbix-agent2 restart) and debug with logfile (like): cat /var/log/zabbix/zabbix_agent2.log or \Program Files\zabbix2\zabbix_agent2.log
Maintenance
[edit]Query most triggered items
SELECT DISTINCT `history_uint`.`itemid`, count(`history_uint`.`itemid`) AS CountOf, `items`.`itemid`, `items`.`name` FROM `history_uint` LEFT JOIN `items` ON `history_uint`.`itemid` = `items`.`itemid` GROUP BY `history_uint`.`itemid` ORDER BY CountOf DESC
login to the MySQL.
Select your database (Which is used for zabbix)
Run below commands (Please change the interval day as your requirement)
DELETE FROM history_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY));
DELETE FROM history WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY));
DELETE FROM trends_uint WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY));
DELETE FROM trends WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY));
DELETE FROM events WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY));
DELETE FROM alerts WHERE clock < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 35 DAY));
In my case I am keeping only last 35 Days data, so change as per your requirement.
Configuration
[edit]Tags
[edit]The clients can be configured with tags in the zabbix_agentd.conf (for Agent) or zabbix_agent2.conf (for Agent 2), so the clients will be assigned to the right Host Group and Template Group. To do so, you need to add the predefined tags under HostMetadata.
Example:
/etc/zabbix/zabbix_agentd.conf (Zabbix Agent) HostMetadata=win,vfx,psl,dus
OR /etc/zabbix/zabbix_agent2.conf (Zabbix Agent 2) HostMetadata=linux,websrv,psl,dus,247
the following tags are predefined:
| Tag | Meaning |
|---|---|
| win | Windows |
| linux | Linux |
| psl | Company Parasol Island |
| capm | Company Capture Media |
| dus | Location Düsseldorf |
| ber | Location Berlin |
| fs75 | Florastr. 75 |
| rds26 | Rudi-Dutschke-Straße 26 |
| rs64 | Rethelstraße 64 |
| env | Type Environmental |
| websrv | Type Webserver |
| winsrv | Type Windows Server |
| erp | Type ERP |
| firewall | Type Firewall |
| hotspot | Type Hotspot |
| hypervisor | Type Hypervisor |
| network | Type Network |
| render | Type Rendernode |
| storage | Type Storage |
| switch | Type Switch |
| vfx | Type VFX Workstation |
| vm | Type Virtual Machine |
| printer | Type Printer |
| cisco | Vendor Cisco |
| hp | Vendor HP |
| ibm | Vendor IBM |
| juniper | Vendor Juniper |
| 105 | Availability 10/5 |
| 247 | Availability 24/7 |
| test | Test Group |
| apache2 | Apache Service |
| mariadb | MariaDB Service |
Location
[edit]SNMP Devices usually offer to configure a location (OID: .1.3.6.1.2.1.1.6.0). Our Location Pattern is:
{country}.{city}.{location}.{floor}.{...drilldown to the device location}. Example:
de.dus.fs75.gf.kitchen
Monitoring
[edit]SQL
[edit]Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent2
On the Host (Zabbix Agent installed)
- mysql
<syntaxhighlight lang="mysql"> CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>'; GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%'; </syntaxhighlight>
- configure "/etc/zabbix/zabbix_agent2.conf"
- Plugins.Mysql.Sessions.mysql01.Uri=unix:/var/run/mysqld/mysqld.sock
- Plugins.Mysql.Sessions.mysql01.User=zbx_monitor
- Plugins.Mysql.Sessions.mysql01.Password=b1RhaAh43ZALR
- service zabbix-agent2 restart
In Zabbix
- Marco: {$MYSQL.DSN} = mysql01
Apache2
[edit]Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/apache_agent
On the Host (Zabbix Agent installed)
- a2enmod status
- Create "/etc/apache2/conf-available/zabbix.conf", e.g. "nano /etc/apache2/conf-available/zabbix.conf"
<syntaxhighlight lang="apache"> <Location "/server-status">
SetHandler server-status
Require host localhost Require ip 127.0.0.1 Require ip 192.168 Require ip 10
</Location> </syntaxhighlight>
- a2enconf zabbix
- service apache2 restart
In Zabbix
- Enable Template: "Template App Apache by Zabbix agent"
Webseiten
[edit]| Host name | www.irgendwas.de |
| Templates |
Website certificate by Zabbix agent 2 |
| Host groups |
Web SSL |
| Interfaces |
Agent 10.1.10.52 |
| Macros |
{$CERT.WEBSITE.HOSTNAME} = www.irgendwas.de |
| Tags |
contact: webmaster |
Snippets
[edit]RegEx Replace Text Output to Int
[edit]https://www.schatenseite.de/2018/04/05/zabbix-item-preprocessing-und-regular-expressions/
(.*) > \1:Off=0:On=1 (On|Off)(?=.*:\1=(\d)) > \2
Error creating thumbnail: File missing
Customization
[edit]Graphs
[edit]Incoming/Rx: Green (00FF00)
OutgoingTx: Blue (0000FF)
All templates/ Generic SNMP
[edit]| Header text | Header text | Header text |
|---|---|---|
| System OS (Full details) | system.os.details.full | iso.3.6.1.2.1.1.1.0 |
| Example | Example | Example |
| Example | Example | Example |
Deprecared
[edit]Host name
[edit]{psl}.{ber|dus}.{ns125|rds26}.{vh|hh|fb|hh|...}.{ug|eg|1og|...}.{kind e.g. vserver}.{machine name, e.g. pslsrv32}. Example:
psl.dus.ns125.fb.1ug.vserver.pslsrv15
Visible name
[edit]{PSL} | {BER|DUS} | {NS125|RDS26} | {VH|HH|FB|HH|...} | {UG|EG|1OG|...} | {kind e.g. vServer} | {machine name, e.g. PSLSRV15} ({Short Description}). Example:
PSL | DUS | NS125 | FB | 1UG | vServer | PSLSRV15 (Preview Webserver)
Hostgroups
[edit]- By Type, e.g. "HGRP | PSL | TYPE | WEBSERVER" , "HGRP | PSL | TYPE | PRINTER"
- By Logical Group, e.g. "HGRP | PSL | LOGIC | DUS" , "HGRP | PSL | LOGIC | BER"
- By Purpose, e.g. "HGRP | PSL | TYPE | RENDERNODE" , "HGRP | PSL | TYPE | NETWORK"
- By Availability Level, e.g. "HGRP | PSL | AVAILABILITY | 24/7" , "HGRP | CAPM | AVAILABILITY | 10/5"
- By Vendor, e.g. "HGRP | PSL | VENDOR | OKI" , "HGRP | PSL | VENDOR | HP"
Template Groups/Template
[edit]- The Template Group is a group of multiple templates that are linked to the Template Group.
- The Template has defined Applications, Trigger, Items, Discovery, Dashboards and Graphs.
- For Example: TGRP | WINDOWS has the following templates linked
| TPL | WINDOWS | CPU |
| TPL | WINDOWS | FILESYSTEMS |
| TPL | WINDOWS | GENERIC |
| TPL | WINDOWS | MEMORY |
| TPL | WINDOWS | NETWORK |
| TPL | WINDOWS | PHYSICAL DISKS |
| TPL | WINDOWS | SERVICES |
| TPL | ZABBIX AGENT| PASSIVE |
https://blog.zabbix.com/support-of-whitelists-and-blacklists-for-metrics-on-agent-side/11878/