In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Zabbix remote command (remote command):
1.1 Features:
Restart the service
Restart the server through the IPMI interface
What any custom script can do: clean up disk space, migrate virtual machine instances, etc.
1.2 related attributes:
Tatget list: the target host on which the remote command is executed, which can be the current host, other host, or host group
Type: command typ
IPMI:IPMI command
Custom script: custom script, which can be executed on zabbix server or zabbix agent
SSH: to execute the command through ssh, you need to provide the user account number on the target host, the relevant authentication method and the additional information required for authentication.
Telnet: to execute the command through Telnet, you need to specify the user name, password and the port on which the remote host telnet service listens.
Global script: a global script that executes one of the scripts defined by "Administration-- > Scripts"
Commands: command to execute
2. Prerequisites for use
Configuration to be completed in agent:
(1) zabbix users have the permissions they need to manage (based on sudo authorization)
~] # visudo#% wheel ALL= (ALL) NOPASSWD: ALLzabbix ALL= (ALL) NOPASSWD: ALL# Defaults requiretty# comment this line
Description of this configuration:
1) Defaults requiretty, modified to # Defaults requiretty, indicating that you do not need to control the terminal (you do not need to log in from the terminal to execute the command)
# su-zabbix-c 'sudo / usr/bin/systemctl restart httpd.service'
2) Defaults requiretty, modified to Defaults:nobody! requiretty, which means that only nobody users do not need to control the terminal (only nobody users do not need to log in from the terminal to execute commands)
(2) the agent process should allow the execution of remote commands
~] # vim / etc/zabbix/zabbix_agentd.confEnableRemoteCommands=1# enable remote command # Option: LogRemoteCommands# Enable logging of executed shell commands as warnings.# 0-disabled# 1-enabled## Mandatory: no# Default:# LogRemoteCommands=0LogRemoteCommands=1# logging
(3) restart the service
~] # systemctl restart zabbix-agent.service
(4) zabbix users can log in
~] # mkdir / var/lib/zabbix# create a home directory, but do not do ~] # grep "^ zabbix" / etc/passwdzabbix:x:996:994:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin~] # usermod-s / bin/bash zabbix~] # grep "^ zabbix" / etc/passwdzabbix:x:996:994:Zabbix Monitoring System:/var/lib/zabbix:/bin/bash
3. Probe port 80 of tcp. If port 80 of tcp is not listening, restart the nginx server automatically.
Install nginx on the monitored host
~] # yum install-y nginx~] # systemctl restart nginx.service # start the service
Configure item and trigger on zabbix web, collect monitoring data, and set triggers
Item:
Trigger:
Action configuration, focusing on the configuration of Operation details:
Verify:
Stop the nginx service
~ #] su-zabbix-c "sudo / usr/bin/systemctl stop nginx.service" # this method can verify whether zabbix can execute commands without a login terminal. The following error will not affect the use, ignore it: Error creating textual authentication agent: Error opening current controlling terminal for the process (`/ dev/tty'): No such device or address (polkit-error-quark, 0)
You can see the triggered monitoring items in the Triggers of Monitoring.
In Events, you can see the triggered event and the Action that has been prompted:
You can view the operation log in the / var/log/zabbix/zabbix_agentd.log directory on agent host (you can find the cause of the error through the log):
4620Rom 20170511Rose 111934.635 Executing command'/ usr/bin/systemctl restart nginx.service'
Port 80 has been found to be listening again on agent host:
[root@wlm ~] # ss-tnl | grep 80LISTEN 0 128 *: 80 *: * LISTEN 0 128: 80:: *
The alarm on zabbix web has also been lifted.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.