linux--Monitoring Service Zabbix deployment (on top of LNMP architecture), service provisioning, data monitoring and alarm automation

Source: Internet
Author: User
Tags configuration settings

First install LNMP According to the process of the previous article
http://blog.51cto.com/13859004/2170379
1. To install the agent\ on the monitored host
Restarting the server host

[[email protected] ~]# zabbix_server[[email protected] ~]# zabbix_agentd[[email protected] ~]# apachectl start[[email protected] ~]# systemctl mysqld start[[email protected] ~]# /etc/init.d/mysqld startStarting MySQL SUCCESS![[email protected] ~]# service php-fpm restart

New host

[[email protected] ~]# yum-y install net-snmp-devel libevent-devel[[email protected] ~]# cd/usr/src/[[email  protected] ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/ Zabbix-3.4.12.tar.gz[[email protected] ~]# tar XF zabbix-3.4.12.tar.gz[[email protected] ~]# groupadd-r Zabbix[[email protected] ~]# useradd-r-G zabbix-m-s/sbin/nologin zabbix[[email protected] ~]# cd/usr/src/z Abbix-3.4.12[[email protected] zabbix-3.4.12]# yum-y install gcc gcc-c++[[email protected] zabbix-3.4.12]# ./configure--enable-agent[[email protected] zabbix-3.4.12]# make install[[email protected] zabbix-3.4.12 ]# ls/usr/local/etc/zabbix_agentd.conf zabbix_agentd.conf.d//Client Parameters server,serveractive,hostname[[email  Protected] zabbix-3.4.12]# vim/usr/local/etc/zabbix_agentd.confserver=192.168.56.11 (destination server domain name or IP) serveractive= 192.168.56.11 (destination server domain name or IP) hostname=192.168.56.138 (the name is arbitrary, but must be the same as the name of the configuration page) #AllowRoot =0(whether the root user is allowed to log on, the default 0 = Not allowed, no changes required) [[email protected] zabbix-3.4.12]# zabbix_agentd[[email protected]                        zabbix-3.4.12]# ss-anltstate recv-q send-q Local address:port Peer address:port                  LISTEN 0 *:10050 *:* Create the directory you want to monitor first [[email protected] ~]# touch/etc/guohui[[email protected] ~]# echo ' Guohui ' >/etc/guohui

2.web interface Configuration steps
1. Build the host group because there are no hosts, so create an empty set.

2. Add the host to the corresponding main group
3. Configuring the Host

Template selected Linux, add, click Update.
Host is configured

4. Configure monitoring items, or you can create monitoring items

Configuring triggers

Graphics

5. Configuring Alarm Information

Look (-K), System.uptime, see how long it started.

[[email protected] ~]# zabbix_get -s 192.168.56.138 -k system.uptime39623


6. Send an email
Configuration-action: What to do, send xxx or mail, to use what hair
Management-Alarm Media: Configuration How to alarm, with who hair, how to hair
Mode 1: Use Zabbix to set up alerts to send messages

Set the recipient, click on the user name to enter the

For triggers, edit actions

Edit the/etc/guohui first, and then view the dashboard.

View Mailbox

Method 2: Use server-side configuration settings to alert outgoing messages
Install mail, change configuration

[[email protected] ~]# vim /etc/mail.rcset [email protected]set smtp=smtp.163.comset [email protected]set smtp-auth-password=shsj123set smtp-auth=loginyum -y install malixecho ‘信息‘ | mail -s ‘标题‘  [email protected]

Write a Send script to enter the Zabbix server configuration file

[[email protected] ~]# vim /usr/local/etc/zabbix_server.conf# AlertScriptsPath=${datadir}/zabbix/alertscripts     //AlertScriptsPath=设置告警脚本存放路径AlertScriptsPath=/opt/alertscripts                             //更换位置//创建位置[[email protected] ~]# mkdir /opt/alertscripts             [[email protected] ~]# chown -R zabbix.zabbix /opt/alertscripts       赋予权限[[email protected] ~]# cd /opt/alertscripts//发送邮件的脚本,subject(主题),messages(内容),$1收件人tr   替换\r\n window换行\n   linux换行[[email protected] alertscripts]# vim mail.sh#!/bin/bashmessages=`echo $3 | tr ‘\r\n‘ ‘\n‘`subject=`echo $2 | tr ‘\r\n‘ ‘\n‘`echo "${messages}" | mail -s "${subject}" $1 >>/tmp/sendmail.log 2>&1//设置脚本的属主属组,给与执行权限[[email protected] alertscripts]# chown -R zabbix.zabbix mail.sh[[email protected] alertscripts]# chmod +x mail.sh

On the Zabbix side Action option operation,

Change

How to change

Test

[[email protected] ~]# echo ‘guohui‘ >> /etc/guohui

View Dashboard, Delivered

If you cannot receive a whitelist that can be set

Custom Monitoring Scripts

First modify the client configuration file, start (#), and modify the Unsafeuserparameters to 1

UnsafeUserParameters=0 默认关闭的自定义监控UnsafeUserParameters=1 表示启用自定义监控[[email protected] etc]# vim /usr/local/etc/zabbix_agentd.confUnsafeUserParameters=1添加UserParameter,关键字UserParameter=users,/bin/bash /scripts/users.sh    

Write a monitoring script

[[email protected] etc]# who | wc -l              //查看有几个用户2[[email protected] etc]# mkdir /scripts//创建脚本,用户超过3则是1,其他则是0[[email protected] etc]# vim /scripts/users.sh#!/bin/bashcur=$(who | wc -l)if [ $cur -gt 3 ];then    echo ‘1‘else    echo ‘0‘fi[[email protected] etc]# chmod +x /scripts/users.sh             //给执行权限[[email protected] etc]# chown -R zabbix.zabbix /scripts/     //赋予属主属组重启客户端[[email protected] etc]# pkill zabbix[[email protected] etc]# zabbix_agentd
服务器端,因为用户不过3,现在是0[[email protected] alertscripts]# zabbix_get -s 192.168.56.138 -k users0

Monitoring Item Settings



Create a Trigger

Number of users over 3

Alert Alert already

Receive mail
Client authorization password can be obtained in 163 mailbox
Where do you want the mail to be sent from?

linux--Monitoring Service Zabbix deployment (on top of LNMP architecture), service provisioning, data monitoring and alarm automation

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.