0

We get sporadic connection fails from webserver to another server. We intended to use tracert based on sockets to determine where it fails. Unfortunately it is impossible to create RAW sockets on webserver due to it's not ran under root (and we cannot do this obvously).

Is there a way to traceroute from PHP without sockets?

Mufasa10
  • 35
  • 4
  • This may be a bit obtuse, but is there a reason why you need to check the connection using PHP as opposed to traceroute using bash? Do you not have any access to the server, even as a regular user? If you could add some more context about your server/application setup, that might help someone answer this one. – killthrush Jul 31 '15 at 11:53
  • To catch error on the run on script execution. – Mufasa10 Jul 31 '15 at 12:12
  • Server runs under Unix (don't know which). I can try to ask to add a script which will be runed from PHP if that is what you mean. – Mufasa10 Jul 31 '15 at 12:13
  • the requirement is quite strange; when building for the net failure must be handled because will happen. gracefully fallback and warn the user to retry or put the work in a queue. also what's the plan with a traceroute? when you identify that the failure is at the Nth hop (eg a router overseas) what will you do? – Paolo Jul 31 '15 at 13:11
  • @Paolo It's kind of simplier. Webserver accesses local network service. We test connection in the morning and send error messages if connection fails. There are reasons why in the morning and why this way. The problem is different. Since connection fail occures sporadically - we had an idea to trace connection at the moment of failure. We have about 100 addresses and some of them can fail, some would never fail. So testing connection manually is not an option. – Menas Eru Aug 03 '15 at 06:32
  • @MenasEru I didn't suggest manual operations. warn the user = send email or give the user a feedback on the page or whatever is the automatic warning system in place. regarding the issue, this is not something to handle in the application: the application must be able to resist failures and that's it. to identify the reason behind the failure provide all the information you have to your sysadmin: is his/her job to find the reason of network failures. – Paolo Aug 03 '15 at 07:30
  • @Paolo The story is following. There is a backend script that test connections to a set of IPs. If connection cannot be established - send an email to admin. It worked OK. But recently we got too many messages per day and tried to figure out where is the problem. It is impossible to test it manually because everyting could be ok for an IP for whole day and fail only once the other day while other IPs are ok. Even if you check connection right after seeing the message - connection appears to be fine. – Menas Eru Aug 03 '15 at 10:54
  • @MenasEru what you put in the comment are info that should be in the question. also the more you write the more the issue looks like a system issue. it is not the application that is failing but 'something' between app and service so you'd better ask for support to a sysadmin and/or network admin. – Paolo Aug 03 '15 at 11:04
  • @Paolo now you got it. :) That is why we need to find out where on the network problem occurs on the run. – Menas Eru Aug 04 '15 at 06:28
  • @Paolo Network admin wouldn't help with this for several reasons. Firstly - we don't have inhouse admin that can spend a day or few to test the issue - everything is set up by third party company. Secondly - since the issue is not constant we do not have enough information to give. So the question is good as it is so I won't have to explain unnecessary details. – Menas Eru Aug 04 '15 at 06:34

1 Answers1

0

you may hunt for nqt.php to get some hint about how to proceed: is an ancient tool that was able to do all the net stuff from a php page (i don't know the internals but may be a good starting point).

some link to test (found using google):
http://www.vanheusden.com/misc/nqt.php
http://eaglesflight.org/nqt.php

the only download i found (i don't know if it is the most recent version):
http://nerdbynature.de/bits/misc/nqt.php.txt

Paolo
  • 2,224
  • 1
  • 15
  • 19
  • Thanks! Looks like it's also based on sockets but doesn't use SOCK_RAW. I'll try to implement it. It would be great if it works. – Menas Eru Aug 05 '15 at 06:38
  • you're welcome. i found a more recent (almost 10 years old anyway...) version tagged as 1.9. you can download it [here](http://janick.no-ip.org/tools/nqt.zip) – Paolo Aug 05 '15 at 06:55
  • @MenasEru feel free to tag my post as answer ^^ – Paolo Aug 05 '15 at 11:17