-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mbonsack
authored and
Ryan Faircloth
committed
Aug 26, 2019
1 parent
31990cb
commit baae02e
Showing
8 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| filter f_cisco_nx-os { | ||
| match("cisco_nx-os", value("fields.sc4s_vendor_product") type(glob) ); | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| log { | ||
|
|
||
| source(s_default-ports); | ||
| filter(f_cisco_nx-os); | ||
|
|
||
| parser { | ||
| p_add_context_splunk(key("cisco:nx-os")); | ||
| }; | ||
| rewrite { | ||
| r_set_splunk(template("t_standard")) | ||
| }; | ||
| destination(d_hec); #--HEC-- | ||
| flags(flow-control); | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright 2019 Splunk, Inc. | ||
| # | ||
| # Use of this source code is governed by a BSD-2-clause-style | ||
| # license that can be found in the LICENSE-BSD2 file or at | ||
| # https://opensource.org/licenses/BSD-2-Clause | ||
|
|
||
| from jinja2 import Environment | ||
|
|
||
| from .sendmessage import * | ||
| from .splunkutils import * | ||
|
|
||
| env = Environment(extensions=['jinja2_time.TimeExtension']) | ||
|
|
||
| # Nov 1 14:07:58 excal-113 %MODULE-5-MOD_OK: Module 1 is online | ||
| def test_cisco_nx_os(record_property, setup_wordlist, get_host_key, setup_splunk): | ||
| host = get_host_key | ||
|
|
||
| mt = env.from_string( | ||
| "{{ mark }} {% now 'utc', '%b %d %H:%M:%S' %} csconx-{{ host }} %MODULE-5-MOD_OK: Module 1 is online") | ||
| message = mt.render(mark="<111>", host=host) | ||
|
|
||
| sendsingle(message) | ||
|
|
||
| st = env.from_string("search index=main host=\"csconx-{{ host }}\" sourcetype=\"cisco:nx-os\" | head 2") | ||
| search = st.render(host=host) | ||
|
|
||
| resultCount, eventCount = splunk_single(setup_splunk, search) | ||
|
|
||
| record_property("host", host) | ||
| record_property("resultCount", resultCount) | ||
| record_property("message", message) | ||
|
|
||
| assert resultCount == 1 | ||
|
|
||
| # Nov 1 14:07:58 excal-113 %MODULE-5-MOD_OK: Module 1 is online | ||
| # @pytest.mark.xfail | ||
| #def test_cisco_nx_os_singleport(record_property, setup_wordlist, get_host_key, setup_splunk): | ||
| # host = get_host_key | ||
| # | ||
| # mt = env.from_string( | ||
| # "{{ mark }} {% now 'utc', '%b %d %H:%M:%S' %} {{ host }} %MODULE-5-MOD_OK: Module 1 is online") | ||
| # message = mt.render(mark="<23>", host=host) | ||
| # | ||
| # sendsingle(message, host="sc4s-nx-os") | ||
| # | ||
| # st = env.from_string("search index=main host=\"{{ host }}\" sourcetype=\"cisco:nx-o\" | head 2") | ||
| # search = st.render(host=host) | ||
| # | ||
| # resultCount, eventCount = splunk_single(setup_splunk, search) | ||
| # | ||
| # record_property("host", host) | ||
| # record_property("resultCount", resultCount) | ||
| # record_property("message", message) | ||
| # | ||
| # assert resultCount == 1 |