Re: [PHP] Checking if a host is online

From: Adam Maas (mykroft_at_mykroft.com)
Date: 11/29/03


Date: Sat, 29 Nov 2003 12:28:07 -0500
To: Adam Maas <mykroft@mykroft.com>

Adam Maas wrote:

> Jason Giangrande wrote:
>
>> I'm creating an application for an Intranet that, among other things, is
>> supposed to check to see if particular hosts are online, and if so, what
>> their IP address is. Anyone know how I can accomplish this? I tried
>> using exec("host $host"); (where $host is the hostname) and while this
>> gets the IP it gets the IP address sometimes even if the host is not
>> active, because a DNS record for the system still exists. I also looked
>> into the gethostbyname() function, but that has similar problems to
>> using the external host command. I also tried to use an external ping
>> command (ping -c 1 $host), and while I could get that to work, since it
>> returns non-zero status if the host can not be contacted, it takes quite
>> a while to execute for even a few hosts at once.
>> Anyone ever do this king=d of thing before or have any suggestions on
>> what might work?
>
>
> why not try:
>
> passthru("ping $host");
>
> Adam
>

My bad, didn't read closely enough.

It's not likely to be able to do this fast, ef you only want it to query
when asked. You may want to look into a monitoring solution like NOCOL.

Adam



Relevant Pages

  • RE: gShield and iptables question
    ... Adam ... I can still see connections from these hosts. ... Norton Antivirus 2K3. ...
    (RedHat)
  • Re: OT: Maybe old news... Re: ZoneAlarm/Hosts (long list)
    ... So you add an entry into your "hosts" file like this... ... references in your "hosts" file, ... having your online IP address registered as "active" etc. ... more adverts from THAT server either! ...
    (alt.med.fibromyalgia)
  • Re: Keith Alexanders account on AIM
    ... > them online. ... he doesn't know who hosts keithalexander.com. ... anyone wan ... but i was running out the door - i meant research on what it'll cost to ...
    (rec.arts.bodyart)
  • Re: xp home sp2 ?
    ... >Firewall,AVG antivirus,AdShield and have a Hosts file.Unit used for a ... >home grown research project,edit movie projects,surf,read ... >weblogs,daily news,games and online buying.Use online services for ... >My question is will SP2 be of use to this setup? ...
    (microsoft.public.windowsxp.general)
  • N95 8GB self repair...
    ... Have worn out some of the keys on my N95 8GB, is there anywhere online that ... hosts a detailed manual for the dissasembly and repair of this phone? ...
    (uk.telecom.mobile)