logstash收集华为、H3C、Cisco交换机日志

网络设备配置

将 syslog-ip 替换成服务器的IP地址。

复制代码
Huawei
info-center loghost source interface
info-center loghost syslog-ip local-time facility local6
H3C
info-center loghost source interface
info-center loghost syslog-ip facility local5
Aruba
logging arm subcat all level warnings
logging network subcat all level warnings
logging security subcat all level warnings
logging security subcat ids level warnings
logging security subcat ids-ap level warnings
logging system subcat all level warnings
logging user subcat all level warnings
logging wireless subcat all level warnings
logging 10.10.4.86 severity warnings facility local3
CISCO
logging on
logging syslog-ip 
logging facility local4
logging source-interface e0

本次以华为交换机为例,首先登录交换机,设置日志收集服务器地址:

复制代码
1、设置日志服务器IP地址
<S5735-EsxiMGT-SW1>system-view
Enter system view, return user view with Ctrl+Z.
[S5735-EsxiMGT-SW1]display current-configuration | in info
info-center loghost source Vlanif100
snmp-agent sys-info version v2c
undo snmp-agent sys-info version v3
[S5735-EsxiMGT-SW1]info-center loghost 10.10.200.35
[S5735-EsxiMGT-SW1]display current-configuration | in info
info-center loghost source Vlanif100
info-center loghost 10.10.200.35
snmp-agent sys-info version v2c
undo snmp-agent sys-info version v3

之后登录logstash服务器,配置conf

复制代码
[root@node3 ~]# cd /etc/logstash/conf.d/
[root@node3 conf.d]# vim switch.conf
input{
    tcp { port => 5002
    type => "Cisco"}
    udp { port => 514
    type => "HUAWEI"}
    udp { port => 5002
    type => "Cisco"}
    udp { port => 5003
    type => "H3C"}
}
filter {
    if [type] == "Cisco" {
    grok {
    match => { "message" => "<%{BASE10NUM:syslog_pri}>%{NUMBER:log_sequence}: .%{SYSLOGTIMESTAMP:timestamp}: %%{DATA:facility}-%{POSINT:severity}-%{CISCO_REASON:mnemonic}: %{GREEDYDATA:message}" }
    match => { "message" => "<%{BASE10NUM:syslog_pri}>%{NUMBER:log_sequence}: %{SYSLOGTIMESTAMP:timestamp}: %%{DATA:facility}-%{POSINT:severity}-%{CISCO_REASON:mnemonic}: %{GREEDYDATA:message}" }
    add_field => {"severity_code" => "%{severity}"}
    overwrite => ["message"]
    }
}
    elseif [type] == "H3C" {
    grok {
    match => { "message" => "<%{BASE10NUM:syslog_pri}>%{SYSLOGTIMESTAMP:timestamp} %{YEAR:year} %{DATA:hostname} %%%{DATA:vvmodule}/%{POSINT:severity}/%{DATA:digest}: %{GREEDYDATA:message}" }
    remove_field => [ "year" ]
    add_field => {"severity_code" => "%{severity}"}
    overwrite => ["message"]
    }
}
        elseif [type] == "HUAWEI" {
    grok {
       match => { "message" => "<%{BASE10NUM:syslog_pri}>%{SYSLOGTIMESTAMP:timestamp} %{DATA:hostname} %%%{DATA:ddModuleName}/%{POSINT:severity}/%{DATA:Brief}:%{GREEDYDATA:message}"}
       match => { "message" => "<%{BASE10NUM:syslog_pri}>%{SYSLOGTIMESTAMP:timestamp} %{DATA:hostname} %{DATA:ddModuleName}/%{POSINT:severity}/%{DATA:Brief}:%{GREEDYDATA:message}"}
       remove_field => [ "timestamp" ]
    add_field => {"severity_code" => "%{severity}"}
    overwrite => ["message"]
    }
}
#mutate {
#        gsub => [
#        "severity", "0", "Emergency",
#        "severity", "1", "Alert",
#        "severity", "2", "Critical",
#        "severity", "3", "Error",
#        "severity", "4", "Warning",
#        "severity", "5", "Notice",
#        "severity", "6", "Informational",
#        "severity", "7", "Debug"
#        ]
#    }
}
output{
    elasticsearch {
        index =>
        "syslog-%{+YYYY.MM.dd}"
        hosts => ["10.10.200.33:9200","10.10.200.34:9200","10.10.200.35:9200"]
    }
}

修改后,重启Logstash

登录ELK,检查数据

相关推荐
花开彼岸天~8 小时前
鸿蒙应用开发实战【01】— 号码助手项目概述与开发环境搭建
华为·harmonyos·鸿蒙系统
段一凡-华北理工大学8 小时前
AI Agent 从入门到封神:24 讲打造你的超级智能体~系列文章23:从Demo到上线:Agent应用的架构设计、性能优化与成本控制实战
运维·网络·人工智能·性能优化·高炉炼铁·工业智能体
leagsoft_10038 小时前
从“策略看不清”到“风险可收敛”:某高端精密制造企业的网络安全策略治理实践
网络·web安全·制造
心中有国也有家8 小时前
AtomGit Flutter 鸿蒙客户端:零外部资源的应用打包策略
android·javascript·flutter·华为·harmonyos
paopaokaka_luck9 小时前
基于Springboot3+Vue3的宠物殡葬管理系统(webSocket实时通讯、接入腾讯地图、支付宝沙盒支付、Echarts图形化分析)
java·开发语言·网络·后端
最爱老式锅包肉9 小时前
HarmonyOS技术精讲-Camera Kit(相机服务)第3篇:实现相机预览功能
数码相机·华为·harmonyos
承渊政道9 小时前
【从零开始大模型开发与微调:基于PyTorch与ChatGLM】(从退化问题到信息高速公路:ResNet残差网络实战拆解)
网络·人工智能·pytorch·深度学习·resnet·chatglm·卷积
Lhappy嘻嘻9 小时前
网络初识|基础入门:局域网广域网、IP 端口、TCP/IP 五层模型与封装解封装全过程
java·开发语言·网络·笔记·网络协议·tcp/ip
youtootech9 小时前
HarmonyOS《柚兔学伴》项目实战02-多模块架构设计与 HSP/HAR 模块化
华为·harmonyos
KaMeidebaby9 小时前
卡梅德生物技术快报|兔单克隆抗体:噬菌体 Fab 免疫文库搭建实操:兔单克隆抗体重组构建完整参数
前端·网络·数据库·人工智能·算法