1.进程监控
在web客服端编写脚本 取出需要监控资源的状态值
//创建目录
[root@web ~]# mkdir /scripts
//编写内容脚本
[root@web ~]# vim /scripts/check_process.sh
[root@web ~]# cat /scripts/check_process.sh
#!/bin/bash
status=$(ps -ef |grep $1|grep -Ev "$0|grep"|wc -l)
if [ $status -eq 0 ];then
echo '1'
else
echo '0'
fi
//给执行权限
[root@web ~]# chmod +x /scripts/check_process.sh
//查看
[root@web ~]# ll /scripts/check_process.sh
-rwxr-xr-x 1 root root 129 Sep 7 01:04 /scripts/check_process.sh
[root@web ~]#
1.1在agent客服端编写配置文件
//将下面两行取消注释作修改,或者直接添加这两行
[root@localhost ~]# vim /usr/local/etc/zabbix_agentd.conf
# Mandatory: no
# Range: 0-1
# Default:
UnsafeUserParameters=1 //取消注释 改为1
### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
# See 'zabbix_agentd' directory for examples.
#
# Mandatory: no
# Default:
UserParameter=check_process[*],/bin/bash /scripts/check_process.sh $1 //取消注释写入内容
//重启agent,生效作更改的配置
[root@web ~]# pkill zabbix_agentd
[root@web ~]# zabbix_agentd
[root@web ~]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@web ~]#
//安装httpd服务
[root@web ~]# yum -y install httpd
[root@web ~]# systemctl start httpd
[root@web ~