re2212 发表于 2015-2-9 09:53:25

Zabbix监控网络设备日志文件及字段报警

Zabbix监控网络设备日志文件及字段报警

一、首先就是配置网络设备日志传送到zabbix存放日志的指定目录,一般目录为/var/log/
需要配置rsyslog.conf
根据需求添加tcp或者udp或者都添加字段# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
添加定义存放目录文件字段:
# Save Debug Message of Netscreen(x.x.x.65) to ns.log
local1.*                                          /var/log/juniper.log//日志存放位置

做完最好重启一下服务:
/etc/init.d/rsyslog restart


二、创建一个日志文件监控项目
在这里借用zabbix server主机,添加log项,进行监控。

1,选择applications 单机→create application;名字定义Log,单机Add 完成。

2,选择Items 单机→create item;
Name:定义代表性
Type :选择Zabbix agent(active)
Key:key就是log日志文件存放的目录加文件名,例:log
Type of information:选择Log
Applications:选择刚才定义好的Log
Enabled:勾选
update:单机,完成。

三、查看日志;
主页→Monitoring→Latest data

Hosts:→select 单机选择zabbix server ;
Applicaton:→select 单机选择Log(上边定义好的)
单机Filter,出现如下:



单机history 即可查看防火墙的所有日志了。

如果觉得不太好看,还有一种text的网页形式:
单机As plain text

看效果:

四、定义Triggers;重新回到界面:
选择Triggers→单机create trigger
Name:定义有代表意义的
Expression:语句参考如下,我这里是定义有字符串alerts的进行报警
(({Zabbix server:log.iregexp(alerts)})<>0)
多个条件如下:
((({Zabbix server:log.iregexp(login)})<>0) or
(({Zabbix server:log.iregexp(Close)})<>0))

Multiple PROBLEM events generation:勾选:代表多次报警的时候发送多次报警邮件;不勾选:代表多次报警只发送一次,其中间隔看个人action设置
Description:描述
Severity:根据报警信息所定义的报警级别
Enabled:勾选,启用该触发
单机update 完成

主页→Monitoring→Triggers 可以查看当前系统所有的触发信息。
可以自己定义一些容易出现的字段做测试。


l zabbix显示日志信息不及时,或者显示不全,就到查看日志去,如下:
zabbix_server.log 日志提示如下信息:

“please increase ValueCacheSize configuration parameter”

缓存不足,默认是8M
解决办法:

打开zabbix_server.conf 找到 Option: CacheSize
把原来的 # CacheSize=8M前面的#注释去掉,将8M修改为1024M,这个1024M根据服务器性能修改。

更改前:
vi zabbix_server.conf
### Option: VMwareCacheSize
#       Size of VMware cache, in bytes.
#       Shared memory size for storing VMware data.
#       Only used if VMware collectors are started.
#
# Mandatory: no
# Range: 256K-2G
# Default:
# VMwareCacheSize=8M

更改后:

### Option: CacheSize
# Size of configuration cache, in bytes.
# Shared memory size for storing host, item and trigger data.
#
# Mandatory: no
# Range: 128K-8G
# Default:
CacheSize=1024M

重启服务
/etc/init.d/zabbix-server restart

恢复正常

页: [1]
查看完整版本: Zabbix监控网络设备日志文件及字段报警