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 3
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
Showing
14 changed files
with
469 additions
and
289 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
Large diffs are not rendered by default.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
splunk_connect_for_snmp_poller/manager/data/event_builder.py
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,54 @@ | ||
# 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. | ||
# | ||
from enum import Enum | ||
from typing import Any, Dict | ||
|
||
from celery.utils.log import get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
class EventBuilder: | ||
def __init__(self) -> None: | ||
self.data: Dict = {} | ||
|
||
def add(self, field, part: Any) -> None: | ||
self.data[field.value] = part | ||
|
||
def is_one_time_walk(self, one_time_flag: bool) -> None: | ||
if one_time_flag: | ||
self.data[EventField.SOURCETYPE.value] = EventType.WALK.value | ||
|
||
def build(self) -> dict: | ||
logger.debug("--------data------\n%s", self.data) | ||
return self.data | ||
|
||
|
||
class EventField(Enum): | ||
TIME = "time" | ||
SOURCETYPE = "sourcetype" | ||
HOST = "host" | ||
INDEX = "index" | ||
EVENT = "event" | ||
FREQUENCY = "frequency" | ||
PROFILE = "profile" | ||
FIELDS = "fields" | ||
|
||
|
||
class EventType(Enum): | ||
EVENT = "sc4snmp:meta" | ||
METRIC = "metric" | ||
WALK = "sc4snmp:walk" | ||
ERROR = "sc4snmp:error" |
28 changes: 28 additions & 0 deletions
28
splunk_connect_for_snmp_poller/manager/data/inventory_record.py
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,28 @@ | ||
# 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 json | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class InventoryRecord: | ||
host: str | ||
version: str | ||
community: str | ||
profile: str | ||
frequency_str: str | ||
|
||
def toJson(self): | ||
return json.dumps(self, default=lambda o: o.__dict__) |
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
Oops, something went wrong.