This support forum board is for support questions relating to
Nagios XI , our flagship commercial network monitoring solution.
lpereira
Posts: 143 Joined: Thu Jul 27, 2017 4:23 pm
Post
by lpereira » Wed Nov 21, 2018 5:29 pm
Hello all:
I have successfully configured a webinject page content, it can login to the url and te response is "WebInject OK - All tests passed successfully in seconds"
However i need to check if a expression exist, and send the alert accordingly if the expresion has been changed.
the plain text is
"Transaction capacity 30000/0"
and the code is
<tr><td class="nrow">Transaction capacity</td><td>30000/0</td><td></td></tr>
Can someone assist in order to get this configured?
this is the complete code i have
Code: Select all
<testcases repeat="1">
id="1"
description1="short description"
description2="long description"
method="post"
url="http:/XXX.XXX.XXX/csl/check"
postbody="username=XXXX&userpwd=XXXX"
verifypositive="verify this string exists"
verifynegative="verify this string does not exist"
logrequest="yes"
logresponse="yes"
sleep="3"
</testcases>
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Mon Nov 26, 2018 9:50 am
Have you tried something like this?
Code: Select all
<testcases repeat="1">
id="1"
description1="short description"
description2="long description"
method="post"
url="http:/XXX.XXX.XXX/csl/check"
postbody="username=XXXX&userpwd=XXXX"
verifypositive='<tr><td class="nrow">Transaction capacity</td><td>30000/0</td><td></td></tr>'
verifynegative="verify this string does not exist"
logrequest="yes"
logresponse="yes"
sleep="3"
</testcases>
lpereira
Posts: 143 Joined: Thu Jul 27, 2017 4:23 pm
Post
by lpereira » Mon Nov 26, 2018 9:56 am
scottwilkerson wrote: Have you tried something like this?
Code: Select all
<testcases repeat="1">
id="1"
description1="short description"
description2="long description"
method="post"
url="http:/XXX.XXX.XXX/csl/check"
postbody="username=XXXX&userpwd=XXXX"
verifypositive='<tr><td class="nrow">Transaction capacity</td><td>30000/0</td><td></td></tr>'
verifynegative="verify this string does not exist"
logrequest="yes"
logresponse="yes"
sleep="3"
</testcases>
yes and i have modified the verify positive check (30000/0 to 30000/5) in order to force an alert, but still in green.
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Mon Nov 26, 2018 12:30 pm
Actually, the code there shouldn't have both a positive and negative
How about something like this
Code: Select all
<testcases repeat="1">
id="1"
description1="short description"
description2="long description"
method="post"
url="http:/XXX.XXX.XXX/csl/check"
postbody="username=XXXX&userpwd=XXXX"
verifypositive="30000/0"
logrequest="yes"
logresponse="yes"
sleep="3"
</testcases>
lpereira
Posts: 143 Joined: Thu Jul 27, 2017 4:23 pm
Post
by lpereira » Mon Nov 26, 2018 1:30 pm
scottwilkerson wrote: Actually, the code there shouldn't have noth a positive and negative
How about something like this
Code: Select all
<testcases repeat="1">
id="1"
description1="short description"
description2="long description"
method="post"
url="http:/XXX.XXX.XXX/csl/check"
postbody="username=XXXX&userpwd=XXXX"
verifypositive="30000/0"
logrequest="yes"
logresponse="yes"
sleep="3"
</testcases>
made the changes, forced the alert but nothing hass been changed
Code: Select all
<testcases repeat="1">
id="1"
description1="short description"
description2="long description"
method="post"
url="http://XXX.XXX.XXX/XXX/XXX"
postbody="username=XXX&userpwd=XXX"
verifypositive="30000/0"
logrequest="yes"
logresponse="yes"
sleep="3"
</testcases>
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Mon Nov 26, 2018 1:38 pm
Looking at our example case in the wizard I see this:
Code: Select all
<testcases repeat="1">
<testvar varname="LOGIN_URL">http://myserver/login.php</testvar>
<testvar varname="LOGIN1">bob</testvar>
<testvar varname="PASSWD1">sponge</testvar>
<testvar varname="SUCCESSFULL_TEST_TEXT">Welcome Bob</testvar>
<case
id="1"
description1="login test case"
description2="verify string login"
method="post"
url="${LOGIN_URL}"
postbody="login=${LOGIN1}&passwd=${PASSWD1}"
verifypositive="${SUCCESSFULL_TEST_TEXT}"
/>
</testcases>
It is like you are actually missing the inner
<case
Can we try the following
Code: Select all
<testcases repeat="1">
<testvar varname="LOGIN_URL">http:/XXX.XXX.XXX/csl/check</testvar>
<testvar varname="LOGIN1">XXXX</testvar>
<testvar varname="PASSWD1">XXXX</testvar>
<testvar varname="SUCCESSFULL_TEST_TEXT">30000/0</testvar>
<case
id="1"
description1="login test case"
description2="verify string login"
method="post"
url="${LOGIN_URL}"
postbody="login=${LOGIN1}&passwd=${PASSWD1}"
verifypositive="${SUCCESSFULL_TEST_TEXT}"
/>
</testcases>
lpereira
Posts: 143 Joined: Thu Jul 27, 2017 4:23 pm
Post
by lpereira » Mon Nov 26, 2018 1:51 pm
scottwilkerson wrote: Looking at our example case in the wizard I see this:
Code: Select all
<testcases repeat="1">
<testvar varname="LOGIN_URL">http://myserver/login.php</testvar>
<testvar varname="LOGIN1">bob</testvar>
<testvar varname="PASSWD1">sponge</testvar>
<testvar varname="SUCCESSFULL_TEST_TEXT">Welcome Bob</testvar>
<case
id="1"
description1="login test case"
description2="verify string login"
method="post"
url="${LOGIN_URL}"
postbody="login=${LOGIN1}&passwd=${PASSWD1}"
verifypositive="${SUCCESSFULL_TEST_TEXT}"
/>
</testcases>
It is like you are actually missing the inner
<case
Can we try the following
Code: Select all
<testcases repeat="1">
<testvar varname="LOGIN_URL">http:/XXX.XXX.XXX/csl/check</testvar>
<testvar varname="LOGIN1">XXXX</testvar>
<testvar varname="PASSWD1">XXXX</testvar>
<testvar varname="SUCCESSFULL_TEST_TEXT">30000/0</testvar>
<case
id="1"
description1="login test case"
description2="verify string login"
method="post"
url="${LOGIN_URL}"
postbody="login=${LOGIN1}&passwd=${PASSWD1}"
verifypositive="${SUCCESSFULL_TEST_TEXT}"
/>
</testcases>
i modified it as requested, now i have an error msj
Code: Select all
(Return code of 25 for service 'CRONOS' on host 'CRONOS' was out of bounds)
No close element tag [Ln: 14, Col: 57]
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Mon Nov 26, 2018 4:26 pm
Can you PM me the whole file, I just tested the above example and didn't get an error.
It could be possible that the login or password contains special chars not valid in XML and we may need to work around that.
lpereira
Posts: 143 Joined: Thu Jul 27, 2017 4:23 pm
Post
by lpereira » Tue Nov 27, 2018 6:01 am
scottwilkerson wrote: Can you PM me the whole file, I just tested the above example and didn't get an error.
It could be possible that the login or password contains special chars not valid in XML and we may need to work around that.
Thanks i have sent you the file.
regards
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Tue Nov 27, 2018 8:54 am
Your PM stated the new error was
lpereira wrote: Code: Select all
"WebInject CRITICAL - Test case number 1 failed"
This is different than the error you posted in the thread
Code: Select all
(Return code of 25 for service 'CRONOS' on host 'CRONOS' was out of bounds)
No close element tag [Ln: 14, Col: 57]
Are you 100% sure there are no other fields required to be posted? this could cause it to not authenticate properly.