二:监控httpd服务
[root@server etc]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.200.11
ServerActive=192.168.200.11
stname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1
UserParameter=mysql.version,mysql -v
UserParameter=mysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1
UserParameter=mysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.200.11 ping | grep -c a
live
UserParameter=httpd.status,/usr/local/zabbix/etc/chk_httpd.sh #添加一条引用httpd的脚本
[root@server etc]# vim chk_httpd.sh #准备脚本
#!/bin/bash
#检查httpd服务是否正常运行,正常输出1不正常输出2
netstat -lnupt | grep -q :80
if [ $? -eq 0 ];then
echo "1"
else
echo "0"
fi
~
[root@server etc]# chmod 777 chk_httpd.sh #给脚本加权限
#重启zabbix_agentd服务
[root@server etc]# killall -9 zabbix_agentd
[root@server etc]# zabbix_agentd
[root@server etc]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.11 -k httpd.status
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
1
[root@server etc]# which netstat
/usr/bin/netstat
[root@server etc]# chmod u+s /usr/bin/netstat
[root@server etc]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.11 -k httpd.status
1
添加图形
创建触发器
三:磁盘监控
[root@server ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.200.11
ServerActive=192.168.200.11
Hostname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
UnsafeUserParameters=1
UserParameter=mysql.version,mysql -v
UserParameter=mysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1
UserParameter=mysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.200.11 ping | grep -c alive
UserParameter=httpd.status,/usr/local/zabbix/etc/chk_httpd.sh
UserParameter=sdb1.used,df -hT| awk -F'[ %]' 'NR==7{ print $(NF-2)}' #引入命令
#重启服务
[root@server ~]# killall -9 zabbix_agentd
[root@server ~]# zabbix_agentd
[root@server ~]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.11 -k sda1.used
17