This repository has been archived by the owner on Dec 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create default profile definition in MIB server (#56)
* feat: create default profile definition in MIB server * fix: fix failing build * fix: fix failing build * fix: fix failing build * fix: fix failing build * feat: PR comments * fix: build fix * fix: build fix
- Loading branch information
Showing
15 changed files
with
457 additions
and
3 deletions.
There are no files selected for viewing
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,37 @@ | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
profiles: | ||
basev1: | ||
frequency: 10 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- '1.3.6.1.2.1.2.*' | ||
basev1l2: | ||
frequency: 20 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- ['IF-MIB','ifHCInOctets'] | ||
- ['IF-MIB','ifHCOutOctets'] | ||
- ['IF-MIB','ifInErrors'] | ||
- ['IF-MIB','ifOutErrors'] | ||
- ['IF-MIB','ifInDiscards'] | ||
- ['IF-MIB','ifOutDiscards'] |
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,40 @@ | ||
# ######################################################################## | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ######################################################################## | ||
import logging | ||
import os | ||
|
||
import yaml | ||
from yaml.parser import ParserError | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def merge_profiles(directory, root_name): | ||
result = {} | ||
merged_profiles = {} | ||
for root, directories, files in os.walk(directory, topdown=False): | ||
for name in sorted(files): | ||
with open(os.path.join(root, name), "r") as stream: | ||
try: | ||
data = yaml.safe_load(stream) | ||
merged_profiles.update(data[root_name]) | ||
except ParserError as pe: | ||
logger.warning( | ||
f"Error while parsing file {os.path.join(root, name)} : {pe}" | ||
) | ||
|
||
result[root_name] = merged_profiles | ||
return result |
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,31 @@ | ||
# | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
snmp: | ||
mibs: | ||
dir: "mibs/pysnmp" | ||
load_list: "lookups/mibs_list.csv" | ||
mibs_path: "mibs" | ||
profiles_path: "profiles" | ||
mongo: | ||
oid: | ||
database: "mib_server" | ||
collection: "oids" | ||
mib: | ||
database: "files" | ||
collection: "mib_files" | ||
profile: | ||
database: "profiles" | ||
collection: "profiles" |
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,37 @@ | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
profiles: | ||
basev1: | ||
frequency: 10 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- '1.3.6.1.2.1.2.*' | ||
basev1l2: | ||
frequency: 20 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- ['IF-MIB','ifHCInOctets'] | ||
- ['IF-MIB','ifHCOutOctets'] | ||
- ['IF-MIB','ifInErrors'] | ||
- ['IF-MIB','ifOutErrors'] | ||
- ['IF-MIB','ifInDiscards'] | ||
- ['IF-MIB','ifOutDiscards'] |
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,42 @@ | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
profiles: | ||
basev2: | ||
patterns: | ||
- '*MY_DEFAULT_DEVICE_3*' | ||
frequency: 60 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- '1.3.6.1.2.1.2.*' | ||
basev2l2: | ||
patterns: | ||
- '*MY_DEFAULT_DEVICE_3*' | ||
- '*MY_DEFAULT_DEVICE_NAME_3*' | ||
frequency: 120 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- ['IF-MIB','ifHCInOctets'] | ||
- ['IF-MIB','ifHCOutOctets'] | ||
- ['IF-MIB','ifInErrors'] | ||
- ['IF-MIB','ifOutErrors'] | ||
- ['IF-MIB','ifInDiscards'] | ||
- ['IF-MIB','ifOutDiscards'] |
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,37 @@ | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
profiles: | ||
basev1: | ||
frequency: 10 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- '1.3.6.1.2.1.2.*' | ||
basev1l2: | ||
frequency: 20 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- ['IF-MIB','ifHCInOctets'] | ||
- ['IF-MIB','ifHCOutOctets'] | ||
- ['IF-MIB','ifInErrors'] | ||
- ['IF-MIB','ifOutErrors'] | ||
- ['IF-MIB','ifInDiscards'] | ||
- ['IF-MIB','ifOutDiscards'] |
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,37 @@ | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
profiles: | ||
basev1: | ||
frequency: 10 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- '1.3.6.1.2.1.2.*' | ||
basev1l2: | ||
frequency: 20 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- ['IF-MIB','ifHCInOctets'] | ||
- ['IF-MIB','ifHCOutOctets'] | ||
- ['IF-MIB','ifInErrors'] | ||
- ['IF-MIB','ifOutErrors'] | ||
- ['IF-MIB','ifInDiscards'] | ||
- ['IF-MIB','ifOutDiscards'] |
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,42 @@ | ||
# Copyright 2021 Splunk Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
profiles: | ||
basev1: | ||
patterns: | ||
- '*MY_DEFAULT_DEVICE_3*' | ||
frequency: 60 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- '1.3.6.1.2.1.2.*' | ||
basev1l2: | ||
patterns: | ||
- '*MY_DEFAULT_DEVICE_3*' | ||
- '*MY_DEFAULT_DEVICE_NAME_3*' | ||
frequency: 120 | ||
varBinds: | ||
# Syntax: [ "MIB-Files", "MIB object name" "MIB index number"] | ||
- ['SNMPv2-MIB', 'sysDescr'] | ||
- ['SNMPv2-MIB', 'sysUpTime',0] | ||
- ['SNMPv2-MIB', 'sysName'] | ||
- ['IF-MIB','ifHCInOctets'] | ||
- ['IF-MIB','ifHCOutOctets'] | ||
- ['IF-MIB','ifInErrors'] | ||
- ['IF-MIB','ifOutErrors'] | ||
- ['IF-MIB','ifInDiscards'] | ||
- ['IF-MIB','ifOutDiscards'] |
Oops, something went wrong.