安全5(简)

foxmail-------->163.com(设置)
outlook

工作中一般可以写5分钟发一个邮件,设置时间不要太短
##############################################################
# ps aux |grep zabbix
zabbix 4100 0.0 0.0 22976 760 ? S 11:47 0:00 zabbix_agentd
zabbix 4101 0.0 0.0 22976 812 ? S 11:47 0:00 zabbix_agentd: collector [idle 1 sec]
zabbix 4102 0.0 0.0 22976 848 ? S 11:47 0:00 zabbix_agentd: active checks #1 [idle 1 sec]
root 4115 0.0 0.0 112676 984 pts/0 R+ 11:49 0:00 grep --color=auto zabbix
##############################################################
常见报错:Zabbix discoverer processes more than 75% busy

解决办法:vim /usr/local/etc/zabbix_server.conf
... ...
StartDiscoverers=5 打开这行的注释,改数值
... ...
StartPollers=10 打开这行的注释,改数值
... ...
##############################################################
-s是silence,安静。

不加-s,会显示很多其他的东西
# curl http://192.168.2.100/status | awk '/Active/{print $3}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 100 100 100 0 0 63251 0 --:--:-- --:--:-- --:--:-- 97k
1

加了-s,就会干净了。
# curl -s http://192.168.2.100/status | awk '/Active/{print $3}'
1
##############################################################
web1被监控主机

# vim /usr/local/bin/nginx_status.sh
#!/bin/bash

case $1 in
active)
curl -s http://192.168.2.100/status | awk '/Active/{print $3}'
tcp)
curl -s http://192.168.2.100/status | awk 'NR==3{print $1}'
wait)
curl -s http://192.168.2.100/status | awk '/Waiting/{print $NF}'
##############################################################
web1被监控主机

# chmod +x /usr/local/bin/nginx_status.sh
# /usr/local/bin/nginx_status.sh active
# /usr/local/bin/nginx_status.sh tcp
# /usr/local/bin/nginx_status.sh wait
##############################################################
常见报错,在被监控的主机上看时会报错。
# zabbix_get -s 192.168.2.100 -k nginx.status[a]
zabbix_get [15823]: Check access restrictions in Zabbix agent configuration

解决方法:要在服务器上看,不要在被监控的主机上看。
# zabbix_get -s 192.168.2.100 -k nginx.status[tcp]
25
###############################################################
web1被监控主机

# ss -anltp | grep :22
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1080,fd=3))
LISTEN 0 128 :::22 :::* users:(("sshd",pid=1080,fd=4))

少了l,不仅看正在监听的端口,还看没有监听的端口。信息更全。
# ss -antp | grep :22
LISTEN 0 128 *:22 *:* users:(("sshd",pid=1080,fd=3))
ESTAB 0 0 192.168.2.5:22 192.168.2.254:55695 users:(("sshd",pid=1470,fd=3))
LISTEN 0 128 :::22 :::* users:(("sshd",pid=1080,fd=4))
################################################################
web1被监控主机

# vim /usr/local/bin/net_status.sh
#!/bin/bash
case $1 in
estab)
ss -antp | grep ^ESTAB | wc -l;;
wait)
ss -antp | grep ^TIME-W | wc -l;;
esac
################################################################
web1被监控主机
# chmod +x /usr/local/bin/net_status.sh
# /usr/local/bin/net_status.sh estab
1
# /usr/local/bin/net_status.sh wait
49


# vim /usr/local/etc/zabbix_agentd.conf.d/net.status
UserParameter=net.status[*],/usr/local/bin/net_status.sh $1

# killall zabbix_agentd
# zabbix_agentd
################################################################
zabbix_server主机

# zabbix_get -s 192.168.2.100 -k net.status[wait]
44
# zabbix_get -s 192.168.2.100 -k net.status[estab]
2

 

posted @ 2019-04-30 22:56  安于夏  阅读(151)  评论(0编辑  收藏  举报