标签:log 自定义 0.0 zabbix 监控 scripts 139 root
1.环境说明:
环境 | ip | hostname | 要安装的应用 |
服务器 | 192.168.59.131 | server | lamp架构 zabbix server zabbix agent |
客户端 | 192.168.59.133 | 139 | zabbix agent |
2.网页配置主机
监控进程
客户端: 打开自定义监控的功能
[root@139 ~]# cd /usr/local/etc [root@139 etc]# ls zabbix_agentd.conf zabbix_agentd.conf.d [root@139 etc]# vim zabbix_agentd.conf UnsafeUserParameters=1
UserParameter=check_process[*],/bin/bash /scripts/check_process.sh $1
#重启服务
[root@139 etc]# pkill zabbix
[root@139 etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@139 etc]# zabbix_agentd
[root@139 etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
创建目录编写脚本
[root@139 etc]# mkdir /scripts [root@139 etc]# ls / bin/ dev/ home/ lib64/ mnt/ proc/ run/ scripts/ sys/ usr/ boot/ etc/ lib/ media/ opt/ root/ sbin/ srv/ tmp/ var/ [root@139 etc]# cd /scripts/ [root@139 scripts]# vim check_process.sh #!/bin/bash process_status=$(ps -ef|grep -Ev "grep|$0"|grep -c $1) if[$process_status -eq 0 ];then echo '1' else echo '0' fi #添加执行权限 [root@139 scripts]# chmod +x check_process.sh
监控端验证
[root@139 etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@server ~]# zabbix_get -s 192.168.59.133 -k check_process['httpd'] 0
网页配置监控项
验证
停止http服务后
监控log日志文件
验证脚本
[root@139 script./log.py /var/log/httpd/error_log_log 0 [root@139 scripts]# echo 'Error' >> /var/log/httpd/error_log [root@139 scripts]# echo 'qwe' >> /var/log/httpd/error_log [root@139 scripts]# echo 'qwe' >> /var/log/httpd/error_log [root@139 scripts]# echo 'qwe' >> /var/log/httpd/error_log [root@139 scripts]# echo 'qwe' >> /var/log/httpd/error_log [root@139 scripts]# ./log.py /var/log/httpd/error_log 1
添加配置文件
[root@139 scripts]# vim /usr/local/etc/zabbix_agentd.conf UserParameter=check_log[*],/scripts/log.py $1 $2 $3 #重启服务 [root@139 scripts]# pkill zabbix [root@139 scripts]# zabbix_agentd
#添加权限
[root@139 ~]# setfacl -m u:zabbix:rx /var/log/httpd/
到服务器监控
[root@server ~]# zabbix_get -s 192.168.59.133 -k check_log['/var/log/httpd/error_log'] 1
网页端配置
验证
[root@139 scripts]# echo 'Error' >> /var/log/httpd/error_log
标签:log,自定义,0.0,zabbix,监控,scripts,139,root 来源: https://www.cnblogs.com/Mariko/p/14801411.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。