运维监控-使用Zabbix Server 监控自定义 item 

                                         作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

  本篇博客就直接开门见山如何使用Zabbix Server 监控自定义item,其实这个案例我之前在用zabbix3.0时分享过。在zabbix 4.0版本上用法几乎一样。关于 Zabbix Server 和 Zabbix Agent 端的部署我这里就不废话。

一.在Zabbix Agent端编写自定义监控项

1>.查看默认的zabbix agent的item模板

[root@node102 ~]# cd /etc/zabbix/zabbix_agentd.d/                    #我们将自定义的zabbix 的item放在该目录下!
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]# ll
total
-rw-r--r--. root root Feb : userparameter_mysql.conf
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]# tail - userparameter_mysql.conf
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]#

2>.自定义zabbix agent 的item项

[root@node102 zabbix_agentd.d]# pwd
/etc/zabbix/zabbix_agentd.d
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]# cat monitor_file.conf             #自定义监控项目
#Add by yinzhengjie
UserParameter=monitor_filesize,stat -c %s /etc/services
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]# systemctl restart zabbix-agent        #修改了上述的配置文件切记要重启服务!
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]# ss -ntl | grep
LISTEN *: *:*
LISTEN ::: :::*
[root@node102 zabbix_agentd.d]#
[root@node102 zabbix_agentd.d]#

3>.检查监控项(item)是否生效

[root@node101 ~]# yum  -y install zabbix-get.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package zabbix-get.x86_64 :4.0.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================
Installing:
zabbix-get x86_64 4.0.-.el7 zabbix k Transaction Summary
====================================================================================================================================================================
Install Package Total download size: k
Installed size: 1.1 M
Downloading packages:
zabbix-get-4.0.-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : zabbix-get-4.0.-.el7.x86_64 /
Verifying : zabbix-get-4.0.-.el7.x86_64 / Installed:
zabbix-get.x86_64 :4.0.-.el7 Complete!
[root@node101 ~]#

[root@node101 ~]# yum -y install zabbix-get.x86_64          #安装zabbix_get服务

[root@node101 ~]# hostname
node101.yinzhengjie.org.cn
[root@node101 ~]#
[root@node101 ~]# zabbix_get -s node102.yinzhengjie.org.cn -k monitor_filesize            #发现我们可以获取到相应的数据啦!说明配置生效了! [root@node101 ~]#

二.在zabbix添加自定义item的监控

