Zabbix Pit Tour--zabbix trigger reboot Tomcat

Source: Internet
Author: User

First, the experimental needs

The company's Tomcat service often crashes automatically, causing business disruption, temporarily monitoring it with Zabbix, and enabling it to start automatically when Tomcat crashes, ensuring that the business returns to normal as soon as possible.


Second, the preparation environment

System Environment: CentOS 6.5

IP Address:

zabbix-server:192.168.239.128

zabbix-agent:192.168.239.130


Installation of Zabbix server and client is installed here in RPM package, configuration is skipped. Install Tomcat on the agent side.


Third, open the pit tour--agent end

① Modify the zabbix-agent configuration file, change the reboot to take effect

# vim/etc/zabbix/zabbix_agentd.conf

Enableremotecommands=1 opening the agent-side remote command execution function

# sudo server zabbix-agent restart

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/18/wKiom1cTPzXwryzAAAAVCi5j5v4096.png "title=" Zabbix5.png "alt=" Wkiom1ctpzxwryzaaaavci5j5v4096.png "/>

② Modify sudoers to give Zabbix user permission, otherwise zabbix-agent cannot execute command

# sudo Visudo

Zabbix all:nopasswd All

Zabbix all:nopasswd/usr/loacal/catalina.sh Start

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/18/wKiom1cTQlGTzG8EAAAWg_dOMD8929.png "title=" Zabbix6.png "alt=" Wkiom1ctqlgtzg8eaaawg_domd8929.png "/>

Four, open the pit tour--server end

① First create a host, directly fill in the agent side of the IP on the line

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/15/wKioL1cTN5jQ4UpTAADKOPv-SLQ807.png "title=" Zabbix1.png "alt=" Wkiol1ctn5jq4uptaadkopv-slq807.png "/>

② Create item, use the built-in key

"Proc.num[<name>,<user>,<state>,<cmdline>]"

Counting the number of processes through a user execution, a process state, a process name

name : Process name (default "All Processes")

User: Username (default "all user")

State: Process status (Default "All"), Optional: Run,sleep,zomb

cmdline: command-line filtering (using regular expressions to find processes)

For example: Proc.num[,root,all,tomcat] The root user runs a process that matches all the states of Tomcat.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7F/15/wKioL1cTOcvR1CU6AAB6rmzRy9Y855.png "style=" float: none; "title=" Zabbix2.png "alt=" Wkiol1ctocvr1cu6aab6rmzry9y855.png "/>

③ CREATE TRIGGER, set trigger conditions, the following expression means that the last two times the result is 0 to trigger the alarm

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/18/wKiom1cTORDiaxQLAABIluzMhaM215.png "style=" float: none; "title=" Zabbix3.png "alt=" Wkiom1ctordiaxqlaabiluzmham215.png "/>

④ Create action

operation type: Execute remote command instead

Target list: Selected agent for execution

Type: There are a number of options, where Tomcat is started and remote command or SSH can be

execute on: The execution side, the default selection agent side can either

Commands: Writes a command that you want the agent to execute

Pit: Here's the command especially note, be sure to add sudo to elevate Zabbix permissions, otherwise the command can not be executed, and remote command execution will not have a reply message, troubleshooting is more difficult.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/15/wKioL1cTPdXgLSw8AADD4EeyQZE630.png "title=" Zabbix4.png "alt=" Wkiol1ctpdxglsw8aadd4eeyqze630.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/16/wKioL1cTSD3SJkWCAAAwyXkUg9k846.png "title=" Zabbix11.png "alt=" Wkiol1ctsd3sjkwcaaawyxkug9k846.png "/>

V. Testing

①agent end Tomcat off

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7F/18/wKiom1cTQu7zSgxcAAApj-j7S1w359.png "title=" Zabbix7.png "alt=" Wkiom1ctqu7zsgxcaaapj-j7s1w359.png "/>

The ②server is displayed as a malfunction and will be normal after a while. (The normal figure is to intercept the log and then intercept, a bit long time)

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/16/wKioL1cTQ-jy9m2oAABPGxJWPJk267.png "title=" Zabbix8.png "alt=" Wkiol1ctq-jy9m2oaabpgxjwpjk267.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7F/18/wKiom1cTRJKCXvqkAABQbLQ47RY539.png "title=" Zabbix10.png "alt=" Wkiom1ctrjkcxvqkaabqblq47ry539.png "/>

③ through the log can also see the server side restored

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/18/wKiom1cTRDDiibF2AACYmVzDMyc467.png "title=" Zabbix9.png "alt=" Wkiom1ctrddiibf2aacymvzdmyc467.png "/>


Summary: Summary of key points

①zabbix-agent End:

Add Enableremotecommands=1

Modify the sudoers, give Zabbix authorization

②zabbix-server End:

Ensure that trigger conditions and execution conditions are normal, remote commands remember to add sudo


Direct reference to Zabbix official documentation

This article is from the Linux Learning Log table blog, so be sure to keep this source http://pixiuwho.blog.51cto.com/2966916/1764770

Zabbix Pit Tour--zabbix trigger reboot Tomcat

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.