Zabbix custom monitoring and alarm (such as writing scripts to monitor hard disk, raid, power supply)

1. Install the agent
2. Create a new configuration file in the directory /etc/zabbix/zabbix_agentd.d, such as check_machine.conf, and write the script and return parameters according to the items you monitor.
Note: The full path of the script is best, and the return parameters such as disk.check.xor should be in
zabbix. UserParameter=disk.check.xor,/opt/MegaRAID/MegaCli/MegaCli64 -pdlist -a0 | grep -w Online | wc -l
UserParameter =raid.check.xor,/opt/MegaRAID/MegaCli/MegaCli64 -LDinfo -LALL -a0 | grep -w Optimal | wc -l
UserParameter=power.check.xor,/usr/sbin/dmidecode | grep -w Safe | wc -l
3. Restart the agent and test
according to the version of the operating system.
Centos 6.5 restart script
service zabbix-agent restart
test, if the return value is the same as your own estimate, the configuration is correct:
test on this machine
zabbix_agentd -t disk.check.xor
is tested on zabbix server
/usr/local/zabbix-server/bin/zabbix_get -s 192.168.3.2 -p 10050 -k disk.check.xor
Four. Configure on zabbix

1 Add item to the host you monitor

2 Enter the parameters and configure them according to your own requirements. The key must be consistent with the parameters in the configuration file check_machine.conf.

3. The status must be enabled. If it is not enable, please check various configurations and find the reasons.

4. According to your requirements, enter the conditions that trigger the alarm.

5. How to deal with the problem of incorrect return value
1. Modify the configuration file of the agent and add
AllowRoot=1 to
restart the agent.
This time the return value cannot be returned correctly. This is related to this configuration. After the configuration, the correct value can be obtained. .
2. It may be that sudo does not allow remote execution. Just comment one line in /etc/sudoers. The following
#Defaults requiretty #This line of comments is fine
. 3. This agent cannot obtain data by executing zabbix_get from the server. It may be that the configuration file is not configured correctly. Add
Server=127.0.0.1 to the configuration file and
restart agentd with ServerIP .

Six related commands

 The zabbix command: zabbix_get command
zabbix_get command is a command used to check the agent side on the server side. After adding the host or trigger, the data cannot be obtained normally. You can use zabbix_get to check whether the data can be collected in order to determine the crux of the problem .
zabbix_get parameter description:
-s --host: specify the client host name or IP
-p --port: client port, default 10050
-I --source-address: specify the source IP, write the ip address of the zabbix server , Generally leave it blank, if the server has multiple IPs, you can specify one.
-k --key: The key you want to get is whether you want to
use long parameters or short ones. Choose by yourself. I often use -s instead of -host.
If you don't know the key parameter, you can use zabbix_agentd -p to find the parameter you want to find
[ root@host~]# zabbix_agentd -p | grep system.cpu.load
system.cpu.load[all,avg1] [d|0.040000]
If you don’t know where zabbix_get is, you can use find / -name zabbix_get to find
[root@ host ~]# find / -name zabbix_get
/usr/local/zabbix/bin/zabbix_get
/data/tools/zabbix-4.0.3/src/zabbix_get
/data/tools/zabbix-4.0.3/src/zabbix_get/zabbix_get
/usr/local/zabbix-server/bin/zabbix_get -s 192.168.3.2 -p 10050 -k sanguo.check.ssh

Guess you like

Origin blog.csdn.net/wzlsunice88/article/details/111470085