zabbix is a monitoring software, I use the version centos7.5
A: I've added a good host, the next step is to see how to view the content of monitoring
1. Open zabbix services web page
2. Detection of the latest data, to be screened in the latest data
3. View Image
Two: The above is the simplest way to see a client, then show you a custom monitor
1.zabbix comes with templates Template OS Linux (Template App Zabbix Agent) provide regular monitoring CPU, memory, disk, network cards, etc., plus a host of new long associated with this template, you can automatically add these items to monitor
Custom monitoring items, monitor items can be created before first use zabbix_get to determine whether the script is correct on zabbix server.
Using yum zabbix server installed at the end zabbix_get
Command: cd /etc/yum.repos.d/
Yum configuration source
Command: RPM -ivh HTTP: // repo .zabbix .com / zabbix / 3.2 / RHEL / 7 / x86_64 / zabbix-release- 3.2- 1.el7 .noarch .rpm
命令:yum -y install zabbix-get.x86_64
You can use zabbix_get -help to view usage
Note: zabbix_ only server operating
Then proceed
命令:zabbix_get -s 192.168.175.102 -p 10050 -k "system.uname"
Notes: IP -s client -p client port, default 10050 Key -k monitored items
2. implement custom monitoring
Custom Syntax
UserParameter=<key>,<shell command>
UserParameter=login-user,who|wc -l
UserParameter=login-user,/bin/sh /server/scripts/login.sh
3.agent registration (client)
Command: cd /etc/zabbix/zabbix_agentd.d/
命令:vim userparameter_login.conf
UserParameter=login-zabbix1,who|wc -l
UserParameter=login-zabbix2,who|wc -l
UserParameter=login-zabbix3,who|wc -l
Note: key name to be unique
Then restart the service
命令:systemctl restart zabbix-agent.service
Then tested on the server
命令:zabbix_get -s 192.168.175.103 -p 10050 -k "login-zabbix1"
命令:zabbix_get -s 192.168.175.103 -p 10050 -k "login-zabbix2"
命令:zabbix_get -s 192.168.175.103 -p 10050 -k "login-zabbix3"
Because the client signed up for three users, so there is no login-zabbix4, will error
4. Register (page operation) in the service side
(1) Click Configure ------> Click Template ------> Click to create a template
(2) completed in accordance with operational requirements
ceshi login-zabbix
(3) create a set of applications
Click Apply to set -----> Creating an application set
(4) Create a monitored item
Click monitored item ------> Create monitored item
(5) create a trigger
(6) Creating Graphics
Click on the graphic ------> Create graphics
(7) the host association template
Click Configuration ----> Host
A host can be associated with multiple templates
Test, while four zabbix open pages in the browser
I use Firefox add four, the Google browser would call the police, so that the configuration is successful
Three: monitoring alarm
(1) third-party alarm platform (nails)
First specify the group you want to send, create a robot in the group
Add Robot
Refer to "documentation"
Create a test document
vim ceshi.sh
curl 'https://oapi.dingtalk.com/robot/send?access_token=a462c4d7c2e095d182721c352b77cae4bc76ce4903efe876a08386668e451c51' \ # add your own WebHook
-H 'Content-Type: the Application / json' \
-d '{ "MsgType": "text",
"text": {
"Content": "alarm"
}
} '
then run the test, if successful sends messages on the nails
(2) Review the default script storage location
Command: cat /etc/zabbix/zabbix_server.conf|grep AlertScriptsPath
Command: cd / usr / lib / zabbix / alertscripts # to enter the default scripts directory
Note: The script is written in python python environment you need to configure the job
Command: yum -y install python-pip # install python
Command: pip install requests # install dependencies
Note: If the installation fails, configure yum Ali cloud sources
Command: mkdir ~ / .pip # Creating Ali cloud pip
Command: down to write the contents of vim /root/.pip/pip.conf #
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
See these instructions to install successfully, and then began to write the script
Command: vim /usr/lib/zabbix/alertscripts/dingding.py # follows
curl 'https://oapi.dingtalk.com/robot/send?access_token=a462c4d7c2e095d182721c352b77cae4bc76ce4903efe876a08386668e451c51' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text",
"text": {
"content": "告警"
}
}'
[root@localhost alertscripts]# cat dingding.py
#!/usr/bin/env python
#coding:utf-8
#zabbix钉钉报警
import requests,json,sys,os,datetime
webhook="https://oapi.dingtalk.com/robot/send?access_token=a462c4d7c2e095d182721c352b77cae4bc76ce4903efe876a08386668e451c51"
user=sys.argv[1]
text=sys.argv[3]
data={
"msgtype": "text",
"text": {
"content": text
},
"at": {
"atMobiles": [
user
],
"isAtAll": False
}
}
headers = {'Content-Type': 'application/json'}
x=requests.post(url=webhook,data=json.dumps(data),headers=headers)
if os.path.exists("/usr/local/zabbix/logs/dingding.log"):
f=open("/usr/local/zabbix/logs/dingding.log","a+")
else:
f=open("/usr/local/zabbix/logs/dingding.log","w+")
f.write("\n"+"--"*30)
if x.json()["errcode"] == 0:
f.write("\n"+str(datetime.datetime.now())+" "+str(user)+" "+"发送成功"+"\n"+str(text))
f.close()
else:
f.write("\n"+str(datetime.datetime.now()) + " " + str(user) + " " + "发送失败" + "\n" + str(text))
f.close()
Command: chown zabbix.zabbix dingding.py # add permissions
Command: mkdir -p / usr / local / zabbix / logs # add a message file
Command: touch /usr/local/zabbix/logs/dingding.log # add message documents
Command: chown -R zabbix.zabbix /usr/local/zabbix/logs/dingding.log # add permissions to the message document
Command: chown -R zabbix.zabbix / usr / local / zabbix / logs # add permissions to the message file
Then the test is not nailed to send a message
Command: ./ dingding.py test 185xxxxxxxx "The test pieces of information, ignoring"
Note: This number means that there are groups that you send this number, quotes the content is in keywords nails in settings
(3) Set the page in zabbix
Three parameters
. Creating alarm intermediary three parameters are: ALERT.SENDTO ALERT.SUBJECT ALERT.MESSAGE
{ALERT.SENDTO}
{ALERT.SUBJECT}
{} ALERT.MESSAGE
Next configuration actions
Click Configuration ------> Action
{TRIGGER.STATUS}: {TRIGGER.NAME}
Alarm Host: {HOST.NAME}
Host IP: {HOST.IP}
Alarm Time: {EVENT.DATE} {EVENT.TIME}
alarm level: {TRIGGER.SEVERITY}
alarms: {TRIGGER.NAME}
details of the problem: {ITEM .NAME}: {ITEM.VALUE}
current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
event ID: {EVENT.ID}
FIG 5 showing the operation of the trigger, the trigger once every 120 seconds, an alarm issued admin users, nail transmission medium.
Recovery parameters
{TRIGGER.STATUS}: {TRIGGER.NAME}
Alarm Host: {HOST.NAME}
Host IP: {HOST.IP}
Alarm Time: {EVENT.DATE} {EVENT.TIME}
alarm level: {TRIGGER.SEVERITY}
alarms: {TRIGGER.NAME}
details of the problem: {ITEM .NAME}: {ITEM.VALUE}
current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
event ID: {EVENT.ID}
Other default
The test machine at the virtual machine, pop-up warning on nails, ok complete
to sum up:. . . . . . . . . . . Omitted here a million words