Commit 1faf32ac by liuyz

更新zabbix数据库脚本

parents
/*
Navicat MySQL Data Transfer
Source Server : 192.168.1.142
Source Server Version : 50505
Source Host : 192.168.1.142:3306
Source Database : zabbix
Target Server Type : MYSQL
Target Server Version : 50505
File Encoding : 65001
Date: 2018-07-06 10:04:29
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- View structure for function_expression_view
-- ----------------------------
DROP VIEW IF EXISTS `function_expression_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `function_expression_view` AS select concat(`h`.`name`,':',`i`.`key_`,'.',`f`.`function`,'(',`f`.`parameter`,')') AS `function_expression`,`f`.`functionid` AS `functionid`,`f`.`itemid` AS `itemid`,`f`.`triggerid` AS `triggerid`,`f`.`function` AS `function`,`f`.`parameter` AS `parameter`,`i`.`hostid` AS `hostid`,`h`.`name` AS `host_name`,`i`.`key_` AS `key_` from ((`functions` `f` left join `items` `i` on(`f`.`itemid` = `i`.`itemid`)) left join `hosts` `h` on(`i`.`hostid` = `h`.`hostid`)) ;
-- ----------------------------
-- View structure for history_text_newest_view
-- ----------------------------
DROP VIEW IF EXISTS `history_text_newest_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `history_text_newest_view` AS select `ht`.`itemid` AS `itemid`,`ht`.`value` AS `value`,max(`ht`.`clock`) AS `clock` from `history_text` `ht` group by `ht`.`itemid` ;
-- ----------------------------
-- View structure for hosts_cpu_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_cpu_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_cpu_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,100 - `ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` = 'system.cpu.util[all,idle,avg1]')) left join `history` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_disk_read_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_disk_read_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_disk_read_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`i`.`key_` AS `key_`,replace(replace(`i`.`key_`,'disk.status[',''),',rKBps]','') AS `disk_name`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` like 'disk.status[%,rKBps]' and `i`.`key_` not like 'disk.status[{#DISK_NAME},%')) left join `history` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_disk_wirte_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_disk_wirte_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_disk_wirte_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`i`.`key_` AS `key_`,replace(replace(`i`.`key_`,'disk.status[',''),',wKBps]','') AS `disk_name`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` like 'disk.status[%,wKBps]' and `i`.`key_` not like 'disk.status[{#DISK_NAME},%')) left join `history` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_event_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_event_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_event_view` AS select `ev2`.`eventid` AS `eventid`,`ev2`.`clock` AS `clock`,`ev2`.`value` AS `value`,`ev2`.`ns` AS `ns`,`h`.`hostid` AS `hostid`,`h`.`host` AS `name`,`h`.`description` AS `host_description`,`t`.`description` AS `description` from ((((((select max(`ev`.`eventid`) AS `eventid`,`ev`.`objectid` AS `objectid` from `zabbix`.`events` `ev` group by `ev`.`objectid`)) `e` left join `zabbix`.`events` `ev2` on(`e`.`eventid` = `ev2`.`eventid`)) left join `zabbix`.`triggers` `t` on(`t`.`triggerid` = `ev2`.`objectid`)) left join `zabbix`.`hosts_trigger_relative_view` `hv` on(`hv`.`triggerid` = `t`.`triggerid`)) left join `zabbix`.`hosts` `h` on(`h`.`hostid` = `hv`.`hostid`)) where `ev2`.`source` = 0 and `ev2`.`object` = 0 and `t`.`triggerid` is not null ;
-- ----------------------------
-- View structure for hosts_memory_size_available
-- ----------------------------
DROP VIEW IF EXISTS `hosts_memory_size_available`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_memory_size_available` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` = 'vm.memory.size[available]')) left join `history_uint` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_memory_size_total
-- ----------------------------
DROP VIEW IF EXISTS `hosts_memory_size_total`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_memory_size_total` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` = 'vm.memory.size[total]')) left join `history_uint` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_net_in_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_net_in_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_net_in_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`i`.`key_` AS `key_`,replace(replace(`i`.`key_`,'net.if.in[',''),']','') AS `network_card`,`i`.`itemid` AS `itemid`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` like 'net.if.in%' and `i`.`key_` <> 'net.if.in[{#IFNAME}]')) left join `history_uint` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_net_out_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_net_out_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_net_out_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`i`.`key_` AS `key_`,replace(replace(`i`.`key_`,'net.if.out[',''),']','') AS `network_card`,`i`.`itemid` AS `itemid`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` like 'net.if.out%' and `i`.`key_` <> 'net.if.out[{#IFNAME}]')) left join `history_uint` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_sysinfo_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_sysinfo_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_sysinfo_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`h`.`description` AS `description`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` = 'sysinfo')) left join `history_text_newest_view` `ht` on(`i`.`itemid` = `ht`.`itemid`)) where `ht`.`clock` is not null ;
-- ----------------------------
-- View structure for hosts_trigger_relative_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_trigger_relative_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_trigger_relative_view` AS select `i`.`hostid` AS `hostid`,`tri`.`triggerid` AS `triggerid` from ((`triggers` `tri` left join `functions` `f` on(`tri`.`triggerid` = `f`.`triggerid`)) left join `items` `i` on(`f`.`itemid` = `i`.`itemid`)) group by `i`.`hostid`,`tri`.`triggerid` ;
-- ----------------------------
-- View structure for hosts_vfs_fs_size_pfree_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_vfs_fs_size_pfree_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_vfs_fs_size_pfree_view` AS select `h`.`hostid` AS `hostid`,`h`.`name` AS `name`,`i`.`key_` AS `key_`,replace(replace(`i`.`key_`,'vfs.fs.size[',''),',pfree]','') AS `mount_point`,`ht`.`value` AS `value`,`ht`.`clock` AS `clock` from ((`hosts_view` `h` left join `items` `i` on(`h`.`hostid` = `i`.`hostid` and `i`.`key_` like 'vfs.fs.size[%,pfree]' and `i`.`key_` not like 'vfs.fs.size[{#FSNAME}%')) left join `history` `ht` on(`i`.`itemid` = `ht`.`itemid`)) ;
-- ----------------------------
-- View structure for hosts_view
-- ----------------------------
DROP VIEW IF EXISTS `hosts_view`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `hosts_view` AS select `h`.`hostid` AS `hostid`,`h`.`proxy_hostid` AS `proxy_hostid`,`h`.`host` AS `host`,`h`.`status` AS `status`,`h`.`disable_until` AS `disable_until`,`h`.`error` AS `error`,`h`.`available` AS `available`,`h`.`errors_from` AS `errors_from`,`h`.`lastaccess` AS `lastaccess`,`h`.`ipmi_authtype` AS `ipmi_authtype`,`h`.`ipmi_privilege` AS `ipmi_privilege`,`h`.`ipmi_username` AS `ipmi_username`,`h`.`ipmi_password` AS `ipmi_password`,`h`.`ipmi_disable_until` AS `ipmi_disable_until`,`h`.`ipmi_available` AS `ipmi_available`,`h`.`snmp_disable_until` AS `snmp_disable_until`,`h`.`snmp_available` AS `snmp_available`,`h`.`maintenanceid` AS `maintenanceid`,`h`.`maintenance_status` AS `maintenance_status`,`h`.`maintenance_type` AS `maintenance_type`,`h`.`maintenance_from` AS `maintenance_from`,`h`.`ipmi_errors_from` AS `ipmi_errors_from`,`h`.`snmp_errors_from` AS `snmp_errors_from`,`h`.`ipmi_error` AS `ipmi_error`,`h`.`snmp_error` AS `snmp_error`,`h`.`jmx_disable_until` AS `jmx_disable_until`,`h`.`jmx_available` AS `jmx_available`,`h`.`jmx_errors_from` AS `jmx_errors_from`,`h`.`jmx_error` AS `jmx_error`,`h`.`name` AS `name`,`h`.`flags` AS `flags`,`h`.`templateid` AS `templateid`,`h`.`description` AS `description`,`h`.`tls_connect` AS `tls_connect`,`h`.`tls_accept` AS `tls_accept`,`h`.`tls_issuer` AS `tls_issuer`,`h`.`tls_subject` AS `tls_subject`,`h`.`tls_psk_identity` AS `tls_psk_identity`,`h`.`tls_psk` AS `tls_psk` from `hosts` `h` where `h`.`status` = 0 ;
#主机列表
#主机列表
hosts_view
--hostid:主机id
--name:主机名
--*:其他详见hosts表,结构完全一致,参考资料:https://wenku.baidu.com/view/8d56c7b489eb172ded63b7ea.html
#主机列表,系统信息详情
hosts_sysinfo_view
--hostid:主机id
--name:主机名
--value:主机详细信息(json格式,有cpu,硬盘,网卡,内存等信息。很多都是数组请注意)
--clock:value信息的获取时间
#监控项中最新的记录
history_text_newest_view
--itemid:监控项id
--监控项最新值
--监控项最新值产生的时间
#主机cpu使用率(可用于某台主机的cpu使用率曲线图)
hosts_cpu_view
--hostid:主机id
--name:主机名
--value:cpu使用率(显示在页面时自己加%号)
--clock:value信息的获取时间
#主机可用的内存(可用于曲线图)
hosts_memory_size_available
--hostid:主机id
--name:主机名
--value:可用内存(单位字节)
--clock:value信息的获取时间
#主机总内存(可用于曲线图)
hosts_memory_size_total
--hostid:主机id
--name:主机名
--value:总内存(单位字节)
--clock:value信息的获取时间
#主机所有网卡的流出量
hosts_net_out_view
--hostid:主机id
--name:主机名
--key_:监控项名称
--itemid:监控项id
--network_card:网卡名称
--value:流出量(单位bps)
--clock:value信息的获取时间
#主机所有网卡的流入量
hosts_net_in_view
--hostid:主机id
--name:主机名
--key_:监控项名称
--itemid:监控项id
--network_card:网卡名称
--value:流入量(单位bps)
--clock:value信息的获取时间
#主机磁盘使用率
hosts_vfs_fs_size_pfree_view
--hostid:主机id
--name:主机名
--mount_point:挂载点(每台主机可能有多个挂载点)
--value:未使用的容量,百分比形式
--clock:value信息的获取时间
#主机IO,读取速度
hosts_disk_read_view
--hostid:主机id
--name:主机名
--disk_name:磁盘名称(每台主机可能有多个磁盘)
--value:读取速度(单位:KB每秒)
--clock:value信息的获取时间
#主机IO,写入速度
hosts_disk_wirte_view
--hostid:主机id
--name:主机名
--disk_name:磁盘名称(每台主机可能有多个磁盘)
--value:写入速度(单位:KB每秒)
--clock:value信息的获取时间
#主机和触发器的关联表
hosts_trigger_relative_view
--hostid:主机id
--triggerid:触发器id
#触发器表达式中的一部分(可根据triggerid或hostid做查询)
function_expression_view
--function_expression:完整的function表达式,可直接替换{functionid}
--其他:略
#主机预警信息
hosts_event_view
-- eventid:预警id
-- hostid:主机id
-- name:主机名称
-- description:问题描述
-- value:状态(0:OK,正常,1:问题)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment