Skip to content

Commit

Permalink
Merge 3fcb4ef into 0a778ae
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceaulinic committed May 13, 2020
2 parents 0a778ae + 3fcb4ef commit c687606
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
9 changes: 8 additions & 1 deletion napalm_logs/config/eos/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ prefixes:
processName: (\w+)
tag: ([\w-]+)
line: '{date} {time} {host} {processName}: %{tag}'

# ISO8601 date-time format
- values:
date: (\d{4}-\d{2}-\d{2})
time: (\d{2}:\d{2}:\d{2}[\.\d{3}]?[\+|-]\d{2}:\d{2})
host: ([^ ]+)
processName: (\w+)
tag: ([\w-]+)
line: '{date}T{time} {host} {processName}: %{tag}'
22 changes: 11 additions & 11 deletions napalm_logs/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,19 @@ def convert_env_dict(self, d):
if isinstance(v, list):
self.convert_env_list(v)

def convert_env_list(self, l):
for n, v in enumerate(l):
if isinstance(v, six.string_type):
if not v.startswith('${') or not v.endswith('}'):
def convert_env_list(self, lst):
for name, value in enumerate(lst):
if isinstance(value, six.string_type):
if not value.startswith('${') or not value.endswith('}'):
continue
if not os.environ.get(v[2:-1]):
log.error('No env variable found for %s, please check your config file', v[2:-1])
if not os.environ.get(value[2:-1]):
log.error('No env variable found for %s, please check your config file', value[2:-1])
sys.exit(1)
l[n] = os.environ[v[2:-1]]
if isinstance(v, dict):
self.convert_env_dict(v)
if isinstance(v, list):
self.convert_env_list(v)
lst[name] = os.environ[value[2:-1]]
if isinstance(value, dict):
self.convert_env_dict(value)
if isinstance(value, list):
self.convert_env_list(value)

def read_config_file(self, filepath):
config = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<13>2020-03-31T08:41:59+00:00 some-switch Bgp: %BGP-5-ADJCHANGE: peer 192.0.2.2 (VRF default AS 12345) old state Established event AdminReset new state Idle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"error": "BGP_NEIGHBOR_STATE_CHANGED",
"message_details": {
"severity": 5,
"processName": "Bgp",
"pri": "13",
"time": "08:41:59+00:00",
"tag": "BGP-5-ADJCHANGE",
"date": "2020-03-31",
"facility": 1,
"host": "some-switch",
"message": ": peer 192.0.2.2 (VRF default AS 12345) old state Established event AdminReset new state Idle"
},
"os": "eos",
"timestamp": 1585644119,
"severity": 5,
"yang_message": {
"bgp": {
"neighbors": {
"neighbor": {
"192.0.2.2": {
"state": {
"session-state": "IDLE",
"session-state-old": "ESTABLISHED",
"peer_as": "12345",
"session-state-change-event": "AdminReset"
}
}
}
}
}
},
"yang_model": "openconfig-bgp",
"ip": "127.0.0.1",
"facility": 1,
"host": "some-switch"
}

0 comments on commit c687606

Please sign in to comment.