Re: Problem using WebDetector in default-foreign-source.xml

David Hustace <[email protected]>
Newsgroups gmane.network.opennms.general
Message-ID <[email protected]>
Try the HttpDetector and set the parameter maxRetCode to 200 and checkRetCode = true.  However, I have found a bug reported that this doesn't work.  If you can confirm it we could escalate the issue especially if you could send us the HTTP response that you're server is sending.

FYI: I do hate the inconsistency in these parameter names and I abhor camel case parameter and attribute names.  Maybe a good DevJam 2018 project for me.


David


> On Apr 19, 2018, at 07:22, Jonathan Heard <[email protected]> wrote:
> 
> Hi John,
> 
>    From what I can discern via a quick search of the code, WebDetector uses opennms/core/web/HttpClientWrapper.java which in turn uses the Apache HttpClient library, and this does appear to follow redirects by default.
> 
> Based on the examples shown on this blog http://www.baeldung.com/httpclient-stop-follow-redirect I can't see anywhere in OpenNMS's wrapper that disables or allows you to disable redirection.  I think this would be an ideal feature to have in a detector but I'm 50/50 on whether this is a bug or a feature request as following redirects is generally a reasonable thing for the detector to do. Either way I think you should probably raise is as an issue. Interestingly there's an old (and seemingly unresolved) issue that HttpMonitor doesn't follow redirects: https://issues.opennms.org/browse/NMS-5338
> 
> Based on this quick look, I reckon that the feature could be relatively easily implemented by adding a method to HttpClientWrapper which allows setting of a followRedirects boolean, and expose it via the WebDetector class too.
> 
> In this particular case, you could possible use HttpDetector instead but this only allows you to set maxRetCode which is a bit restrictive, but if you set it to 200 then there only appears to be four 1xx codes which are all a bit obscure;https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_Informational_responses
> 
> HTH
> 
> Jonathan
> 
> 
> On 19/04/18 04:18, JohnD Blackburn wrote:
>> Hi All,
>> 
>> I’ve come across an issue with setting up a web detector.
>> 
>> I’ve added the following to default-foreign-source.xml
>> 
>>       <detector name="RFINTEG-logcall" class="org.opennms.netmgt.provision.detector.web.WebDetector">
>>          <parameter key="port" value="80"/>
>>          <parameter key="responseRange" value="200-200"/>
>>          <parameter key="timeout" value="10000"/>
>>          <parameter key="path" value="/cgi-bin/logcall.pl"/>
>>       </detector>
>> 
>> 
>> And this is working and correctly detecting that URI on the server that is supposed to be serving that.  However, there is another server that automatically redirects all calls to non-existent URI’s to /users/signin/
>> 
>> If I perform a curl on http://wrongserver/cgi-bin/logcall.pl I see the return code of 302 with a reference to /users/signin/
>> And of course running curl against http://wrongserver/users/signin/ is giving a return code of 200.
>> 
>> In the foreign source detector, I set the response range to only accept 200 as valid code thinking that it would exclude the 302, but it appears that the WebDetector is following the 302 redirect and using the response code of the re-directed URI, so is therefore incorrectly detecting this URI where it should not.
>> 
>> How do I stop the detector from following the redirect, and only detecting the URI if there is no re-direct?   In this case, if I get a 302, then this is not the web server I am looking for…
>> 
>> 
>> 
>> 
>> 
>> 
>> Regards,
>> John Blackburn
>> 
>> 
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org!
>> http://sdm.link/slashdot
>> 
>> 
>> _______________________________________________
>> Please read the OpenNMS Mailing List FAQ:
>> 
>> http://www.opennms.org/index.php/Mailing_List_FAQ
>> 
>> 
>> opennms-discuss mailing list
>> 
>> To *unsubscribe* or change your subscription options, see the bottom of this page:
>> 
>> https://lists.sourceforge.net/lists/listinfo/opennms-discuss
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
> Please read the OpenNMS Mailing List FAQ:
> http://www.opennms.org/index.php/Mailing_List_FAQ
> 
> opennms-discuss mailing list
> 
> To *unsubscribe* or change your subscription options, see the bottom of this page:
> https://lists.sourceforge.net/lists/listinfo/opennms-discuss

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-discuss mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-discuss
signature.asc (application/pgp-signature, 873 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIzBAEBCAAdFiEEM8HVsB3Payb01u1DmyrG1LpC+MIFAlrYjL0ACgkQmyrG1LpC
+MLOYRAApR1o3YYCt1nRMsKh3tEWbr7EhjAHoOFmclGXUwELP/qqzlag5BZUPNqq
r8sjbFg0gPKQNJgyeX+l5KE444TfGVwex/n8BxLO3X7eAVhHCLTu21Rh3h/6gHIi
eVt1HWJgZnbz1qcrp9kJhBI2MSNq+VSoPKeJk7ZdtJ5Hgn+L/68WayZ23K1W4pHn
YtOEIiAbb5LNOFgyUBc8pAM2M251DoL8GbxYt/YxL6fRpMY9XFeGSSsDX2uKme7s
j5VTRhTYjuHnhMHAdkx5EZiG76JbZie4alzl1GEHojTDn2TGKURPsY+3p1qayAbJ
Csjcy66ybGD+sWFdr+lHq6xj4y9jxw2s6zXE6ocJLJHGJsFySkgeZ4DMWB2+hCQH
2FLY/br22GaIAKgmy3U9BlRw2T3YyoRCbwoDX8ozBsmJJ1SI2McByEesTgt+XpEm
lXXrYnitgIDFOwrOyKY2UBLk3eGOPBmNEPNB0XBSD86AuolGLWr7bdsXPfigeEiw
w/OV9hHsKt0wvKd8wWoi14E8wouE9R28Y8NG8wzerQm4vj1+x/crW9qlica6lPsR
lFJSjD+72q53Mo5we7y60sd/6nprH4U++bQl3z0TNsAwzWgnRLbsVUMP41TBJMC6
AVNFPbgWORtYzK69AiDs3kwySg0xLlVBHqIjSp5sfT9ywFKFP1g=
=VT6y
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.