Skip to content

Enhanced parser#90

Open
rendicott wants to merge 5 commits into
shawn-sterling:masterfrom
rendicott:enhanced-parser
Open

Enhanced parser#90
rendicott wants to merge 5 commits into
shawn-sterling:masterfrom
rendicott:enhanced-parser

Conversation

@rendicott

Copy link
Copy Markdown

Love the project by the way. However, a lot of my perfdata comes from windows boxes and NSClient++ which spits back nasty perfdata UOM strings. raws[0] and raws[1] in the below example are actual sample data that makes up 80% of my disk space checks. These were all throwing exceptions in the process_log() function because it was splitting on spaces. I wrote a parser_enhanced() function that finds the true delimiter with nasty perfdata strings like this.

Let me know if it looks like it could benefit the project.

raws = [    "c: free=201.06451GB;0.97656;0.48828;0;279.37899 c: free %=71%;0;0;0;100",
            "total 5m=2%;80;90 total 1m=1%;80;90 total 5s=2%;80;90",
            "my perf/descrip is awsom!=20gbs;30ms;70rs dis$isdope=45%;80gs",
]

Types of exceptions I was seeing
image

How it was showing up in Graphite:
graphios-graphite-parsed

Russell Endicott added 5 commits October 7, 2015 18:36
@shawn-sterling

Copy link
Copy Markdown
Owner

Hi There, sorry for the delay I was at a conference (re:invent) all week.

Thank you for taking the time to write this.

Can you take a peek at the 'parserfix' branch and see if that works with your data? The branch is going to be a bit behind now, because for some reason people keep saying they will go test it and no-one ever gets back to me. :) heh

Anyways, if the parserfix branch doesn't fix the problem, then I'll take a closer look at this and we'll move forward with it.

Have a good day.

@rendicott

Copy link
Copy Markdown
Author

Hey Shawn,
I took a look at the 'parserfix' branch and I see how it would handle labels with a single quote in the name since it's doing a shlex.split() instead of the standard string split(). However, even with the shlex.split() labels with spaces in the name will still be a problem.

e.g.,

>>> import shlex
>>> shlex.split(s)
['c:', 'free=201.06451GB;0.97656;0.48828;0;279.37899', 'c:', 'free', '%=71%;0;0;0;100']

It looks like that's all that the parserfix branch is doing is those few lines.

I checked to make sure my parser could handle labels with single quotes in them as was intended with the shlex split using this raw data:

raws = [    "c: free=201.06451GB;0.97656;0.48828;0;279.37899 c: free %=71%;0;0;0;100",
            "total 5m=2%;80;90 total 1m=1%;80;90 total 5s=2%;80;90",
            "my perf/descrip is awsom!=20gbs;30ms;70rs dis$isdope=45%;80gs",
            "'label cool'=56mb;10mb;8mb bob's awesome label=45mbps;43mbps",
]
C:\source\rendicott-github\graphios2>python enhancedparser.py
CHUNKS= '['c:_free=201.06451GB;0.97656;0.48828;0;279.37899', 'c:_free_%=71%;0;0;0;100']'
CHUNKS= '['total_5m=2%;80;90', 'total_1m=1%;80;90', 'total_5s=2%;80;90']'
CHUNKS= '['my_perf/descrip_is_awsom!=20gbs;30ms;70rs', 'dis$isdope=45%;80gs']'
CHUNKS= '["'label_cool'=56mb;10mb;8mb", "bob's_awesome_label=45mbps;43mbps"]'

It looks like it handles it just fine. My new function in the enhanced-parser branch should be able to handle any character in the label name as long as it's not an = or ; which I think is similar to how pnp4nagios handles parsing.

Please do test it though :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants