环境介绍
操作系统:Centos 7.9
软件环境:zabbix-server 4.2.8、NET-SNMP version 5.7.2、snmpttv1.4beta2
网关型号:鼎信通达MTG2000-X-8E1
一、核心逻辑
网关(MTG2000-X-8E1)发送 Trap -> Zabbix Proxy(安装snmptrapd和snmptt) 上的 snmptrapd 接收 -> snmptt 翻译并过滤 -> 写入日志文件 -> Zabbix Server 读取日志并触发告警
二、网关配置
- 启用 SNMP 协议:设置为 Yes。
- SNMP 版本:选择 v2c。
- SNMP 管理主机 IP(Trap 接收器地址):填写 Zabbix Proxy 的 IP。
- Trap 端口:默认使用标准 162(手册中可能与 NTP 端口描述混淆,实际按 SNMP 标准配置 162)。
- Community 字符串:设置 Read Community(轮询用,建议自定义如
public或更安全的字符串);Write Community 如果需要。 - 注意:MTG2000-X-8E1的trap消息可能只能通过管理口GE0发送
原厂提供的snmp-trap信息
| OID | ||||
|---|---|---|---|---|
| 1.3.6.1.4.1.38111.7.30.1 | SystemUpTrap | An indication that the system is already up and running. | 系统已经启动,正在运行 | System Up |
| 1.3.6.1.4.1.38111.7.30.2 | E1StatusTrap | This Notification is generated when there is a change of mtg E1 port status | E1端口状态发生变化通知 | port %u miss signal port %u have Remote Alarm port %u have AIS Alarm port %u have ISDN/SS7/R2 Signal Alarm port %u is normal SS7/PRA/R2 port %u do not configure |
| 1.3.6.1.4.1.38111.7.30.3 | PRIlinkdownTrap | This Notification is generated when there is a change of PRI link status | pri链路状态发生变化通知 | PRI port %u link down PRI port %u link up |
| 1.3.6.1.4.1.38111.7.30.4 | SS7linkdownTrap | This Notification is generated when there is a change of SS7 link status | ss7链路状态发生变化通知 | SS7 port %u link down SS7 port %u link up |
| 1.3.6.1.4.1.38111.7.30.5 | SIPTrunkStatusTrap | This Notification is generated when there is a change of SIP Trunk status | sip中继状态发生变化通知 | SIPTrunkNO:%u,TrunkName:%s,PeerIP:%s,Status:Fault SIPTrunkNO:%u,TrunkName:%s,PeerIP:%s,Status:Ok |
| 1.3.6.1.4.1.38111.7.30.6 | SystemRestartTrap | An indication that the system is in the process being restarted | 系统重启通知 | System Restart |
| 1.3.6.1.4.1.38111.7.30.7 | WanIpUpdatedTrap | This Notification is generated when there is a change of the IP address of WAN interface | 设备wan口ip地址更改通知 | Wan Ip Updated |
| 1.3.6.1.4.1.38111.7.30.12 | TelnetLogin3TFailTrap | This Notification is generated when Telnet Login failed for three times | telnet登录连续失败3次通知 | Telnet login failed within three times |
| 1.3.6.1.4.1.38111.7.30.13 | HttpLogin3TFailTrap | This Notification is generated when Http Login failed for three times | web登录连续失败3次通知 | Http login failed within three times |
| 1.3.6.1.4.1.38111.7.30.17 | R2linkdownTrap | This Notification is generated when there is a change of R2 link status | R2中继cas复帧同步状态变化通知 | R2 port %u link down R2 port %u link up |
| 1.3.6.1.4.1.38111.7.30.18 | PowerStatustrap | notification of mtg power status | mtg 电源状态告警 | 电源 %u 正常,电压增大 Power %u is good, voltage increases. 电源 %u 正常,电压减小 Power %u is good, voltage decreases. 电源 %u 正常 Power %u is good. 电源 %u 故障,无电压 Power %u is fault, no voltage. 电源 %u 故障,链路故障 Power %u is fault, link down. 电源 %u 故障 Power %u is fault. |
| 1.3.6.1.4.1.38111.7.30.19 | RoleSwitchtrap | notification of mtg role switch to main board | mtg mcu板切换为主板 | MCU%u 切换为主用板 MCU%u switch to main board. |
| 1.3.6.1.4.1.38111.7.30.21 | SipacctRegisterTrap | This Notification is generated when there is a change of SIP Accoutn status | sip账号状态发生变化通知 | Sip Trunk:%d, AcctId:%d, Register Status:%s |
| 1.3.6.1.4.1.38111.7.30.22 | CloudRegisterTrap | This Notification is generated when there is a change of Cloud status | cloud网管注册状态发生变化通知 | Cloud Server Register Status:%s |
| 1.3.6.1.4.1.38111.7.30.23 | CommonEventTrap | Common Event info trap | 通用事件通知,支持配置是否发送。包括:dtu故障 | Common Event:login success from web! Common Event:login success from telnet! Common Event:login success from other type! |
| 1.3.6.1.4.1.38111.7.30.24 | Q931UsageOverThrtrap | This Notification is generated when pri call over trreshold | Q931使用率超阈值告警 | Q931 Trunk(No.%u)usage rate restore normal Q931 Trunk(No.%u)usage rate over threshold Q931 Trunk(No.%u)usage rate continuous over threshold |
| 1.3.6.1.4.1.38111.7.30.25 | CpuTemperatureTrap | This Notification is generated when cpu temperature over threshold | 设备cpu温度超阈值告警 | dev cpu temperature is %uC, temperature exception! dev cpu temperature is %uC, temperature normal! |
| 1.3.6.1.4.1.38111.7.30.26 | FanStatustrap | notification of mtg fan status | mtg 风扇状态告警 | [alarm_events] The fan is abnormal and the speed is 0. [alarm_events] Fan returns to normal. |
三、zabbix proxy
安装必要软件包
1 | |
配置zabbix代理(zabbix_proxy.conf)
/etc/zabbix/zabbix_proxy.conf
1 | |
配置snmptrapd(接收端snmptrapd.conf)
/etc/snmp/snmptrapd.conf
1 | |
导致snmptt.log一直不产生的根源!!
1 | |
增加-On参数,确认 snmptrapd 启动参数里有 -On(以数字形式输出 OID),这个很关键
ExecStart=/usr/sbin/snmptrapd $OPTIONS -f -On
/usr/lib/systemd/system/snmptrapd.service
1 | |
配置snmptt(转换器snmptt.ini和snmptt.conf)
修改全局配置/etc/snmp/snmptt.ini
1 | |
默认规则/etc/snmp/snmptt.conf
格式:
1 | |
/etc/snmp/snmptt.conf
1 | |
自定义规则/etc/snmp/snmptt_MTG2000.conf
/etc/snmp/snmptt_MTG2000.conf
1 | |
配置说明:
- :代表打印所有接收到的变量。
- 1,1,2…:代表打印 Trap 包中第 N 个变量。例如 SIP 中继告警,使用具体的变量位置可以让 Zabbix 的正则匹配更高效。
- 严重性 (Severity):这里的 Normal/Warning/Critical 仅作为 snmptt 日志标识,最终告警等级由 Zabbix Trigger 决定。
改完配置重启所有服务
1 | |
1 | |
四、zabbix server配置
配置-主机-创建主机
配置-模板-创建模板
编辑模板,编辑模板宏
{ $IFCONTROL }⇒1
{ $IF_ERRORS_WARN }⇒2
{ $IF_UTIL_MAX }⇒95
{ $SNMP_COMMUNITY }⇒public
创建监控项
- SystemUpTrap
- 类型:SNMP trap
- 键值:
snmptrap["1.3.6.1.4.1.38111.7.30.1"] - 信息类型:log
- 日志时间格式:hh:mm:ss yyyy/MM/dd
- 触发器:{ Template MTG2000 SNMP Traps v2c:snmptrap[“.1.3.6.1.4.1.38111.7.30.1”].count(300,already up and running) }=1
- E1端口状态
- 类型:SNMP trap
- 键值:
snmptrap["1.3.6.1.4.1.38111.7.30.2"] - 信息类型:log
- 日志时间格式:hh:mm:ss yyyy/MM/dd
- 触发器:{ Template MTG2000 SNMP Traps v2c:snmptrap[“1.3.6.1.4.1.38111.7.30.2”].regexp(“信号丢失|信令告警|告警”) }=1
- { Template MTG2000 SNMP Traps v2c:snmptrap[“1.3.6.1.4.1.38111.7.30.2”].regexp(“E1端口|正常”) }=1
- 触发器问题事件生成模式:多重
- PRI链路状态
- 类型:SNMP trap
- 键值:
snmptrap["1.3.6.1.4.1.38111.7.30.3"] - 信息类型:log
- 日志时间格式:hh:mm:ss yyyy/MM/dd
- 触发器:{ Template MTG2000 SNMP Traps v2c:snmptrap[“1.3.6.1.4.1.38111.7.30.3”].regexp(“PRI端口|故障”) }=1
- { Template MTG2000 SNMP Traps v2c:snmptrap[“1.3.6.1.4.1.38111.7.30.3”].regexp(“PRI端口|正常”) }=1
- 触发器问题事件生成模式:多重
- SS7链路状态
- 类型:SNMP trap
- 键值:
snmptrap["1.3.6.1.4.1.38111.7.30.4"] - 信息类型:log
- 日志时间格式:hh:mm:ss yyyy/MM/dd
- 触发器:{ Template MTG2000 SNMP Traps v2c:snmptrap[“.1.3.6.1.4.1.38111.7.30.4”].regexp(“SS7端口|故障”) }=1
- { Template MTG2000 SNMP Traps v2c:snmptrap[“.1.3.6.1.4.1.38111.7.30.4”].regexp(“SS7端口|正常”) }=1
- 触发器问题事件生成模式:多重
- SIP中继状态
- 类型:SNMP trap
- 键值:
snmptrap["1.3.6.1.4.1.38111.7.30.5"] - 信息类型:log
- 日志时间格式:hh:mm:ss yyyy/MM/dd
- 触发器:{ Template MTG2000 SNMP Traps v2c:snmptrap[“.1.3.6.1.4.1.38111.7.30.5”].regexp(“Status:Fault”) }=1
- { Template MTG2000 SNMP Traps v2c:snmptrap[“.1.3.6.1.4.1.38111.7.30.5”].regexp(“Status:Ok”) }=1
- 触发器问题事件生成模式:多重
- 系统重启
- 类型:SNMP trap
- 键值:
snmptrap["1.3.6.1.4.1.38111.7.30.6"] - 信息类型:log
- 日志时间格式:hh:mm:ss yyyy/MM/dd
- 触发器:{ Template MTG2000 SNMP Traps v2c:snmptrap[“.1.3.6.1.4.1.38111.7.30.6”].regexp(“System Restart”) }=1
其中E1\PRI\SS7\SIP或其他监控项因为接收到的是中文日志,需要在zabbix server做预处理的,在监控项-进程中增加JavaScript,参数如下
1 | |
创建触发器
- 正则表达式提取: 鼎信通达的 Trap 信息包含
%u(端口号)。 - 手动关闭告警: 部分 Trap 只有告警没有明确的恢复报文(例如
SystemRestartTrap),这类触发器应配置为Allow manual close(允许手动关闭)。
选择主机关联模板
五、验证
1 | |
1 | |
实时调试,在zabbix proxy上实时查看系统日志过滤
1 | |
如果有产生/var/log/snmptt/snmpttunknown.log,而没有产生/var/log/snmptt/snmptt.log。说明OID 过滤规则(EVENT 路径)没匹配上