See www.zabbix.com for the official Zabbix site.

Zabbix Templates/SQLs for Official Templates

From Zabbix.org
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.

BEGIN;
SET @vid = (SELECT MAX(valuemapid) AS id FROM valuemaps);
SET @mid = (SELECT MAX(mappingid) AS id FROM mappings);
INSERT INTO `valuemaps` 
(valuemapid,name) 
VALUES 
(@vid+1,'VMware status'),
(@vid+2,'VMware VirtualMachinePowerState');
INSERT INTO `mappings` 
(mappingid,valuemapid,value,newvalue) 
VALUES 
(@mid+1,@vid+2,'0','poweredOff'),
(@mid+2,@vid+2,'1','poweredOn'),
(@mid+3,@vid+2,'2','suspended'),
(@mid+4,@vid+1,'0','gray'),
(@mid+5,@vid+1,'1','green'),
(@mid+6,@vid+1,'2','yellow'),
(@mid+7,@vid+1,'3','red');
DELETE FROM ids WHERE table_name='valuemaps' AND field_name='valuemapid';
DELETE FROM ids WHERE table_name='mappings' AND field_name='mappingid';
COMMIT;
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.

BEGIN;
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` 
(expressionid,regexpid,expression,expression_type,exp_delimiter,case_sensitive) 
VALUES
(@eid+1,@rid+1,'^(btrfs|ext2|ext3|ext4|jfs|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|ntfs|fat32|zfs)$',3,',',0),
(@eid+2,@rid+2,'^lo$',4,',',1),
(@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';
COMMIT;


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.