zabbix通过系统表统计并优化资源配置

目录

1.基础表结构

2关键应用

2.1 服务器cpu,内存使用率统计

2.2磁盘目录使用率统计

2.3问题故障统计


1.基础表结构介绍

在进行信息统计之前我们需要先了解一下几个基础表,关于全面详细表结构网上资料很多这里不作具体讲解,重点展示几个常见且实用的信息获取

表名备注表关键信息
hosts 主机主机ip,备注
hosts_groups 主机组主要起到服务器按组过滤
items 监控项各个具体的监控项如:cpu,内存,磁盘
trends 趋势表各个数值监控项,某一时间段内的数值
trends_uint 趋势表各个数值监控项,某一时间段内的数值

2关键应用

2.1 服务器cpu,内存使用率统计

对资源使用率低的服务器进行资源回收,负荷高的服务器进行升级,合理的分配资源

select ip,
max(case when item='Number of CPUs' or item='Number of cores'  then value_max  end) cpus,
max(case when item='Total memory'  then  round(value_max/1024/1024/1024,0)  end)totalMem,
max(case when item='Used memory'  then round(value_max/1024/1024/1024,0)  end)usedMem,
max(case when item='CPU utilization'  then round(value_max,2)  end)pusedCpuMax,
max(case when item='CPU utilization'  then round(value_avg,2)  end)pusedCpuAvg,
max(case when item='Memory utilization'  then round(value_max,2)  end)pusedMemMax,
max(case when item='Memory utilization'  then round(value_avg,2)  end)pusedMemAvg
from (
        select a.name ip ,b.name item,max(c.value_max)  value_max,avg(c.value_avg)value_avg
        from hosts a
        join items b on a.hostid=b.hostid
        join trends c on b.itemid=c.itemid
        where c.clock>UNIX_TIMESTAMP(date_sub(curdate(),interval 90 day))
        and b.name in ('Number of cores','Total memory','Memory utilization','Number of CPUs','Memory utilization','Used memory','CPU utilization')
        group by a.name,b.name
        
        union 
        select a.name,b.name,max(c.value_max) value_max,avg(c.value_avg)value_avg
        from hosts a
        join items b on a.hostid=b.hostid
        join trends_uint c on b.itemid=c.itemid
        where c.clock>UNIX_TIMESTAMP(date_sub(curdate(),interval 90 day))
        and b.name in ('Number of cores','Total memory','Memory utilization','Number of CPUs','Memory utilization','Used memory')
        group by a.name,b.name
)t join hosts d on t.ip=d.name
where d.error not like '%cannot connect%' and d.status=0 and not exists (select 1 from hosts_groups e where e.groupid=17 and e.hostid=d.hostid )
group by ip
order by  pusedMemAvg;

效果图

usedMem非空的为Windows服务器,因为Linux服务器没有这个监控项

2.2磁盘目录使用率统计

使用率高的磁盘系统会告警,但是使用率低的不会有任何提示,因此我们可以通过此方法统计出空间利用率低的磁盘进行回收,避免资源浪费:以下统计的是某服务器组,磁盘总量大于100G且利用率低于20%的磁盘。

select ta.ip,substr(ta.item,1,locate(':',ta.item)) path,ta.utilization_max,tb.total_max
from
(select a.name ip ,b.name item,round(max(c.value_max),2) utilization_max
from hosts a
join items b on a.hostid=b.hostid
join trends c on b.itemid=c.itemid
where c.clock>UNIX_TIMESTAMP(date_sub(now(),interval 2 hour))
and length(b.name)<50 and b.name like '%Space utilization'
group by a.name,b.name
) as ta
 join

(select a.name ip ,b.name item,round(max(c.value_max)/1024/1024/1024,2) total_max
from hosts a
join items b on a.hostid=b.hostid
join trends_uint c on b.itemid=c.itemid
where c.clock>UNIX_TIMESTAMP(date_sub(now(),interval 2 hour))
and length(b.name)<50 and b.name like '%Total space'
group by a.name,b.name
)as tb
on ta.ip=tb.ip and substr(ta.item,1,locate(':',ta.item))=substr(tb.item,1,locate(':',tb.item))
join hosts d on ta.ip=d.name
where ta.utilization_max<20  and tb.total_max>100
and not exists (select * from hosts_groups e where e.groupid=17 and e.hostid=d.hostid )
order by tb.total_max asc;

效果图

2.3问题故障统计

注意必须添加value条件过滤,因为一个事件有开始和关闭两个状态,如果不进行过滤会重复统计两次。

select date_format(from_unixtime(clock),'%Y-%m-%d')time,name,count(*) 
from events 
where name like '%frequent%' and value=0 
group by date_format(from_unixtime(clock),'%Y-%m-%d'),name  
order by date_format(from_unixtime(clock),'%Y-%m-%d') desc limit 30;

效果图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在Solaris系统上配置Zabbix,首先要确保Zabbix agent可以在Solaris系统上运行。根据引用的信息,Zabbix agent可以在Solaris系统上运行。接下来,可以按照以下步骤配置Zabbix: 1. 配置yum源: 在Solaris系统上,可以使用pkgadd命令安装Zabbix,而不是使用yum。所以不需要配置yum源。请参考官方文档或适用于Solaris系统Zabbix安装指南以获得更详细的安装步骤。 2. 配置Zabbix server: 编辑Zabbix server的配置文件/etc/zabbix/zabbix_server.conf,将ListenIP设置为Solaris系统的IP地址。确保DBHost、DBName、DBUser和DBPassword与您的数据库设置匹配。 3. 重启Zabbix server: 使用systemctl命令重启Zabbix server服务以使配置生效:systemctl restart zabbix-server.service 4. 启用Zabbix server: 使用systemctl命令启用Zabbix server服务,以便在系统启动时自动启动:systemctl enable zabbix-server.service 请注意,这只是一个基本的指南,具体的配置步骤可能会因您的系统环境而有所不同。建议您参考官方文档或适用于Solaris系统Zabbix安装指南以获得详细的配置步骤和更多信息。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [zabbix监控服务配置](https://blog.csdn.net/mw5258/article/details/126717294)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Zabbix分布式系统监视-其他](https://download.csdn.net/download/weixin_38576229/19575305)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雷柏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值