See for the official Zabbix site.

Zabbix Templates/SQLs for Official Templates

Jump to: navigation, search

SQL scripts to complement official Zabbix templates

This is community's initiative ! This is a place where SQL scripts for official Zabbix templates will be located.

These scripts will create some global-level configuration data in Zabbix database which can not be included to XML templates but they have references to these global-level data structures.

These scripts prepared for MySQL but supposedly compatible with other db engines, not tested yet.

Scripts may be applied ONLY to a standalone server or to a child node (without its child nodes.)

After upgrading to 2.2

This script will add 2 new value mappings which are used in new 2.2 templates for VMware monitoring. Without this script it's not possible to import 3 new VMware templates.

SET @vid = (SELECT MAX(valuemapid) AS id FROM valuemaps);
SET @mid = (SELECT MAX(mappingid) AS id FROM mappings);
INSERT INTO `valuemaps` 
(@vid+1,'VMware status'),
(@vid+2,'VMware VirtualMachinePowerState');
INSERT INTO `mappings` 
DELETE FROM ids WHERE table_name='valuemaps' AND field_name='valuemapid';
DELETE FROM ids WHERE table_name='mappings' AND field_name='mappingid';
Note: Since Zabbix 3.0.0, value maps can also be exported/imported from XML.

After upgrading to 2.0

This script will add 3 new global regexps which are used in new 2.0 templates for LLD. Without this script the templates will not work correctly. Zabbix bug tracker contains several bugs reported mistakenly, those have been closed as Incomplete now.

SET @rid = IFNULL((SELECT MAX(regexpid) AS id FROM regexps),0);
SET @eid = IFNULL((SELECT MAX(expressionid) AS id FROM expressions),0);
INSERT INTO `regexps` (regexpid,name,test_string) VALUES 
(@rid+1,'File systems for discovery','ext3'),
(@rid+2,'Network interfaces for discovery','eth0'),
(@rid+3,'Storage devices for SNMP discovery','/boot');
INSERT INTO `expressions` 
(@eid+3,@rid+3,'^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$',4,',',1),
(@eid+4,@rid+2,'^Software Loopback Interface',4,',',1);
DELETE FROM ids WHERE table_name='regexps' AND field_name='regexpid';
DELETE FROM ids WHERE table_name='expressions' AND field_name='expressionid';

Note: for example, if you upgraded 1.8 -> 2.0 -> 2.2 and want to use all new 2.0, 2.2 templates - you have to execute all the SQLs above.