技术流ken

运维拯救世界

每天五分钟轻松学运维:zabbix自定义监控项目(三)–技术流ken

前言

 

之前的文章当中我们已经部署好了zabbix服务器端以及客户端,并且已经使用zabbix自带的模板对客户端进行了监控。但是由于系统自带模板的监控项较少,实际工作中不能满足我们生产的需要,所以我们需要进行自定义监控某些我们想要的一些项目。

本篇文章我们就来详细演示如何使用自定义监控我们想要监控的一些项目。

 

zabbix自定义监控模板

 

查看自定义监控模板,篇幅有限截取部分模板

[root@ken-node1 ~]# vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
...
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
UserParameter=mysql.version,mysql -V

分析:

在模板当中我们可以发现自定义监控有如下两种形式:

1. UserParameter=key,command

2.UserParameter=key[*],command

两种格式的区别即第一个不能接受用户参数,第二个可以接受变量,更加灵活。

 

自定义监控详细演示–自定义监控内存

 

下面我们就来演示如何监控内存的总大小,使用量,以及剩余量

 

第一步:创建test1.conf,文件结尾必须是conf,被主文件加载

[root@ken-node1 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@ken-node1 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@ken-node1 zabbix_agentd.d]# touch test1.conf
[root@ken-node1 zabbix_agentd.d]# ls
test1.conf userparameter_mysql.conf

 

第二步:截取内存总大小,使用量以及剩余量

[root@ken-node1 ~]# free -h
 total used free shared buff/cache available
Mem: 470M 300M 8.4M 8.1M 161M 116M
Swap: 2.0G 22M 2.0G
[root@ken-node1 ~]# free -m
 total used free shared buff/cache available
Mem: 470 300 8 8 161 116
Swap: 2047 22 2025
[root@ken-node1 ~]# free -m | awk -F " +" 'NR==2{print $4}'
8
[root@ken-node1 ~]# free -m | awk -F " +" 'NR==2{print $2}'
470
[root@ken-node1 ~]# free -m | awk -F " +" 'NR==2{print $3}'
300
[root@ken-node1 ~]# free -m | awk -F " +" 'NR==2{print $4}'
7

 

第三步:编写自定义文件

[root@ken-node1 zabbix_agentd.d]# vim test1.conf 
UserParameter=mem.total,free -m | awk -F " +" 'NR==2{print $2}'
UserParameter=mem.used,free -m | awk -F " +" 'NR==2{print $3}'
UserParameter=mem.free,free -m | awk -F " +" 'NR==2{print $4}'

 

第四步:重启agent客户端

[root@ken-node1 zabbix_agentd.d]# systemctl restart zabbix-agent

 

第五步:zabbix服务器端配置

 

第六步:创建监控项

 

第七步:填写创建的项目名称

 

第八步:查看监控

可以发现我们已经对磁盘的各种参数进行监控了。

今天的五分钟运维就到这里了,至于带变量的自定义监控我们明天再演示吧。

10 thoughts on “每天五分钟轻松学运维:zabbix自定义监控项目(三)–技术流ken

  1. Needed to write you one tiny remark to thank you very much the moment again over the beautiful knowledge you have documented at this time. This is simply pretty generous with people like you to grant without restraint what many individuals could possibly have offered for an electronic book to help with making some cash on their own, primarily seeing that you could possibly have done it in the event you considered necessary. These basics in addition acted to provide a great way to be aware that the rest have the same zeal the same as my own to see a lot more with reference to this matter. I am sure there are thousands of more pleasurable opportunities ahead for people who discover your website.

  2. Thanks a lot for providing individuals with an extraordinarily terrific possiblity to discover important secrets from here. It’s usually so great and as well , packed with a great time for me and my office co-workers to visit your site the equivalent of three times weekly to read the newest stuff you have got. Of course, I am at all times astounded with all the wonderful guidelines you serve. Some 4 facts on this page are basically the most effective we’ve had.

  3. I together with my friends ended up studying the best secrets found on the blog then instantly I got a terrible suspicion I had not expressed respect to the site owner for those strategies. The people happened to be totally thrilled to read through them and already have definitely been making the most of them. Thank you for actually being quite thoughtful and then for considering varieties of amazing subjects millions of individuals are really eager to learn about. My honest apologies for not expressing appreciation to earlier.

  4. I’m also writing to let you be aware of what a useful discovery my cousin’s princess enjoyed reading your blog. She even learned too many things, which include what it’s like to possess a wonderful teaching character to let other people with no trouble gain knowledge of specific advanced subject areas. You undoubtedly did more than visitors’ expectations. Thanks for coming up with these interesting, trustworthy, informative as well as cool thoughts on the topic to Gloria.

  5. I as well as my friends were actually digesting the best pointers located on your web blog and then all of a sudden I got a horrible feeling I never expressed respect to you for those tips. Most of the guys appeared to be consequently excited to learn all of them and already have surely been making the most of them. Appreciation for being so considerate and for making a decision on this kind of remarkable subject areas most people are really desirous to learn about. My sincere regret for not expressing appreciation to sooner.

  6. My wife and i got excited when Jordan managed to complete his studies through the entire ideas he obtained out of your weblog. It is now and again perplexing just to always be giving for free tips and tricks which some other people have been selling. And we also realize we have the blog owner to be grateful to for that. The entire illustrations you made, the easy web site menu, the relationships your site help to create – it’s many sensational, and it is helping our son and the family understand this theme is exciting, and that’s tremendously fundamental. Thanks for everything!

  7. I needed to compose you this very little note just to say thank you again considering the precious concepts you have discussed here. It’s quite generous of people like you to offer unhampered what a lot of people would have offered for an e-book in order to make some cash for themselves, especially since you might well have tried it in the event you desired. Those good tips in addition acted like a good way to know that many people have the identical keenness just as mine to figure out whole lot more with respect to this problem. I am sure there are lots of more enjoyable periods up front for individuals who read through your blog.

  8. I would like to express appreciation to you for rescuing me from this circumstance. After browsing throughout the the web and seeing views that were not pleasant, I assumed my entire life was well over. Being alive devoid of the approaches to the problems you’ve solved by way of this write-up is a serious case, as well as those that could have adversely affected my career if I hadn’t discovered your web blog. Your main natural talent and kindness in maneuvering the whole lot was excellent. I don’t know what I would’ve done if I had not come upon such a solution like this. I am able to at this point relish my future. Thanks for your time so much for the specialized and sensible help. I won’t think twice to recommend the website to anybody who requires assistance about this area.

  9. A lot of thanks for your entire work on this blog. My daughter enjoys carrying out internet research and it’s easy to see why. I know all regarding the powerful ways you deliver invaluable tips and tricks via this web site and as well encourage response from some other people on this article plus our favorite simple princess is really becoming educated a lot. Enjoy the remaining portion of the year. You’re the one performing a useful job.

发表评论

邮箱地址不会被公开。