-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New specs var_log_pcp_openmetrics_log (#3596)
Signed-off-by: Mohit Kumar <[email protected]>
- Loading branch information
1 parent
ffeb412
commit 04ddde3
Showing
5 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.. automodule:: insights.parsers.pcp_openmetrics_log | ||
:members: | ||
:show-inheritance: |
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,32 @@ | ||
""" | ||
PcpOpenmetricsLog - file ``/var/log/pcp/pmcd/openmetrics.log`` | ||
-------------------------------------------------------------- | ||
""" | ||
from insights.specs import Specs | ||
from insights import LogFileOutput, parser | ||
|
||
|
||
@parser(Specs.pcp_openmetrics_log) | ||
class PcpOpenmetricsLog(LogFileOutput): | ||
""" | ||
Parse the ``/var/log/pcp/pmcd/openmetrics.log`` log file. | ||
.. note:: | ||
Please refer to its super-class :class:`insights.core.LogFileOutput` | ||
Sample input:: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store 55% {: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store }: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store 95% {: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store }: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store };: | ||
Examples: | ||
>>> "Error: cannot parse/store" in log | ||
True | ||
>>> len(log.get('pmdaopenmetrics')) == 5 | ||
True | ||
""" | ||
pass |
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,26 @@ | ||
import doctest | ||
from insights.parsers import pcp_openmetrics_log | ||
from insights.tests import context_wrap | ||
|
||
|
||
PCP_OPENMETRICS_LOG = """ | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store 55% {: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store }: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store 95% {: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store }: | ||
[Mon Jul 11 07:59:32] pmdaopenmetrics(1733) Error: cannot parse/store };: | ||
""".strip() | ||
|
||
|
||
def test_pcp_openmetrics_log(): | ||
log = pcp_openmetrics_log.PcpOpenmetricsLog(context_wrap(PCP_OPENMETRICS_LOG)) | ||
assert "Error: cannot parse/store" in log | ||
assert len(log.get('pmdaopenmetrics')) == 5 | ||
|
||
|
||
def test_documentation(): | ||
failed_count, tests = doctest.testmod( | ||
pcp_openmetrics_log, | ||
globs={'log': pcp_openmetrics_log.PcpOpenmetricsLog(context_wrap(PCP_OPENMETRICS_LOG))} | ||
) | ||
assert failed_count == 0 |