Zabbix Add Custom item, trigger, graphic, and execute remote command

Source: Internet
Author: User

#前言:
Rough look is very complex, in fact, follow the steps to do a bit, very simple!

#意图:
When the agentd-side monitoring service is down, it attempts to restart it.

#环境:

1, VMware12, CentOS 7.1, Zabbix 2.4.6
2. Zabbix Server ip:10.10.100.104
3, Zabbix Agentd ip:10.10.100.105
4. The server side and the Agentd end are respectively turned off SELinux and FIREWALLD:

4.1, vim/etc/selinux/conf
Selinux=disabled
4.2. Service Firewalld Stop
Chkconfig Firewalld off
4.3, reboot

#流程:

1, operation in: Agentd end

#自定义监控脚本

[email protected] libexec]# cat httpd_service.sh #!/bin/bash proc=$ (netstat-lnutp | grep httpd | grep-v grep | gawk ' {print $7} ' | Gawk ' BEGIN {fs= '/'}{print $} ' | WC-L) #获取httpd proces information if ["$proc" = "] then echo 0 #如果没有httpd proces information, echo 0 else echo $proc #如果 With httpd proces information, echo counts the number of rows fi

Note: If your script returns only a fixed value, no graphics will be generated.


#zabbix_agentd. conf configuration

Vim/usr/local/zabbix/etc/zabbix_agentd.conf

Unsafeuserparameters=1 #允许使用自定义item userparameter=httpd_monitor,/usr/local/zabbix/libexec/httpd_service.sh # Userparameter=item name, script path Allowroot=1 #测试时使用root账号的话, and allow root server=10.10.100.104 to be used #server端ip Enableremotecommand S=1 #允许执行远程命令 Logfile=/tmp/zabbix_agentd.log #日志路径

Warning:
To use a remote command in the "Configure" action, "serveractive" must not be turned on, and I have stumbled here.

2, operation in: Server side

#添加自定义item, triggers, graphics steps:

1. Add Host
Configuration "Host" to complete the "host name", "Visible name", using the existing groups from the right "other groups" select, otherwise in the "New group", fill in the IP address ZABBIX_AGENTD host IP address.

650) this.width=650; "title=" host.jpg "src=" http://s1.51cto.com/wyfs02/M00/76/54/ Wkiom1zpl7-zgzjoaaoqlcnyi1s687.jpg "alt=" Wkiom1zpl7-zgzjoaaoqlcnyi1s687.jpg "/>

2. Add an app Set
Configuration "Host" in the list of hosts, locate the "host" you added, click "Apply Set" to create an app set, fill in the application Set "name" add

650) this.width=650; "title=" application.jpg "src=" http://s3.51cto.com/wyfs02/M00/76/53/ Wkiol1zpmoox0emiaahteqef5hw652.jpg "alt=" Wkiol1zpmoox0emiaahteqef5hw652.jpg "/>
3. Add Items
Configuration "Host" in the list of hosts, find the "host" you added, click "Project" to create a monitoring item, "name" Custom input, "key value" manually fill out (you in zabbix_agentd.conf "Userparameter" defined in the item name) "Application set, select App sets created in step two add

650) this.width=650; "title=" item.jpg "src=" http://s3.51cto.com/wyfs02/M00/76/53/ Wkiol1zpmtfxlowsaaemnkfjouw519.jpg "alt=" Wkiol1zpmtfxlowsaaemnkfjouw519.jpg "/>

4. Add Trigger
Configuration "Host" in the host list, find the "host" you added, click "Trigger"
4.1 "name" Custom input, "expression" click "Add" "Project" click "Select" Select "Project" "function" created in the third step, select the expression according to the actual need, I choose the "last (most recent) T value is n", "n" Input 0 "insert
4.2 "Severity" Select Category "Disaster" add

650) this.width=650; "style=" Float:none; "title=" trigger_expr.jpg "src=" http://s1.51cto.com/wyfs02/M00/76/54/ Wkiom1zpmznwnjozaad6hhthwja101.jpg "alt=" Wkiom1zpmznwnjozaad6hhthwja101.jpg "/>

650) this.width=650; "style=" Float:none; "title=" trigger.jpg "src=" http://s4.51cto.com/wyfs02/M01/76/54/ Wkiom1zpmavwp5sfaakznvdewxu685.jpg "alt=" Wkiom1zpmavwp5sfaakznvdewxu685.jpg "/>

Note:
1. Add multiple triggers to the class and choose a different "severity" to tell you what level of "problem" is occurring.
2. Expression description, {host: project. function}= value (function is System defined)

5. Create a graphic
Configuration "Host" in the list of hosts, find the "host" you added, click "Graphics" to create a graphic, "name" Custom input, "project" Add "Select the third step to create

"Project" added

650) this.width=650; "title=" graph.jpg "src=" http://s1.51cto.com/wyfs02/M02/76/54/ Wkiom1zpmhtsh2qwaam3ke19pq0796.jpg "alt=" Wkiom1zpmhtsh2qwaam3ke19pq0796.jpg "/>

At this point, the custom item, trigger, and graphics are added.

3, operation in: Server side

#配置动作

1, configuration "action" create action "

1.1 Action, fill in "name" can

650) this.width=650; "title=" action.jpg "src=" http://s2.51cto.com/wyfs02/M01/76/54/ Wkiom1zpmpwjmmh9aaij1nq45hq798.jpg "alt=" Wkiom1zpmpwjmmh9aaij1nq45hq798.jpg "/>

1.2 Items, calculation method, select "and" (see actual need) "new trigger conditions, host = XXX (select the above steps to create the host)" Add

650) this.width=650; "title=" condition.jpg "src=" http://s2.51cto.com/wyfs02/M00/76/53/ Wkiol1zpm2yco8fiaai7wisyr9o164.jpg "alt=" Wkiol1zpm2yco8fiaai7wisyr9o164.jpg "/>

1.3 operation, "new" "Stage" (from ...) To, how many times, step duration), operation type Select Remote command
1.3.1 Target list, "new" target Select "Host", (select the host created by the above steps) add

1.4 Type, "Custom Script", executed in "Zabbix agent"
1.5 commands, see need, I enter "service httpd restart" here
1.6 pieces, see need
1.6.1 is generally known as: event-aware = Non-aware "add
Add to

650) this.width=650; "title=" operating.jpg "src=" http://s4.51cto.com/wyfs02/M02/76/53/wKioL1ZPM-WhKZF_ Aam3yn4jgka888.jpg "alt=" Wkiol1zpm-whkzf_aam3yn4jgka888.jpg "/>

At this point, the "action" is added.

4. Testing

1. Perform service httpd stop on AGENTD side
2, observe Zabbix server, prompt problem, one will successfully perform remote command restore normal state.

650) this.width=650; "title=" Monitor Graph.jpg "src=" http://s4.51cto.com/wyfs02/M01/76/54/ Wkiom1zpnipc1uj0aaz313ld2qy877.jpg "alt=" Wkiom1zpnipc1uj0aaz313ld2qy877.jpg "/>

The experiment is complete.


This article is from the "Super_color" blog, make sure to keep this source http://small.blog.51cto.com/259970/1715237

Zabbix Add Custom item, trigger, graphic, and execute remote command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.