In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Compile and install zabbix2.4 on centos6.5
The zabbix server installation node is: 192.168.1.36
The monitored host node is 192.168.1.37
Originally wanted to install zabbix3.0 on centos6.5, did not expect to install to the first step can not go on, Baidu, Google for a long time did not find the answer, many people also encountered the same problem: that is to enter the web page of zabbix, the first step to click on the next step, the phenomenon is that after the page refresh, there is no next step, so, had to give up, modified zabbix2.4.
Another failure is that we originally planned to use the corporate official account to conduct the zabbix alarm experiment of Wechat, but also failed until test, suffering from being unable to find a solution, so we had to use the Wechat enterprise account to conduct the zabbix alarm experiment, which had more online documents.
Therefore, the above problems can not be solved, so we have to bypass the problems and make the experiment successful.
Server side IP:192.168.1.36 of zabbix
IP:192.168.1.37 on the Agent side of zabbix
The premise is that the firewall and selinux of both hosts are turned off:
] # service iptabels stop
] # vim / etc/sysconfig/selinux
SELINUX=disabled
Install the basic software package in server, where the environment is installed using yum, and it is possible to install it using source code
] # yum-y install wget vim tree gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp net-snmp-devel curl-devel
Start httpd and mysql and set it to boot automatically
] # service httpd start
] # service mysqld start
] # chkconfig httpd on
] # chkconfig mysqld on
If iptables is set up in actual production, you can refer to the following settings:
] # iptables-I INPUT-p tcp-m multiport-- destination-port 80 10050 tcp 10051-j ACCEPT
] # iptables-L-n
Chain INPUT (policy ACCEPT)
Target prot opt source destination
ACCEPT tcp-0.0.0.0Compact 0 0.0.0.0Compare 0 multiport dports 80 10050purl 10051
ACCEPT all-0.0.0.0Universe 0 0.0.0.0Universe 0 state RELATED,ESTABLISHED
ACCEPT icmp-- 0.0.0.0Universe 0 0.0.0.0Universe 0
ACCEPT all-- 0.0.0.0Universe 0 0.0.0.0Universe 0
ACCEPT tcp-0.0.0.0Universe 0 0.0.0.0Universe 0 state NEW tcp dpt:22
REJECT all-0.0.0.0Universe 0 0.0.0.0Universe 0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
Target prot opt source destination
REJECT all-0.0.0.0Universe 0 0.0.0.0Universe 0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
Target prot opt source destination
# Save iptables rules
] # service iptables save
Iptables: Saving firewall rules to / etc/sysconfig/iptables: [OK]
three。 Configure PHP parameters
The operation of zabbix needs to be supported by specific php parameters, which is modified as follows
] # sed-I "sdate.timezone = @ date.timezone = Asia/Shanghai@g" / etc/php.ini
] # sed-I "s@max_execution_time = 30@max_execution_time = 300g" / etc/php.ini
] # sed-I "s@post_max_size = 8M@post_max_size = 32M@g" / etc/php.ini
] # sed-I "s@max_input_time = 60@max_input_time = 300g" / etc/php.ini
] # sed-I "s@memory_limit = 128M@memory_limit = 128M@g" / etc/php.ini
] # sed-I "swarming with mbmbstring.functionally overload = 0@ambstring.func_overload = 2millig" / etc/php.ini
Modify the FQDN error of httpd and restart the httpd service
] # echo "ServerName localhost:80" > > / etc/httpd/conf/httpd.conf
] # / etc/init.d/httpd restart
four。 Download zabbix-2.4.5.tar.gz
Https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz/download?use_mirror=jaist
five。 Add zabbix users and groups
] # groupadd-g 201 zabbix
] # useradd-g zabbix-u 201-s / sbin/nologin zabbix
six。 Install the zabbix-server side
] # tar xf zabbix-2.4.5.tar.gz
] # cd zabbix-2.4.5
] # / configure-- prefix=/usr/local/zabbix-- enable-server-- enable-proxy-- enable-agent-- with-mysql=/usr/bin/mysql_config-- with-net-snmp-- with-libcurl,
] # make & & make install
# create zabbix database and related tables
] # mysql-e "create database zabbix default charset utf8;"
] # mysql-e "grant all on zabbix.* to zabbix@localhost identified by 'zabbix';"
] # mysql-uzabbix-pzabbix zabbixzabbix.sql
] # sed-I's Universe latin1 zabbix.sql UTF8 Universe
two。 Delete zabbix database
> drop database zabbix
3. Close the mysql database and set the default character set
] # service mysqld stop
# add character set parameters to the mysql configuration file
] # vim / etc/my.cnf
[mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
Default-character-set = utf8
User=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
[mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
4. Start mysql and restore the zabbix database
] # service mysqld start
] # mysql
> create database zabbix
> show create database zabbix
> show databases
> use zabbix
> source zabbix.sql
Test whether the communication between the agent side and the server side is normal
] # zabbix_get-s127.0.0.1-p10050-k "system.uptime"
65819
Note: because the server side and the server side are installed on the zabbix server, you can test it locally.
If there is an output, the communication is normal.
Note: zabbix monitors server natively. You need to set zabbix-server monitoring on the page before you can enable the zabbix server side to monitor yourself.
According to the following figure:
Finally, click the "add" button.
At this point, wait a moment, it should be in the test-- "Dashboard page, you can see."
The screenshot here shows that there are two hosts that have been monitored in green, because at the time of writing this blog, the whole experiment has been done and another monitoring host has been added, so it shows that two hosts (including the zabbix host and an agent host) have been monitored.
twelve。 Install zabbix on the client side 192.168.1.37
Install the basic software package
] # yum install wget vim tree gcc gcc-c++-y
Groupadd-g 201 zabbix
Useradd-g zabbix-u 201-s / sbin/nologin zabbix
Tar xf zabbix-2.4.5.tar.gz
Cd zabbix-2.4.5
# start compiling and installing zabbix client
. / configure-prefix=/usr/local/zabbix-enable-agent
] # make & & make install
# create a log directory for zabbix
] # mkdir / var/log/zabbix
] # chown zabbix.zabbix / var/log/zabbix
# copy the zabbix_agentd startup file to the / etc/init.d directory
] # cp misc/init.d/fedora/core/zabbix_agentd / etc/init.d/
] # chmod 755 / etc/init.d/zabbix_agentd
# release ports 10050 and 10051 in iptables
] # iptables-I INPUT-p tcp-m multiport-- dports 10050 tcp 10051-j ACCEPT
] # service iptables save # Save iptables rules
# View iptables results
] # iptables-L-n
Chain INPUT (policy ACCEPT)
Target prot opt source destination
ACCEPT tcp-- 0.0.0.0amp 0 0.0.0.0Compare 0 multiport dports 10050purl 10051
ACCEPT all-0.0.0.0Universe 0 0.0.0.0Universe 0 state RELATED,ESTABLISHED
ACCEPT icmp-- 0.0.0.0Universe 0 0.0.0.0Universe 0
ACCEPT all-- 0.0.0.0Universe 0 0.0.0.0Universe 0
ACCEPT tcp-0.0.0.0Universe 0 0.0.0.0Universe 0 state NEW tcp dpt:22
REJECT all-0.0.0.0Universe 0 0.0.0.0Universe 0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
Target prot opt source destination
REJECT all-0.0.0.0Universe 0 0.0.0.0Universe 0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
Target prot opt source destination
# modify startup file and configure soft connection
] # sed-I "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" / etc/init.d/zabbix_agentd
] # ln-s / usr/local/zabbix/etc/ / etc/zabbix
] # ln-s / usr/local/zabbix/bin/* / usr/bin
] # ln-s / usr/local/zabbix/sbin/* / usr/sbin/
# / etc/zabbix/zabbix_agentd.conf. The IP address here is the IP address on the zabbix_server side.
] # sed-I "s@Server=127.0.0.1@Server=192.168.3.28@g" / etc/zabbix/zabbix_agentd.conf
] # sed-I "s@ServerActive=127.0.0.1@ServerActive=192.168.3.28:10051@g" / etc/zabbix/zabbix_agentd.conf
] # sed-I "s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g" / etc/zabbix/zabbix_agentd.conf
] # sed-I "s @ ^ # UnsafeUserParameters=0@UnsafeUserParameters=1\ ng" / etc/zabbix/zabbix_agentd.conf
] # egrep-v'^ $| ^ #'/ etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.1.36
ServerActive=192.168.1.36:10051
Hostname=Zabbix server
UnsafeUserParameters=1
# set zabbix_agentd to boot automatically and start the zabbix_agentd service
] # chkconfig zabbix_agentd on
] # service zabbix_agentd start
After setting up on the command line of the monitored host, you can add the monitoring host on the web management page of zabbix.
Add steps, which are the same as those for monitoring zabbix natives, and will not be repeated here.
English guide: Configuration → Hosts → Create host
What I want to say here is that when adding a monitored host, the host name and IP address should be written on the monitored host.
Then, click Configuration → Hosts's template add template (select)
After adding, click Configuration → Hosts effect, Z turns green and OK.
At this point, the basic construction of zabbix is complete, and then it is the key Wechat alarm.
eleven。 Set the Wechat enterprise account
To apply for the https://qy.weixin.qq.com/ address, just follow the steps step by step.
This Wechat enterprise account is also a document found on the Internet. Anyway, you can register an enterprise number yourself, scan it with your mobile phone, and enter your personal × × number and mobile phone number. Basically is the mouse operation, there is no difficulty, at most the wrong point, click again.
Source of reference document: http://mxlmgl.blog.51cto.com/9834691/1831695
Enter the address Book, click the plus sign next to organizational structure, and click add member
Note: the account here is equivalent to your enterprise account and has nothing to do with WeChat account.
You must create a user here and fill in the correct WeChat account or mobile phone number before you can follow the enterprise number by scanning the QR code.
I'm crystal here (this will be used later in the script parameters)
How to follow the Enterprise account: click "Settings"-QR code on the left, and scan the QR code using Wechat.
Click "Tencent App Center" in the left column, and click the icon zabbix of "self-built Apps"
Note: when creating the application, I uploaded pictures of beautiful women. I loser likes to see beautiful women, .
One value to keep in mind here: apply ID, and you need to fill in the following configuration.
Settings-feature Settings-Rights Management-New Management Group
The administrator must have paid attention to the enterprise account in advance and set up the email address.
Added system groups:
Pay attention to the application permissions, address book permissions
Note: note that it will be used in the configuration behind CorpID and Secret below.
Here's the point:
Http://qydev.weixin.qq.com/debug Wechat Enterprise Interface debugging tool (see if the API can be called successfully)
Fill in the CorpID and Secret here and access_token will appear.
Fill in the information obtained in the previous steps and click to check the question:
After testing, the following message will continue to appear: (ok indicates success)
When the result is returned, copy the contents in the red box, which will be used in the next step.
Then the interface type is changed to send a message
Fill in the information:
The access_token here has been obtained in the previous step. The key point is body. After looking at the official format editor, it is summarized as follows:
{
"touser": "crystal"
"toparty": "PartyID1 | PartyID2"
"totag": "TagID1 | TagID2"
"msgtype": "text"
"agentid": 1
"text": {
"content": "lala (http://xxxxx)"
}
"safe": "0"
}
Here, you need to change the value of touser (crystal) into your own employee account.
Click to check the problem
Then you can receive the message on Wechat Enterprise account, which reads lala (http://xxxxx)).
The above proves that there is no problem with the API call, and then it's time to go to the script.
First of all: where to put the script
/ usr/local/zabbix/share/zabbix/alertscripts
Chown zabbix.zabbix / usr/local/zabbix/share/zabbix/alertscripts/weixin.sh
Chmod + x / usr/local/zabbix/share/zabbix/alertscripts/weixin.sh
All right, let's serve the main course:
] # vim / usr/local/zabbix/share/zabbix/alertscripts/weixin.sh
#! / bin/bash
CorpID=wxef*7423 (code here)
Secret=PYzCHeqi3Jjbp06V*** (code here) _ cKoarAeSqn8pLls
GURL= "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret"
Gtoken=$ (/ usr/bin/curl $GURL-H "DNT: 1"-H "Accept-Encoding: gzip, deflate"-H "Accept-Language: zh-CN,zh;q=0.8"-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 BIDUBrowser/8.1 Safari/537.36"-H "Accept: text/html,application/xhtml+xml,application/xml Compressed 0.9 Cache-Control Cache-Control: max-age=0 "- compressed | awk-F\" {print $4}')
PURL= "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
Function body () {
Local int appId=1
Local userId=$1
Local partyId=1
Local tag=1
Local msg=$ (echo "$@" | cut-d ""-f3 -)
Printf'{\ n'
Printf'\ t "touser": "'" $userId "\",\ n "
Printf'\ t "toparty": "'" $partyId "\",\ n "
Printf'\ t "msgtype": "text",'"\ n"
Printf'\ t "totag": "'" $tag "\",\ n "
Printf'\ t "agentid": "'" $appId "\",\ n "
Printf'\ t "text": {\ n'
Printf'\ t\ t "content": "'" $msg "\"
Printf'\ n\ t},\ n'
Printf'\ t "safe": "0"\ n'
Printf'}\ n'
}
Body $1 $2 $3
/ usr/bin/curl-- data-ascii "$(body $1 $2 $3)" $PURL
Test method:
. / weixin.sh crystal 1 helloevery
Crystal is the user account (not WeChat account, but your name in the enterprise account)
1 this is the department's ID (or the application ID, mine is all 1)
Test: it's what you want to post.
The above content indicates that the script is executed successfully, and your Wechat enterprise account will receive the alarm content you sent, so we have succeeded in more than half of the time *. *
The above is the content received by Wechat.
The next thing we need to do is to set the alarm medium type and trigger action in the web interface.
Click Management (Administration)-Media Type (Mediatypes)-create Media Type (Create media type)
After filling in, you can see that an weixin has been added to the warning media type.
Next, click manage (Administration)-Users Create user
Next, click manage (Administration)-Users Create user
Select a user group:
At this point, do not click add, set the alarm media and then add.
Select the weixin you created:
Add at Media point
Type (ty) pe selects the weixin just defined
Recipient (send to): fill in your WeChat account
Next, change user_type to Super Admin in permissions
Click add, and the user has been added.
The next step is to create a trigger action
Default information:
Host: {HOST.NAME}
Time: {EVENT.DATE} {EVENT.TIME}
Status: {TRIGGER.STATUS}
Event: {TRIGGER.NAME}
Recovery information:
Server recovered.
Host: {HOST.NAME}
Time: {EVENT.DATE} {EVENT.TIME}
Status: {TRIGGER.STATUS}
Event: {TRIGGER.NAME}
In this way, when the server is restored, you can receive a message that begins with Serverrecovered, and you can know in time that the server is back to normal.
Conditions (Conditions) are ignored.
Note: you must complete the options in operations below before you can click add (ADD).
Press the add inside and then the add outside when filling in the options in the operations, otherwise an error will be reported.
Now that the configuration is complete, the monitored machine is now closed. Wait a minute. If Wechat receives a message, the configuration will be successful.
After waiting for less than 5 minutes, Wechat called the police and received it.
So far, the experiment is complete!
Burn incense, documents can be found online and can be successful!
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.