Skip to content

Commit

Permalink
Merge pull request #17 from amorenoz/styles
Browse files Browse the repository at this point in the history
Make styles configurable
  • Loading branch information
amorenoz authored Sep 7, 2021
2 parents 4cec221 + fc0e95c commit cde38f4
Show file tree
Hide file tree
Showing 15 changed files with 1,105 additions and 297 deletions.
4 changes: 2 additions & 2 deletions bin/ovs-lgrep
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ from ovs_dbg.logs import OVSLog
@click.option(
"-s",
"--start",
help="Start timestamp."
help="Start timestamp. "
"Format (same as OVS logs): '%Y-%m-%dT%H:%M:%S.%fZ'"
", e.g: '2021-07-15T15:04:05.793Z'",
)
@click.option(
"-e",
"--end",
help="End timestamp"
help="End timestamp. "
"Format (same as OVS logs): '%Y-%m-%dT%H:%M:%S.%fZ'"
", e.g: '2021-07-15T15:04:05.793Z'",
)
Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This respository stores scripts and documentation to help debug OVS and OVN.

ofofproto

lgrep

Indices and tables
==================

Expand Down
81 changes: 81 additions & 0 deletions docs/source/lgrep.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
==================================
ovs-lgrep: Time-aware log grepping
==================================

Often, when troubleshooting OVS or OVN problems, we need to correlate
multiple log files (from multiple nodes, OVN, etc). To make that task
a bit easer `ovs-lgrep` allows you to look for logs at a specific point
in time in many log files.


-----
Usage
-----

::

ovs-lgrep -h


Search logs by regular expression
*********************************

ovs-lgrep uses Python's regular expression syntax, see the regexp_syntax_.
Grep for a specific expression by running:


::

ovs-lgrep -r "peak resident set size grew" ovn-northd.log


.. _regexp_syntax: https://docs.python.org/3/library/re.html


Search by timestamp
*******************

Start and end boundaries can be specified:

::

ovs-lgrep -s "2021-07-15T16:50:03.018Z" -e "2021-07-15T17:42:03.492Z"
ovn-northd.log


Time boundaries can be specified using `-A` and `-B` options:

::

ovs-lgrep -s "2021-07-15T16:50:03.018Z" -A 2m ovn-northd.log
ovs-lgrep -s "2021-07-15T16:50:03.018Z" -B 1h2m3s ovn-northd.log


Logfile interleaving
********************

If multiple log files are specified, the result of the search will be interleaved
to help analyze the distributed system.

::

ovs-lgrep -s "2021-07-15T16:50:03.018Z" -A 2m */ovn-northd.log

--- File: ovn-central-1/ovn-northd.log ---
2021-07-15T16:50:03.018Z|00252|poll_loop|INFO|Dropped 4 log messages in last 0
seconds (most recently, 0 seconds ago) due to excessive rate
2021-07-15T16:50:03.018Z|00253|poll_loop|INFO|wakeup due to [POLLIN] on fd 12
(192.16.0.1:46952<->192.16.0.1:6641) at lib/stream-ssl.c:832 (91% CPU usage)
2021-07-15T16:50:03.589Z|00254|ovsdb_cs|INFO|ssl:192.16.0.3:6642: clustered
database server is not cluster leader; trying another server
2021-07-15T16:50:03.589Z|00255|ovn_northd|INFO|ovn-northd lock lost. This
ovn-northd instance is now on standby.
--- File: ovn-central-2/ovn-northd.log ---
2021-07-15T16:50:03.590Z|00057|ovsdb_cs|INFO|ssl:192.16.0.3:6642: clustered
database server is not cluster leader; trying another server
--- File: ovn-central-3/ovn-northd.log ---
2021-07-15T16:50:03.590Z|00057|ovsdb_cs|INFO|ssl:192.16.0.3:6642: clustered
database server is not cluster leader; trying another server
--- File: ovn-central-1/ovn-northd.log ---
2021-07-15T16:50:11.597Z|00256|reconnect|INFO|ssl:192.16.0.1:6642: connected

2 changes: 1 addition & 1 deletion ovs_dbg/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def max(self):
return (self.max_mask() & ~self._mask) | (self._value & self._mask)

def __str__(self):
if self.fully:
if self.fully():
return str(self._value)
else:
return "{}/{}".format(hex(self._value), hex(self._mask))
Expand Down
11 changes: 9 additions & 2 deletions ovs_dbg/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,26 @@ class Flow(object):
Args:
sections (list[Section]): list of sections that comprise the flow
orig (str): Original flow string
id (Any): Identifier
"""

def __init__(self, sections, orig=""):
def __init__(self, sections, orig="", id=None):
self._sections = sections
self._orig = orig
self._id = id
for section in sections:
setattr( self, section.name, self.section(section.name).format_data())
setattr(self, section.name, self.section(section.name).format_data())
setattr(self, "{}_kv".format(section.name), self.section(section.name).data)

def section(self, name):
"""Return the section by name"""
return next((sect for sect in self._sections if sect.name == name), None)

@property
def id(self):
"""Return the Flow ID"""
return self._id

@property
def sections(self):
"""Return the section by name"""
Expand Down
8 changes: 4 additions & 4 deletions ovs_dbg/odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
class ODPFlow(Flow):
"""Datapath Flow"""

def __init__(self, sections, raw=""):
def __init__(self, sections, raw="", id=None):
"""Constructor"""
super(ODPFlow, self).__init__(sections, raw)
super(ODPFlow, self).__init__(sections, raw, id)

@classmethod
def from_string(cls, odp_string):
def from_string(cls, odp_string, id=None):
"""Parse a odp flow string
The string is expected to have the follwoing format:
Expand Down Expand Up @@ -109,7 +109,7 @@ def from_string(cls, odp_string):
)
sections.append(asection)

return cls(sections, odp_string)
return cls(sections, odp_string, id)

@classmethod
def _action_parser(cls):
Expand Down
8 changes: 4 additions & 4 deletions ovs_dbg/ofp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
class OFPFlow(Flow):
"""OpenFlow Flow"""

def __init__(self, sections, orig=""):
def __init__(self, sections, orig="", id=None):
"""Constructor"""
super(OFPFlow, self).__init__(sections, orig)
super(OFPFlow, self).__init__(sections, orig, id)

@classmethod
def from_string(cls, ofp_string):
def from_string(cls, ofp_string, id=None):
"""Parse a ofproto flow string
The string is expected to have the follwoing format:
Expand Down Expand Up @@ -102,7 +102,7 @@ def from_string(cls, ofp_string):
)
sections.append(asection)

return cls(sections, ofp_string)
return cls(sections, ofp_string, id)

@classmethod
def _info_decoders(cls):
Expand Down
Loading

0 comments on commit cde38f4

Please sign in to comment.