In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Manually add a monitored server
Add a monitored server process
The monitored host ip:10.55.2.83,OS:RHEL 6.5 in this test
Agent installation on the monitored side
A. Configure the zabbix yum source and install
# yum install zabbix-agent zabbix-sender
B. Modify the configuration, Passiv checks (waiting for the zabbix host to grab data) and Active checks (actively providing data to the zabbix host)
Passive checks mode is used first in this test.
/ etc/zabbix/zabbix_agentd.conf
Passive checks related (configuration related to passive detection: agent waits for server to request data) * Server=10.55.2.81 uses commas to separate the server addresses to which zabbix-server or zabbix-proxy are authorized to collect data; ListenPort=10050 ListenIP=0.0.0.0 StartAgents=3
Note: Hostname must be filled in when configuring active mode
# Active checks related (active detection of relevant configurations: agent actively sends monitoring data to server) * ServerActive=IP [: Port] comma-separated server where the current agent actively sends monitoring data in the past; * Hostname=HOSTNAME
C. Start zabbix-agent and set it to boot automatically. The default port for startup on the agent side is 10050.
~] # chkconfig zabbix-agent on~] # chkconfig-- list zabbix-agentzabbix-agent 0:off 1:off 2:on 3:on 4:on 5:on 6:off ~] # service zabbix-agent startStarting Zabbix agent: [OK] ss-tnl 10050 port LISTEN 0128:: 10050 : * LISTEN 0128 *: 10050 *: * add monitoring configuration to the web configuration interface
A complete and simple monitoring configuration:
Host group-- > host-- > [applications]-> item-- > trigger (Events)-> (Media Type,User Group,User)-> action (conditions,operations (send message,remote script))
Define hostgroup
I used Linux servers built in zabbix for this test.
Define hosts
Define the monitoring item application
Define items
Set in item, select the zabbix agent option for type
The latest sampled data can be seen in the Latest data in Monitoring.
Add trigger
Trigger trigger events: the level at which a monitor item can have more than one trigger; but a trigger can only be associated with one monitor item trigger: trigger expression: {:. (parameter)}: threshold; diff (): compare whether the sampling value is the same as the prior value; usually through checksum; min (): the minimum value within a specified interval or time range Max () avg () nodata ()
Trigger statu
Define the medium
Administration---- > Media types
Add media users combined users
Note: you can only fill in one email address in the recipient by using the mail function provided with zabbix.
Add action based on trigger
Action is the global configuration of zabbix, so it is not available in hosts
Here I define the first 3 10 minutes to send to ops users
Alarm upgrade setting, 4-6 10 minutes sent to boss users
2. Alarm test
When an alarm occurs on a server, the first thing to do is to remote command it first. If it fails, the alarm will be upgraded and send message will be carried out.
Remote command test
This time, a httpd server is tested, and its port 80 is monitored. If it is down, it will resume automatically.
Server address: 10.55.10.79
Add a monitoring item to monitor its port 80
Manually shut down the service for event testing:-> ok
[root@itblog yum.repos.d] # systemctl stop httpd.service [root@itblog yum.repos.d] # systemctl start httpd.service
The configuration that needs to be done on the agent side
Tty problem description: usermod zabbix-s / bin/bash (1) zabbix users need administrative rights (based on sudo authorization); edit / etc/sudoers (visudo) 1) Defaults requiretty, modified to # Defaults requiretty, indicating no need to control the terminal. 2) Defaults requiretty, modified to Default:nobody! requiretty, which means that only nobody users do not need to control the terminal. (2) the agent process should allow the execution of remote commands EnableRemoteCommands=1 add remote command script, first add sudo permission of zabbix ~] # visudo add zabbix ALL= (ALL) NOPASSWD: ALLzabbix can run all operations on this host without password comments centos7 will have such requirements, otherwise it will report the error of tty # Defaults requiretty edit zabbix configuration file, enable remote command function ~] # vim / etc/zabbix/zabbix_agentd.confEnableRemoteCommands=1LogRemoteCommands=1 # logging ~] # systemctl restart zabbix-agent.service
Add action
When the httpd service cannot be repaired automatically, update the alarm and send email.
Test result
Manually shut down httpd
[root@itblog ~] # systemctl stop httpd.service [root@itblog ~] # ss-tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *: 3306 *: * LISTEN 0128 *: 22 *: * LISTEN 0 128 *: 10050 *: * LISTEN 0 128: 22:: * LISTEN 0 : 10050: *
Action:remote command will be activated and the service will be started automatically.
[root@itblog] # ss-tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *: 3306 *: * LISTEN 0128 *: 22 *: * LISTEN 0128 *: 10050 *: * LISTEN 0128: 80:: * LISTEN 0128: :: 22:: * LISTEN 0128: 10050: * Custom scriptsend message: Media Type in the Media Type of the alarm: the channel for delivering messages Script: used to define the information channel. The script that completes the message delivery; (1) the script placement path: / etc/zabbix/zabbix_server.conf AlertScriptPath=/usr/lib/zabbix/alertscripts (2) zabbix passes three parameters to the script: $1: the target of the message sent over this channel; $2: the subject; of the message $3: the body of the message Users: receives messages using a specified channel; User Groups: user's logical container
Write a test script
Here I changed an email script for python, and the send_mail function accepts the three parameters mentioned above.
2.6.6 included with python version RHEL 6.5
[root@wuzabbix ~] # vim / usr _ coding:utf-8 _ current_time=time.strftime _ alertscripts _ Time.localtime (time.time ()) mail_host = '10.55.1.13'mail_user =' wuzabbix@*'#mail_pwd ='* 'def send_email (content,mailto, get_sub): # msg = MIMEText (content.encode (' utf8'), _ subtype=' html', _ charset = 'utf8') msg = MIMEText (content,_subtype='plain' _ charset='gb2312') msg ['From'] = mail_user msg [' Subject'] = get_sub msg ['To'] = "," .join (mailto) try: s = smtplib.SMTP () s.connect (mail_host,25) s.sendmail (mail_user,mailto,msg.as_string ()) s.close () except Exception as e: print' Exception:' E title=sys.argv [2] cont= ""-Abstract:% s-- Date:% s-- -""% (sys.argv [3]) Current_time) to_list = ['% s% (sys.argv [1]),] with open ('/ tmp/sendmail_qs.log','ab') as f: f.write ('% s Receive address:% s Title:% s\ n% (current_time,sys.argv [1], title)) send_email (cont,to_list,title)
Add permissions and send tests on this machine:
Chmod + x altermail.py [root@wuzabbix alertscripts] # python altermail.py yaominghe@* test test
Email accept OK
Custom media type
Edit the action of webservice that I just defined
Modify the ops users just defined, and also modify the media defined in users
Close httpd for testing
[root@itblog ~] # systemctl stop httpd.service [root@itblog ~] # ss-tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *: 3306 *: * LISTEN 0128 *: 22 *: * LISTEN 0 128 *: 10050 *: * LISTEN 0 128 127.0.1 LISTEN 199 *: * LISTEN 0 LISTEN 0 128: 10050: *
3. Key built-in key
Add item based on key+parameter
For more information on how to use it, you can check the documentation in the official document.
Https://www.zabbix.com/documentation/3.0/manual/config/items/itemtypes/zabbix_agent
Test defines the inbound traffic of a network card
Store value: As is: no data processing; Delta (Simple change): this sampling data minus the previous sampling data; Delta (speed per second): this sampling data minus the previous sampling data, and then divided by the sampling interval
By this time, the data has already come.
User-defined key
UserParameter
4. Display interface image Graphs
Continue to add multiple item on the 10.55.2.83 server to monitor network traffic
Select graphs in the host settings to configure
Add it to add and view it in monitorring.
Screen
Integrate multiple graph on the same screen for display
Slide shows
Display multiple screen in slide show way
5. Template
Application template testing
Open a new monitored host 10.55.1.13 Install zabbix-agent Zabbix-sender and configure [root@wulmail zabbix] # vim zabbix_agentd.confServer=10.55.2.81EnableRemoteCommands=1LogRemoteCommands=1ServerActive=127.0.0.1,10.55.2.81Hostname=wulmail # to enable active monitoring must specify hostname [root @ wulmail ~] # service zabbix-agent startStarting Zabbix agent: [OK] [root@wulmail ~] # chkconfig zabbix-agent on [root@wulmail ~] # chkconfig-- list | grep zabbix-agentzabbix -agent 0: off 1: close 2: enable 3: enable 4: enable 5: enable 6: shut down the web side to add hosts
Due to the application of the template, all the things that need to be added manually after clicking add are completed automatically.
Templates can be built into the system or defined according to your own needs.
6. Macros and custom key macros: macro, default text replacement mode; two: built-in custom {$MACRO} naming methods: uppercase letters, numbers and underscores; level: global template host-> template-- > global
Global macro
Customize a {HTTP_PORT} global macro for testing
Template macro
Host macro
The host defines a macro for testing
User-defined key location: implemented on the zabbix agent side Zabbix_agentd.conf UserParameter syntax format: UserParameter=, usage example: monitoring memory information UserParameter=memory.usage [*], cat / proc/meminfo | awk'/ ^ $1zabbix_agentd.conf UserParameter / {print $2} 'Monitoring nginx status page UserParameter=ngx.active [*], curl-s http://$1:$2/$3 | awk' / ^ Active/ {print $3} 'UserParameter=ngx.accepts [*], curl-s http://$1:$2/$3 | awk' / ^ [: space:]]
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.