[ZBXNEXT-5183] Allow simple triggers under item attribute in export files Created: 2019 Apr 17 Updated: 2024 Apr 10 Resolved: 2019 Jun 21 |
|
Status: | Closed |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | API (A) |
Affects Version/s: | None |
Fix Version/s: | 4.4.0alpha1, 4.4 (plan) |
Type: | New Feature Request | Priority: | Major |
Reporter: | Rostislav Palivoda | Assignee: | Martins Valkovskis |
Resolution: | Fixed | Votes: | 1 |
Labels: | Import/Export, triggers | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: | subissue-3.xml zn5183.patch |
Team: | Team D |
Sprint: | Sprint 51 (Apr 2019), Sprint 52 (May 2019), Sprint 53 (Jun 2019) |
Story Points: | 5 |
Description |
Comments |
Comment by richlv [ 2019 Apr 17 ] |
While it can be sometimes useful to see which items have triggers defined against them in the XML, that might not be a justified rationale for changing the export format. The use case of "I want to see clearly what triggers are defined for each item and edit them in a text editor if needed" would still not be solved, as they could not clearly see any trigger that would reference more than one item. Perhaps the functional goal would be better achieved by ways to display and edit the XML files (assuming editing templates in the UI is not deemed easy enough, which might indicate a need for usability improvements there). One such way could be a solution to summarise Zabbix export XML contents, here's a quick'n'dirty hack to list items with their corresponding triggers: template-stats.pl use strict; use warnings; use XML::LibXML; my $dom = XML::LibXML->load_xml( location => $ARGV[0], ); my %triggers; foreach my $trigger ($dom->findnodes('/zabbix_export/triggers/trigger')) { $triggers{$trigger->findvalue('expression')} = $trigger->findvalue('name'); } foreach my $template ($dom->findnodes('/zabbix_export/templates/template')) { my $templatename = $template->findvalue('./template'); print "$templatename\n"; foreach my $item ($template->findnodes('./items/item')) { my $name = $item->findvalue('name'); my $key = $item->findvalue('key'); print "\t$name - $key\n"; my (@itemtriggers) = grep {$_ =~ "\Q$templatename:$key.\E" } keys %triggers; foreach my $expression (@itemtriggers) { print "\t\t$triggers{$expression} - $expression\n"; } } } The output would look like this: > perl template-stats.pl zbx_export_templates-linux.xml HS Template OS Linux Maximum number of opened files - kernel.maxfiles Configured max number of opened files is too low on {HOST.NAME} - {HS Template OS Linux:kernel.maxfiles.last(0)}<1024 Maximum number of processes - kernel.maxproc Configured max number of processes is too low on {HOST.NAME} - {HS Template OS Linux:kernel.maxproc.last(0)}<256 Memory used by sssd_nss - proc.mem[sssd_nss] Memory usage of sssd_nss suspiciously high - {HS Template OS Linux:proc.mem[sssd_nss].avg(5m)}>400M Number of running processes - proc.num[,,run] Too many processes running on {HOST.NAME} - {HS Template OS Linux:proc.num[,,run].avg(5m)}>30 Count of $1 processes running as $2 - proc.num[java,root] There are java processes running as root - {HS Template OS Linux:proc.num[java,root].max(600)}>0 Number of processes - proc.num[] Too many processes on {HOST.NAME} - {HS Template OS Linux:proc.num[].avg(5m)}>{$TRG_PROCNUM_THRESH} Host boot time - system.boottime Interrupts per second - system.cpu.intr Processor load (1 min average per core) - system.cpu.load[percpu,avg1] Processor load is too high on {HOST.NAME} - {HS Template OS Linux:system.cpu.load[percpu,avg1].avg({$TRG_CPULOAD_PERIOD})}>{$TRG_CPULOAD_THRESH} Active Zabbix agent is unreachable for 10 minutes - {HS Template OS Linux:system.cpu.load[percpu,avg1].nodata(10m)}=1 Processor load (5 min average per core) - system.cpu.load[percpu,avg5] Processor load (15 min average per core) - system.cpu.load[percpu,avg15] Context switches per second - system.cpu.switches CPU $2 time - system.cpu.util[,idle] CPU $2 time - system.cpu.util[,interrupt] CPU $2 time - system.cpu.util[,iowait] Disk I/O is overloaded on {HOST.NAME} - {HS Template OS Linux:system.cpu.util[,iowait].avg(5m)}>20 CPU $2 time - system.cpu.util[,nice] CPU $2 time - system.cpu.util[,softirq] CPU $2 time - system.cpu.util[,steal] CPU $2 time - system.cpu.util[,system] CPU $2 time - system.cpu.util[,user] Host name - system.hostname Hostname was changed on {HOST.NAME} - {HS Template OS Linux:system.hostname.diff(0)}>0 Host local time - system.localtime Permissions of / - system.run[stat -c "%a" "/"] Permissions on / unexpected - {HS Template OS Linux:system.run[stat -c "%a" "/"].last()}<>{$PERMISSIONS_ROOT} Permissions of /home - system.run[stat -c "%a" "/home"] Permissions on /home unexpected - {HS Template OS Linux:system.run[stat -c "%a" "/home"].last()}<>755 Owner of / - system.run[stat -c "%u" "/"] Owner of / not root - {HS Template OS Linux:system.run[stat -c "%u" "/"].last()}<>0 Owner of /home - system.run[stat -c "%u" "/home"] Owner of /home not root - {HS Template OS Linux:system.run[stat -c "%u" "/home"].last()}<>0 Free swap space - system.swap.size[,free] Free swap space in % - system.swap.size[,pfree] Lack of free swap space on {HOST.NAME} - {HS Template OS Linux:system.swap.size[,pfree].last(0)}<50 Total swap space - system.swap.size[,total] System information - system.uname Host information was changed on {HOST.NAME} - {HS Template OS Linux:system.uname.diff(0)}>0 System uptime - system.uptime {HOST.NAME} has just been restarted - {HS Template OS Linux:system.uptime.change(0)}<0 Number of logged in users - system.users.num Checksum of $1 - vfs.file.cksum[/etc/passwd] /etc/passwd has been changed on {HOST.NAME} - {HS Template OS Linux:vfs.file.cksum[/etc/passwd].diff(0)}>0 Last modification time of logrotate status file - vfs.file.time[/var/lib/logrotate.status] Logrotate status file not updated for two days - {HS Template OS Linux:vfs.file.time[/var/lib/logrotate.status].fuzzytime(2d)}=0 Available memory - vm.memory.size[available] Lack of available memory on server {HOST.NAME} - {HS Template OS Linux:vm.memory.size[available].last(0)}<20M Total memory - vm.memory.size[total] |
Comment by Glebs Ivanovskis [ 2019 Apr 19 ] |
I agree with richlv, XML files are for programs. Proposed changes make these programs more complicated. For "Business Use Cases" there is an open source enterprise level GUI tool to edit templates. It's called Zabbix frontend. |
Comment by Andrejs Griščenko [ 2019 May 16 ] |
Implemented in development branch feature/ |
Comment by Andrejs Griščenko [ 2019 Jun 13 ] |
Comment by Alexander Vladishev [ 2019 Jun 20 ] |
Updated documentation: |
Comment by richlv [ 2019 Jun 20 ] |
Thank you for listing this in the upgrade notes. While the what'snew section does not explicitly mention formats, it does show an example of XML. |
Comment by Martins Valkovskis [ 2019 Jun 21 ] |
Yes, now both XML and JSON are mentioned in 'what's new' and the upgrade notes. Thanks. |