Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


simple PHP ping script (you only need 1 web server) - Page 2
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

simple PHP ping script (you only need 1 web server)

2

Comments

  • trexostrexos Member

    Going to test it tomorrow :) I really have to sleep now :)

  • skaska Member
    edited July 2013

    Keep in mind that you need to adjust your IPTables in order to be able to open the port from the server the script is running and on the server the script tries to connect to. Thus, you will need to pierce your firewall. It is therefore better to check the ressources on the relevant server and send the result via port 80/443 to the stat-server. The stat-server then displays the stats. The stat-server then can also check if the other server is down if he didn't get a value within a specific time (aggregation/calculation). The nice advantage is that you can add an uptime history quite easily.

    Thanked by 1Spirit
  • SpiritSpirit Member
    edited July 2013

    @ska said:
    Keep in mind that you need to adjust your IPTables in order to be able to open the port from the server the script is running

    This was the issue. @nixcom and @asterisk14 adjust outgoing TCP ports on monitoring server.

    @clone1018 and @trexos - solved I believe.

  • nixcomnixcom Member

    I'll check it later and confirm you guys, thanks for all your time!

  • nixcomnixcom Member

    That was it. The port was blocked on outgoing. My bad... ;)

  • Yes this script may not work on some shared webhosts since the outgoing ports will likely be blocked.

    Some hosts also block fsockopen as its used in a common Denial of Service script.

  • perennateperennate Member, Host Rep

    If all you want is to ping, monit works and it probably has more features.

    I don't know of any monitoring software that requires web server to be installed on slaves if all you want is ping; the only reason slaves would need software is for other data like load, disk usage, etc.

  • Howsabout some Jquery to flash a green /red row on update?

  • taronyutaronyu Member
    edited July 2013

    Threw it on another server so I could try ssh on my LES box.

    http://f63.net/stat.php

    Works fine, ssh is on 3601 and it is showing it is up.

    I'm not sure why my pi is offline, just found a purpose for it and now I can't use it :(

  • NeoonNeoon Community Contributor, Veteran

    Also here in my signature, how do you get the Background in? css?

  • taronyutaronyu Member
    edited July 2013

    Yeah,

    Add:
    http://pastebin.com/1R2wrQ5H
    in your

    and put:
    body {
    background-image:url('bg.jpg');
    background-size: 100%;
    }
    in your style.css

    Now upload a picture and call it bg.jpg. (You can do it without a seperate css file but this was easier for me.)

  • clone1018clone1018 Member
    edited July 2013

    Here's an updated one that doesn't freeze if the host is down, it also continually checks the host every 6 seconds:

    Source: http://paste.kde.org/pde389f82/

    Demo: http://tools.io/misc/status.php

    Thanked by 2Spirit taronyu
  • trexostrexos Member

    What do you mean with freeze?

    I refresh the whole page every 5 seconds with HTML :)

  • @trexos said:
    What do you mean with freeze?

    I refresh the whole page every 5 seconds with HTML :)

    When there is a server down it takes a while to load the page, with his version it will load instantly and then check the servers.

  • skaska Member

    Keep in mind that with the usage of fsockopen() you provide third parties a nice way of bringing your whole server-infrastructure down. All they need to do is massively loading and reloading your script until you flood your servers with requests.

  • NeoonNeoon Community Contributor, Veteran

    Thanks for the Update, only problem is when i have the one .js file local it dosent works 100% like yours.

  • I don't understand @Infinity580

    @ska This was written for internal use, which is why it's one script total not a whole application.

  • NeoonNeoon Community Contributor, Veteran
    edited July 2013

    Äh. i changed this
    cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js
    to this jquery.min.js
    So when you take a closer look you can see the differences.
    The File is local available

  • You'll have to rehost any files that I include if you don't have access to the internet wherever the script is being ran.

  • NeoonNeoon Community Contributor, Veteran

    I just put them local because the page is loading a bit faster as before

  • You need all the bundled icons too.

  • skaska Member

    @clone1018 said:
    This was written for internal use, which is why it's one script total not a whole application.

    I see, but what I've written was directed at those who propagandate the public access to the working script on their servers.

  • NeoonNeoon Community Contributor, Veteran

    @clone1018 Thanks, fixed.

  • Makkesk8Makkesk8 Member
    edited July 2013

    @joelgm said:
    That's just silly. Why do you need to use a third party service, when you can do it on your own server.
    This is something I'm interested in. I might give it a go later.

    Not really since its free?

    And if you were lucky enough to grab a pingdom account in december you could have gotten that for free awell.. (got 3 accounts, total of 30 checks for free) :D

  • skaska Member

    @Makkesk8 said:
    Not really since its free?

    The question to be asked is: Do you want to give third parties insights into your infrastructure and why do you trust third parties more than your own set-up?

  • @ska said:
    The question to be asked is: Do you want to give third parties insights into your infrastructure and why do you trust third parties more than your own set-up?

    I don't really see how a company like pingdom would care if your uptime is 10% or 100% really... and a company like pingdom has way more features and are more reliable than any self hosted stuff, atleast in my case.

    And by using a third party service you don't need that webserver.

  • @ska - it's fun to host something like this on your own site, but like @Makkesk8 said I use scalextreme/uptimerobot/pingdom to monitor my site, even though my site is not critical. Do we really want a LEB monitoring another LEB? Sounds crazy!

  • CoreyCorey Member

    Using php sockets is extremely slow in this case. It's faster to execute the linux ping program from php and then parse the output.

  • skaska Member

    @Makkesk8 said:
    And by using a third party service you don't need that webserver.

    You don't need a webserver in general to perfom pings. A simple bash-script is sufficient. I'm just saying that relying on third parties must not always be a good solution. Especially if a monitoring can be done easily without much hassle and data provided to third parties.

    @asterisk14 said:
    ska - it's fun to host something like this on your own site, but like Makkesk8 said I use scalextreme/uptimerobot/pingdom to monitor my site, even though my site is not critical. Do we really want a LEB monitoring another LEB? Sounds crazy!

    You think using a LEB for monitoring another LEB is crazy but using third party tools that are designed for business usage for a non-critical LEB is not crazy? That sounds crazy! ;-)

Sign In or Register to comment.