From 1e94d7f72712bf61f81dad7268ad8fcff6170d4b Mon Sep 17 00:00:00 2001 From: rfaircloth-splunk Date: Wed, 4 Mar 2020 16:47:45 -0500 Subject: [PATCH] Enhance cisco IOS Enhance to address extra field before time stamp, uptime, and no host formats --- .../etc/conf.d/conflib/_common/templates.conf | 5 + package/etc/conf.d/filters/cisco/ios.conf | 118 ++++++++++++++++++ .../conf.d/log_paths/lp-cisco_ios.conf.tmpl | 2 +- package/etc/go_templates/source_network.t | 8 +- pytest.ini | 2 +- tests/test_cisco_ios.py | 43 ++++++- 6 files changed, 166 insertions(+), 12 deletions(-) diff --git a/package/etc/conf.d/conflib/_common/templates.conf b/package/etc/conf.d/conflib/_common/templates.conf index 5746a1c..cc49e3b 100644 --- a/package/etc/conf.d/conflib/_common/templates.conf +++ b/package/etc/conf.d/conflib/_common/templates.conf @@ -45,6 +45,11 @@ template t_hdr_msg { template t_legacy_hdr_msg { template("${LEGACY_MSGHDR}${MESSAGE}"); }; + +template t_program_msg { + template("${PROGRAM}: ${MESSAGE}"); + }; + # =============================================================================================== # Message Header, Structured Data (from RFC5424 parse) and Message; for Juniper # =============================================================================================== diff --git a/package/etc/conf.d/filters/cisco/ios.conf b/package/etc/conf.d/filters/cisco/ios.conf index 0e4c478..5a0b589 100644 --- a/package/etc/conf.d/filters/cisco/ios.conf +++ b/package/etc/conf.d/filters/cisco/ios.conf @@ -4,3 +4,121 @@ filter f_cisco_ios{ match("cisco_ios", value("fields.sc4s_vendor_product") type(glob)); }; +#6339985: foo: 6340004: *Mar 4 11:45:20: %SEC-6-IPACCESSLOGP: list INET-BLOCK permitted tcp 192.168.20.252(55244) -> 10.54.3.178(44818), 1 packet +#30: foo: *Apr 29 13:58:46.000001: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.239 stopped - CLI initiated +#30: foo: *Apr 29 13:58:46.411: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.239 stopped - CLI initiated +#29: foo: *Apr 29 13:58:40.411: %SYS-5-CONFIG_I: Configured from console by console +#30: foo: *Apr 29 13:58:46.411: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.239 stopped - CLI initiated +#31: foo: *Apr 29 13:58:46.411: %SYS-6-LOGGINGHOST_STARTSTOP: Logging to host 192.168.1.239 started - CLI initiated +#32: 0.0.0.0: *Apr 29 13:59:12.491: %SYS-5-CONFIG_I: Configured from console by console +#33: 0.0.0.0: *Apr 29 13:59:26.415: %SYS-5-CONFIG_I: Configured from console by console +#34: 0.0.0.0: *Apr 29 13:59:56.603: %SYS-5-CONFIG_I: Configured from console by console +#35: *Apr 29 14:00:16.059: %SYS-5-CONFIG_I: Configured from console by console +#32: foo: *Apr 29 13:58:46.411: %SYSMGR-STANDBY-3-SHUTDOWN_START: The System Manager has started the shutdown procedure. +#foo: *Apr 29 13:58:46.411: %SYSMGR-STANDBY-3-SHUTDOWN_START: The System Manager has +#started the shutdown procedure. +#foo: 00:01:01: %SYSMGR-STANDBY-3-SHUTDOWN_START: The System Manager has started the +#foo: 1 2: %SYSMGR-STANDBY-3-SHUTDOWN_START: The System Manager has started the shutdown procedure.shutdown procedure. +#foo: 101 21: %SYSMGR-STANDBY-3-SHUTDOWN_START: The System Manager has started the shutdown procedure.shutdown procedure. +#*Mar 1 18:48:50.483 UTC: %SYS-5-CONFIG_I: Configured from console by vty2 (10.34.195.36) + +# block parser cisco-timestamp-parser-ex(template()) { +# channel { +# filter { +# match('^\*?([A-Za-z]{3} [0-9 ]\d (\d{4} )?\d{2}:\d{2}:\d{2}(\.\d{3})?( (AM|PM))?)' template(`template`) flags(store-matches)); +# }; +# parser { +# date-parser(format('%b %d %I:%M:%S %p.%f', +# '%b %d %I:%M:%S %p', +# '%b %d %H:%M:%S.%f', +# '%b %d %H:%M:%S', +# '%b %d %Y %H:%M:%S.%f', +# '%b %d %Y %H:%M:%S') +# template("$1")); +# }; +# }; +# }; + +# block parser cisco-triplet-parser-ex(template() prefix()) { +# channel { +# if { +# parser { +# csv-parser(delimiters(chars('-')) template(`template`) +# columns('`prefix`facility', '`prefix`severity', '`prefix`mnemonic') +# flags(drop-invalid)); +# }; +# } else { +# parser { +# csv-parser(delimiters(chars('-')) template(`template`) +# columns('`prefix`facility', '1', '`prefix`severity', '`prefix`mnemonic') +# flags(drop-invalid)); +# }; +# rewrite { set("${`prefix`facility}-$1" value('`prefix`facility')); }; +# }; +# }; +# }; + + +parser cisco-parser-ex{ + channel { + filter { + #message('^<\d*>(?:(?\d+)\: )?(?:(?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]): )?(?:(?\d+): )?(?:(?\*)?(?(?