聚合图形,自定义监控脚本

聚合图形
Monitoring(监控中)-->Screens(聚合图形)-->Create screen(创建聚合图形)即可创建聚合图形
创建的聚合图形(web2_host),点击后面的构造函数(constructor),点击Change(更改),设置每行每列需要显示的数据图表

 


自定义监控案例
监控Nginx服务状态
将源码包拷贝到web1家目录下
cd lnmp_soft/
  ls
   tar -xf nginx-1.12.2.tar.gz
 cd nginx-1.12.2/
  yum -y install gcc pcre-devel openssl-devel
    ./configure  --with-http_stub_status_module
    make && make install
[root@web1 nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf 修改配置文件
location /status {
                stub_status on;
        }     42行添加

[root@web1 nginx-1.12.2]# /usr/local/nginx/sbin/nginx
[root@web1 nginx-1.12.2]# curl http://192.168.2.100/status  测试
Active connections: 1
server accepts handled requests
 1 1 1
Reading: 0 Writing: 1 Waiting: 0

2)自定义监控key
编写自定义监控脚本
[root@web1 ~]# vim /usr/local/bin/nginx_status.sh
#!/bin/bash
case $1 in
active)
   curl -s http://192.168.2.100/status | awk '/Active/{print $NF}';;
waiting)
   curl -s http://192.168.2.100/status | awk '/Waiting/{print $NF}';;
accepts)
   curl -s http://192.168.2.100/status | awk 'NR==3{print $2}';;
esac

[root@web1 ~]# chmod +x /usr/local/bin/nginx_status.sh
[root@web1 ~]# /usr/local/bin/nginx_status.sh waiting
'0

创建自定义key
[root@web1 ~]#  vim /usr/local/etc/zabbix_agentd.conf.d/nginx.status
UserParameter=nginx.status[*],/usr/local/bin/nginx_status.sh $1
[root@web1 ~]# systemctl restart zabbix_agentd  重启服务
[root@web1 ~]# zabbix_get  -s 127.0.0.1 -k 'nginx.status[accepts]'  测试
3


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值