-6

I am a PHP programmer. I want too write a class that can calculate a website times:

  • Lookup DNS
  • Connect
  • Send the request
  • Wait for response
  • Receive response
  • Loading time

How can I make a website like Pingdom? What PHP functions can do this for me?

halfer
  • 19,824
  • 17
  • 99
  • 186
el Fo
  • 9
  • 4
  • PHP CURL should be able to give you a load time for requesting a web page. – Artem Kalinchuk Jul 11 '12 at 12:30
  • This question is far too broad for StackOverflow, but: do these things on the server in a background process, record the results in a database, and then write a website to display the results and modify the ping queue. – halfer Jul 11 '12 at 12:41

2 Answers2

2

You can do a dns lookup with gethostbyaddr, create a connection with fsockopen, write the HTTP request, wait for the response etc. You can calculate the time after each step.

We at www.downnotifier.com use similar ways.

1

I suggest you read the documentation about their API on their website. Don't know if you already read it but hey here's the link

There's some php examples that might be interesting to you.

There is some question that has been asked here on stackoverflow i'll list some of them :

https://stackoverflow.com/questions/9957389/creating-a-website-monitoring-system-like-pingdom-wormly

https://stackoverflow.com/questions/9439669/making-a-website-like-pingdom

Hope this helps you!

Community
  • 1
  • 1
Ben Lefebvre
  • 359
  • 5
  • 21
  • ok.thank you. by/t i want too do this my self in php. what is the function in php ? curl cant help me. i can calculate site loading time with microtime. but cant calculate exact time. – el Fo Jul 11 '12 at 13:07
  • @elFo Convert microtime to seconds: http://stackoverflow.com/questions/6468127/microtime-to-seconds-or-hours-or-min-conversion – Artem Kalinchuk Jul 11 '12 at 13:54
  • I'm looking for a way to measure each step of a (HTTP) web request in php similar to Firebug's network waterfall timeline or Pingdom.com's full page test. Both share a lowest common denominator of showing time spans required for each request to: Lookup DNS Connect Send the request Wait for response Receive response Obviously I can use a timer to measure the web requests , but I looking for some function in php that can give me this exact time. – el Fo Jul 11 '12 at 14:02
  • @elFo You should edit your question to provide some sample code and those exact details. Include what you've already tried, and be clear about what specific problem you're having. As it stands, your question is far too vague to answer. – Chris Baker Jul 12 '12 at 00:04