1、环境介绍
操作系统:龙蜥os 7.9
软件:dataease v1.18.18
zabbix: 6.0
2、软件下载
https://community.fit2cloud.com/#/products/dataease/downloads
3、将软件包上传到服务器并解压缩
tar -xvf dataease-v1.18.18-offline.tar.gz
4、修改安装配置
根据自己需求修改配置
5、执行安装脚本
sh install.sh
6、登录web ui并修改登录密码
注意:上一步安装成功后会输出默认用户名密码admin dataease
登录成功后这样(这是1.0版本,2.0版本整洁比较,但是模版不如1.0版本多)
7、添加zabbix数据源(以下 数据源、模版、官方展示数据屏全部删除了)
这里根据自己的zabbix 数据库版本选择,我这里是mysql
填写数据库信息,验证成功后保存
8、创建zabbix仪表盘目录
9、选择zabbix模版
选择上一步建立的目录zabbix
10、创建数据集(这里只写一个示例,最后我将记录全部使用的数据集,sql如果有出入自行修改,没啥字段说明,只能自己看数据库)
提示建立一个文件夹
点加号建立数据集,这里选择sql
SELECTCASEWHEN p.severity = '0' THEN '未分类'WHEN p.severity = '1' THEN '信息'WHEN p.severity = '2' THEN '警告'WHEN p.severity = '3' THEN '一般严重'WHEN p.severity = '4' THEN '严重'WHEN p.severity = '5' THEN '灾难级'END AS severity_name,COUNT(*) AS num
FROM problem p
JOIN (SELECT triggerid, MIN(itemid) AS itemidFROM functionsGROUP BY triggerid
) f ON p.objectid=f.triggerid
JOIN items i ON f.itemid=i.itemid
JOIN hosts h ON i.hostid=h.hostid
LEFT JOIN interface inf ON inf.hostid=h.hostid AND inf.main=1
WHERE p.r_clock=0AND h.status IN (0,1)AND i.status=0AND (inf.ip IS NULL OR inf.ip <> '127.0.0.1')
GROUP BYCASEWHEN p.severity = '0' THEN '未分类'WHEN p.severity = '1' THEN '信息'WHEN p.severity = '2' THEN '警告'WHEN p.severity = '3' THEN '一般严重'WHEN p.severity = '4' THEN '严重'WHEN p.severity = '5' THEN '灾难级'END,p.severity
ORDER BY CAST(p.severity AS SIGNED) DESC;
点击运行检查 成功出数据后,保存
11、将数据集应用到模版
点击更换数据集,拖动数据到维度和指标(维度就是表头,指标就是数,如果维度和指标不对就在数据集中更改,或者转换)
填好后这里数据就变了 这就是一个区域弄好了,按照这个思路完善其他区域即可(如有需求这里可以编辑图标的样式)
12、补充数据集(自行调整,有不对的欢迎留言)
主机组数量统计
SELECT COUNT(*) as 主机组数量
FROM hstgrp;
主机数量统计
SELECTCOUNT(DISTINCT h.hostid) AS 主机数量
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
WHEREh.status = 0;
可监控主机数量统计
SELECTCOUNT(DISTINCT h.hostid) AS 可监控主机
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
JOINinterface i ON h.hostid = i.hostid
WHEREh.status = 0AND i.available = 1;
不可监控主机数量统计
SELECTCOUNT(DISTINCT h.hostid) AS 不可监控主机
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
JOINinterface i ON h.hostid = i.hostid
WHEREh.status = 0AND i.available = 2;
未知监控主机数量统计
SELECTCOUNT(DISTINCT h.hostid) AS 未知监控主机
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
JOINinterface i ON h.hostid = i.hostid
WHEREh.status = 0AND i.available = 0;
告警主机数量统计
SELECTCOUNT(DISTINCT h.hostid) AS 告警主机数量
FROMtriggers t
JOINproblem p ON t.triggerid = p.objectid
JOINfunctions f ON t.triggerid = f.triggerid
JOINitems it ON f.itemid = it.itemid
JOINhosts h ON it.hostid = h.hostid
WHEREp.r_eventid IS NULLAND h.status = 0;
待处理警告数量统计
SELECT COUNT(DISTINCT p.eventid) AS 待处理警告数
FROM problem p
JOIN triggers t ON p.objectid = t.triggerid
JOIN functions f ON t.triggerid = f.triggerid
JOIN items i ON f.itemid = i.itemid
JOIN hosts h ON i.hostid = h.hostid
WHERE p.r_eventid IS NULL
AND p.acknowledged = 0;
已处理警告数量统计
SELECT COUNT(*) AS 已处理警告数量
FROM (SELECT eventidFROM problemWHERE acknowledged = 1UNION ALLSELECT eventidFROM eventsWHERE severity = 0
) AS resolved_warnings;
主机状态数量统计
SELECT'可监控主机' AS 主机状态,COUNT(DISTINCT CASE WHEN i.available = 1 THEN h.hostid END) AS 数量
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
JOINinterface i ON h.hostid = i.hostid
WHEREh.status = 0UNION ALLSELECT'不可监控主机' AS 主机状态,COUNT(DISTINCT CASE WHEN i.available = 2 THEN h.hostid END) AS 数量
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
JOINinterface i ON h.hostid = i.hostid
WHEREh.status = 0UNION ALLSELECT'未知监控主机' AS 主机状态,COUNT(DISTINCT CASE WHEN i.available = 0 THEN h.hostid END) AS 数量
FROMhstgrp hg
JOINhosts_groups hgh ON hg.groupid = hgh.groupid
JOINhosts h ON hgh.hostid = h.hostid
JOINinterface i ON h.hostid = i.hostid
WHEREh.status = 0;
top 10 待处理问题数
SELECTh.name AS 主机名称,COUNT(p.eventid) AS 问题数
FROMproblem p
LEFT JOIN (SELECTs1.triggerid,(SELECTs2.itemidFROMfunctions s2WHEREs2.triggerid = s1.triggeridLIMIT 1) AS itemidFROMfunctions s1GROUP BYs1.triggerid
) AS f ON f.triggerid = p.objectid
LEFT JOIN `items` AS i ON i.itemid = f.itemid
LEFT JOIN `hosts` AS h ON h.hostid = i.hostid
LEFT JOIN `interface` AS inf ON inf.hostid = h.hostid
WHEREp.r_eventid IS NULLAND h.status = 0AND i.status = 0
GROUP BYh.hostid, h.host
ORDER BY问题数 DESC
LIMIT 10;
top 10 主机组告警数
SELECTtotal_problems.主机组名,SUM(total_problems.num_problems) AS 问题数
FROM (SELECThs.NAME AS 主机组名,COUNT(DISTINCT p.eventid) AS num_problemsFROMproblem pLEFT JOIN (SELECTs1.triggerid,(SELECTs2.itemidFROMfunctions s2WHEREs2.triggerid = s1.triggeridLIMIT 1) AS itemidFROMfunctions s1GROUP BYs1.triggerid) AS f ON f.triggerid = p.objectidLEFT JOIN `items` AS i ON i.itemid = f.itemidLEFT JOIN `hosts` AS h ON h.hostid = i.hostidLEFT JOIN hosts_groups AS hg ON hg.hostid = h.hostidLEFT JOIN hstgrp AS hs ON hs.groupid = hg.groupidWHEREISNULL(p.r_eventid)AND h.STATUS = 0AND i.`status` = 0GROUP BYhs.NAME
) AS total_problems
GROUP BYtotal_problems.主机组名
ORDER BY问题数 DESC
LIMIT 10;
主机组异常设备占比
SELECThg.groupid AS '组ID',COALESCE(hs.name, '无') AS '组名',COUNT(DISTINCT CASE WHEN p.eventid IS NOT NULL THEN h.hostid END) AS '异常主机数量',COUNT(DISTINCT h.hostid) AS '总主机数量',CONCAT(ROUND(COUNT(DISTINCT CASE WHEN p.eventid IS NOT NULL THEN h.hostid END) / COUNT(DISTINCT h.hostid) * 100, 2), '%') AS '异常主机占比'
FROMhosts_groups hg
LEFT JOIN hosts h ON hg.hostid = h.hostid
LEFT JOIN hstgrp hs ON hg.groupid = hs.groupid
LEFT JOIN (SELECTi.hostid,p.eventidFROMproblem pJOIN functions f ON p.objectid = f.triggeridJOIN items i ON f.itemid = i.itemidWHEREp.r_eventid IS NULL
) AS p ON h.hostid = p.hostid
WHEREh.status = 0
GROUP BYhg.groupid, hs.name
ORDER BYhg.groupid;
告警信息详细
SELECT DISTINCTe.clock,FROM_UNIXTIME(e.clock) AS '告警时间',e.name AS '告警名称',e.severity AS '严重程度',CASE e.severityWHEN '0' THEN '未定义'WHEN '1' THEN '信息'WHEN '2' THEN '警告'WHEN '3' THEN '一般严重'WHEN '4' THEN '严重'WHEN '5' THEN '灾难'ELSE '未知'END AS '严重程度名称',h.host AS '主机名',h.name_upper AS '主机名显示',i.ip AS 'IP地址'
FROMevents e
LEFT JOINtriggers t ON e.objectid = t.triggerid
LEFT JOINfunctions f ON t.triggerid = f.triggerid
LEFT JOINitems it ON f.itemid = it.itemid
LEFT JOINhosts h ON it.hostid = h.hostid
LEFT JOINinterface i ON h.hostid = i.hostid
WHEREe.source = 0AND e.value = 1
ORDER BYe.clock DESC;
最终效果