如何配置 zabbix 根据网络设备日志报警

如何配置 zabbix 根据网络设备日志报警

我这里配置的是如果交换机的端口出现down的情况,钉钉给与报警,并给出是哪个端口出现异常的信息。

一、rsyslog服务配置
server的操作系统是centos6.5
服务器上启动rsyslog
yum -y install rsyslog
编辑配置文件:/etc/rsyslogd.conf,添加以下内容
#启用udp 514端口监听。
$ModLoad imudp
$UDPServerRun 514
#配置交换机日志保存文件  说明:x.x.x.x为交换机ip
:fromhost-ip,isequal, "192.168.1.248"              /var/log/xx_switch248.log
:fromhost-ip,isequal, "192.168.1.246"              /var/log/B4_switch246.log
:fromhost-ip,isequal, "192.168.1.200"              /var/log/B4_switch200.log
重启rsyslog服务
service rsyslog restart

二、配置交换机(华为交换机)

方法1:

配置交换机日志推送到日志主机: eg:日志主机IP地址:10.172.49.1
system-view
info-center channel 6 name loghost1
info-center source default channel loghost1 log state on
info-center loghost source *******
info-center loghost 10.172.49.1 channel loghost1
方法2:
#指定发送消息基本,表示从0-7都发送
info-center source default channel 2 log level debugging
#指定从哪个接口发送
info-center loghost source *******
#指定远程syslog服务器ip
info-center loghost 10.172.49.1
我采用的是如下的配置:
info-center source default channel 2 log level debugging
info-center loghost source Vlanif2
info-center loghost 192.168.1.241

三、 配置zabbix
1.底层配置item
 cat /etc/zabbix/zabbix_agentd.d/userparameter_sw_log.conf  ,内容如下:
UserParameter=switch_syslog_248,/etc/zabbix/scripts/huawei/checklog.sh
UserParameter=switch_syslog_246,/etc/zabbix/scripts/huawei/checklog246.sh
UserParameter=switch_syslog_200,/etc/zabbix/scripts/huawei/checklog200.sh
-----------------------------------------
 cat /etc/zabbix/scripts/huawei/checklog200.sh
#!/bin/sh
key=`cat /var/log/B4_switch200.log | grep "down" | grep "Ethernet" | awk  '{print $12"\t"$13}'`
echo $key
if [ -s /var/log/B4_switch200.log ] ;
then
cat /var/log/B4_switch200.log >> /var/log/B4_switch200.log_backup
echo "" > /var/log/B4_switch200.log
fi

{print $12"\t"$13}'等key参数 需要根据自己的设备和要求进行调整
重启zabbix-agent
service zabbix-agent restart
2 界面上配置item

根据自己的情况进行参数输入

3 配置tigger


触发条件如下:
{192.168.3.2:switch_syslog_200.strlen()}>0

猜你喜欢

转载自blog.csdn.net/wzlsunice88/article/details/113756915