Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
igeoigeo
Posts: 8 Joined: Tue Oct 08, 2019 3:19 pm
Post
by igeoigeo » Tue Oct 08, 2019 3:25 pm
Hello,
I am looking of how to embed the regular expression that will match a pattern which is multiple times addressed. In other words, this should find only when this pattern is found more than once. Below is an example of a web page (xml), which shows twice the "c start", so I would like to know what is the regex in order to find it?
Code: Select all
<c start="11111" end="1111111" />
<c start="11111" end="222222222" />
</action>
<action
src="abc"
system="2222">
<param
name="trackID"
value="1"
valueType="data">
I know how to find it by using the following regex:
Code: Select all
<c\s+start=\"(?<start>[^\"]+)\"\s+end=\"(?<end>[^\"]+)\"\s+\/>
do you know how to embed it to the check_http plugin?
thank you.
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Tue Oct 08, 2019 3:46 pm
This would do it. You need to
-l to span multiple lines
igeoigeo
Posts: 8 Joined: Tue Oct 08, 2019 3:19 pm
Post
by igeoigeo » Wed Oct 09, 2019 1:17 am
scottwilkerson wrote: This would do it. You need to
-l to span multiple lines
how can I set up the check to alarm when it find multiple lines, i.e. more than once (.*c start.*c start.*)?
thank you.
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Wed Oct 09, 2019 10:06 am
Add
--invert-regex to the command
Code: Select all
--invert-regex
Return CRITICAL if found, OK if not
igeoigeo
Posts: 8 Joined: Tue Oct 08, 2019 3:19 pm
Post
by igeoigeo » Thu Oct 10, 2019 5:53 am
scottwilkerson wrote: Add
--invert-regex to the command
Code: Select all
--invert-regex
Return CRITICAL if found, OK if not
I should rephraise it. The following pattern should be the OK pattern, which contains several regex ".*c start.*c start.*":
Code: Select all
<action
src="abc"
system="2222">
<param
name="trackID"
value="1"
valueType="data">
<c start="11111" end="1111111" />
</action>
<action
src="abc"
system="2222">
<param
name="trackID"
value="1"
valueType="data">
<c start="11111" end="1111111" />
</action>
The alert should be triggered when it finds more that once in the <action> the regex pattern ".*c start.*c start.*
Code: Select all
<action
src="abc"
system="2222">
<param
name="trackID"
value="1"
valueType="data">
<c start="11111" end="1111111" />
<c start="11111" end="222222222" />
</action>
<action
src="abc"
system="2222">
<param
name="trackID"
value="1"
valueType="data">
<c start="11111" end="1111111" />
<c start="11111" end="222222222" />
</action>
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Oct 10, 2019 6:34 am
I'm not a master regex builder but something like this?
Code: Select all
--invert-regex -l -r '.*action.*c start.*c start.*/action.*'
igeoigeo
Posts: 8 Joined: Tue Oct 08, 2019 3:19 pm
Post
by igeoigeo » Thu Oct 10, 2019 8:42 am
scottwilkerson wrote: I'm not a master regex builder but something like this?
Code: Select all
--invert-regex -l -r '.*action.*c start.*c start.*/action.*'
Unfortunatelly, this regex doesn't get the right pattern, I mean that having more than once the pattern this cannot get the critical.