1>.如下图所示,找到已经监控的我们上面配置的zabbix agent自定义监控项的主机中的item(如果主机未被监控,我们自己监控一下即可!

2>.点击创建item

3>.添加自定义item

4>.item添加完成

5>.添加item完成后,需要确认是否获取到数据

三.监控httpd服务的80端口

1>.在zabbix agent 安装http并启动

[root@node102 ~]# yum -y install httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors..com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 :2.4.-.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.-.el7.centos for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: libaprutil-.so.()(64bit) for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: libapr-.so.()(64bit) for package: httpd-2.4.-.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 :1.4.-.el7_4. will be installed
---> Package apr-util.x86_64 :1.5.-.el7 will be installed
---> Package httpd-tools.x86_64 :2.4.-.el7.centos will be installed
---> Package mailcap.noarch :2.1.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================
Installing:
httpd x86_64 2.4.-.el7.centos base 2.7 M
Installing for dependencies:
apr x86_64 1.4.-.el7_4. base k
apr-util x86_64 1.5.-.el7 base k
httpd-tools x86_64 2.4.-.el7.centos base k
mailcap noarch 2.1.-.el7 base k Transaction Summary
====================================================================================================================================================================
Install Package (+ Dependent packages) Total download size: 3.0 M
Installed size: M
Downloading packages:
warning: /var/cache/yum/x86_64//base/packages/apr-util-1.5.-.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY. B/s | B --:--:-- ETA
Public key for apr-util-1.5.-.el7.x86_64.rpm is not installed
(/): apr-util-1.5.-.el7.x86_64.rpm | kB ::
(/): apr-1.4.-.el7_4..x86_64.rpm | kB ::
(/): mailcap-2.1.-.el7.noarch.rpm | kB ::
(/): httpd-tools-2.4.-.el7.centos.x86_64.rpm | kB ::
(/): httpd-2.4.-.el7.centos.x86_64.rpm | 2.7 MB ::
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.5 MB/s | 3.0 MB ::
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release--2.1511.el7.centos.2.10.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.-.el7_4..x86_64 /
Installing : apr-util-1.5.-.el7.x86_64 /
Installing : httpd-tools-2.4.-.el7.centos.x86_64 /
Installing : mailcap-2.1.-.el7.noarch /
Installing : httpd-2.4.-.el7.centos.x86_64 /
Verifying : httpd-tools-2.4.-.el7.centos.x86_64 /
Verifying : apr-1.4.-.el7_4..x86_64 /
Verifying : mailcap-2.1.-.el7.noarch /
Verifying : httpd-2.4.-.el7.centos.x86_64 /
Verifying : apr-util-1.5.-.el7.x86_64 / Installed:
httpd.x86_64 :2.4.-.el7.centos Dependency Installed:
apr.x86_64 :1.4.-.el7_4. apr-util.x86_64 :1.5.-.el7 httpd-tools.x86_64 :2.4.-.el7.centos mailcap.noarch :2.1.-.el7 Complete!
[root@node102 ~]#
[root@node102 ~]#

[root@node102 ~]# yum -y install httpd

[root@node102 ~]#
[root@node102 ~]# systemctl start httpd
[root@node102 ~]#
[root@node102 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Fri -- :: PST; 6s ago
Docs: man:httpd()
man:apachectl()
Main PID: (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
└─ /usr/sbin/httpd -DFOREGROUND Feb :: node102.yinzhengjie.org.cn systemd[]: Starting The Apache HTTP Server...
Feb :: node102.yinzhengjie.org.cn systemd[]: Started The Apache HTTP Server.
[root@node102 ~]#
[root@node102 ~]#
[root@node102 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@node102 ~]#
[root@node102 ~]#

2>.在zabbix server进行监控

3>.停掉httpd服务,观察监控到的值

4>.查看监控的图像(解决中文乱码问题)

[root@node101 fonts]# yum -y install lrzsz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 :0.12.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================
Installing:
lrzsz x86_64 0.12.-.el7 base k Transaction Summary
====================================================================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
lrzsz-0.12.-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : lrzsz-0.12.-.el7.x86_64 /
Verifying : lrzsz-0.12.-.el7.x86_64 / Installed:
lrzsz.x86_64 :0.12.-.el7 Complete!
[root@node101 fonts]#

[root@node101 fonts]# yum -y install lrzsz            #安装Linux再带的工具

[root@node101 fonts]#
[root@node101 fonts]# pwd        #zabbix存放字体的路径!
/usr/share/zabbix/fonts
[root@node101 fonts]#
[root@node101 fonts]# ls
graphfont.ttf
[root@node101 fonts]#
[root@node101 fonts]# ll
total
lrwxrwxrwx. root root Feb : graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@node101 fonts]#
[root@node101 fonts]#
[root@node101 fonts]# ls
graphfont.ttf simkai.ttf
[root@node101 fonts]#
[root@node101 fonts]# rz [root@node101 fonts]#
[root@node101 fonts]# \mv simkai.ttf graphfont.ttf
[root@node101 fonts]#
[root@node101 fonts]# ll
total
-rw-r--r--. root root Jun graphfont.ttf
[root@node101 fonts]#

  只需要将Windows的机器字体上传到服务器上并替换即可让字体显示正常。

5>.

6>.

运维监控-使用Zabbix Server 添加自定义 item的更多相关文章

  1. 运维监控-使用Zabbix Server 创建 Actions

    运维监控-使用Zabbix Server 创建 Actions 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. zabbix的action默认是关闭的,因此我们想使用它就得先启用哟. ...

  2. 运维监控-使用Zabbix Server 创建触发器Triggers

    运维监控-使用Zabbix Server 创建触发器Triggers  作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 1>.点击相应主机的触发器 2>.点击创建触发器 ...

  3. 运维监控---企业级Zabbix详解_【all】

    基础LNMP环境搭建 Linux 下LNMP环境搭建 下载Zabbix 链接:https://pan.baidu.com/s/1n36esVyYAKstwnFopbV2sg 密码:izll 创建zab ...

  4. 运维监控篇Zabbix简单的性能调优

    Zabbix是一款高性能的分布式监控报警系统.比如现在常见的家用台式机配置处理器I5-3470.内存4GB1600MHz.硬盘7200rpm就能够监控1000台左右的HOST,是的没错Zabbix就是 ...

  5. 运维监控之zabbix(yum安装)

    简介 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位 ...

  6. OpenStack与ZStack深度对比:架构、部署、计算、运维监控等

    摘要 OpenStack从2010年开源至今,已经走过9个年头,其正在进入主流企业市场,但该项目依然面临较难部署和管理的老问题.有一点是毫无疑问的,那就是OpenStack保持着高速增长的态势,超过5 ...

  7. 运维监控-基于yum的方式部署Zabbix Server 4.0 版本

    运维监控-基于yum的方式部署Zabbix Server 4.0 版本 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.如何选择zabbix版本 1>.打开zabbix官方 ...

  8. 运维监控-Zabbix Server 使用微信 WeChat 告警

    运维监控-Zabbix Server 使用微信 WeChat 告警 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 微信公众号告警每个一天只支持1000次告警,如果超出这个次数了就不 ...

  9. 运维监控-Zabbix Server 使用QQ SMTP发送邮件报警及定制报警内容

    运维监控-Zabbix Server 使用QQ SMTP发送邮件报警及定制报警内容 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客采用腾讯邮箱,想必大家都对QQ很了解,所以 ...

随机推荐

  1. Ubuntu 16.04配置Java Web开发环境

    说明:在Linux下无论是开发还是服务器配置,我个人建议都安装二进制包版本的,优点:配置清晰,容易发现问题,性能调优方便等.缺点:配置太复杂.而其余平台的建议是一键安装版本,毕竟都是用于测试的,不会实 ...

  2. 弹出层-layui

    type 0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层) 弹出层 //winIndex存储弹出层的index,以便关闭弹出层时使用 function openWindo ...

  3. 常用的redis服务命令。

    卸载服务:redis-server --service-uninstall 开启服务:redis-server --service-start 停止服务:redis-server --service- ...

  4. BZOJ5119 生成树计数(prufer+生成函数+分治FFT+多项式exp)

    https://www.luogu.org/problemnew/solution/P4002 神树的题解写的很清楚了.稍微补充: 1.[x^i]ln(A(ax))=a^i[x^i]ln(A(x)), ...

  5. 二分图最小点覆盖König定理的简单证明 (加入自己理解)

    第一次更改:http://blog.sina.com.cn/s/blog_51cea4040100h152.html 讲的更细致 增广路:https://blog.csdn.net/qq_374572 ...

  6. 洛谷P1007独木桥题解

    题目 这个题看起来很难,但是只要理解了题目,一切都显得简单. 你只需想象出来每个人在碰撞之后仅仅是交换了灵魂, 这样一来,代码就好写了. 附代码: #include<iostream> # ...

  7. 用大O记号法测量算法的效率(Algorithm efficiency Asymptotic notation Big O notation)

    为什么要了解算法的效率? 一般来说,编程就是把各种已知的算法代入到自己的代码当中,以此来解决问题.因此,了解各种算法的效率对于我们选择一个合适的算法有很大帮助. 算法的效率由什么确定? 从算法分析的理 ...

  8. MT【293】拐点处切线

    (2018浙江高考压轴题)已知函数$f(x)=\sqrt{x}-\ln x.$(2)若$a\le 3-4\ln 2,$证明:对于任意$k>0$,直线$y=kx+a$ 与曲线$y=f(x)$有唯一 ...

  9. MT【287】余弦的线性组合

    (2017北大特优)在$\Delta ABC$中,$cos A+\sqrt{2}cos B+\sqrt{2}cos C$的最大值____ 解答 :2$cos A+\sqrt{2}cos B+\sqrt ...

  10. MT【261】左准线

    设双曲线$x^2-\dfrac{y^2}{3}=1$的左右焦点为$F_1,F_2$, 直线$l$ 过$F_2$且与双曲线交于$A,B$两点.若$l$的斜率存在,且$(\overrightarrow{F ...