473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Check the hosts that can be accessed via the icmp protocol.

I have to Check the hosts that can be accessed via the icmp protocol. Displays all the IP in a table.
Add one more field to the table to indicate if these hosts is reached, the time to access these hosts.
Sorry if my English is not good.

This is what I have done, but I don't know how to continue:I get the ips and if yo access or not. But I dont know how to get the time
Thanks for your help
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "<table border='1'>";
  3. for ($i=1;$i<=254;$i++) {
  4.  
  5. $IP = '10.10.120.'.$i;
  6. $comando = 'ping 10.10.120.' . $i. ' -n 1';
  7. $ejecucion = popen($comando,'r');
  8.  
  9. $accesible='si';
  10. while (!feof($ejecucion)) { //while not end of file($ejecucion)
  11. $linea = fgets($ejecucion);
  12. $campos = explode('inaccesible',$linea);
  13. if (count($campos) == 2) {
  14. $accesible='no';
  15. }
  16. }
  17. echo "<tr> <td> $IP </td> <td> $accesible </td> </tr>";
  18.  
  19. }
  20. echo "</table>";
  21.  
  22. ?>
  23.  
May 28 '11 #1
1 1479
I continue trying to get something

When I do each one separately I can see.

Count ($ field == 8) gives me the time and if I Count ($ field == 2), I see if it is accessible or not.

The problem is to bring the two together to see all the information in a table
(IPS, times, yes or no)

<code>

<?php
echo "<table border='1'>";
for ($i=220;$i<=254;$i++) {

$IP = '10.10.120.'.$i;
$comando = 'ping 10.10.120.' . $i. ' -n 1';
$ejecucion = popen($comando,'r');

$tiempo=microtime(); //'timestamp';
while (!feof($ejecucion)) { // mientras no sea el final del archivo($ejecucion)
$linea = fgets($ejecucion);
$campos = explode('tiempo',$linea);

if (count($campos) == 8) {
$tiempo='timestamp';
}


/* $accesible='si';
if ($count($campos)==2) {
//while (!feof($ejecucion)) { // mientras no sea el final del archivo($ejecucion)
//$linea = fgets($ejecucion);
//$campos = explode('inaccesible',$linea);
//if (count($campos) == 2) {
$accesible='no';
} */


//}************************************************* *******/

}
echo "<tr> <td> $IP </td> <td> $tiempo </td> </tr>";
// echo "<tr> <td> $IP </td> <td> $tiempo </td> <td> $accesible</td> </tr>";

}

echo "</table>";
?>
</code>
May 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Bob Rivers | last post by:
Hi, I was doing a research looking for Java solutions that are able to do "ping". I found old messages (and not so old ones), telling that Java was not able to do that, because the API...
0
by: Andreas Pauley | last post by:
Hi, I'd like to generate my own icmp packets from within python. Typically this would include sending an ECHO_REQUEST and checking if I get an ECHO_REPLY back. But I would also like to...
2
by: NotNeo | last post by:
I am getting a strange symptom: tnsping and sqlplus work fine on my LINUX server (neo) so the listener and DB are OK. However, from my remote XP Client (tank) I get TNS-12560. I can ping the neo...
6
by: Charles Law | last post by:
This is going to seem like a basic OO question, but it comes up and bites me every now and again. Suppose we have a multi-tiered protocol to implement, what is the logical, OO way to design the...
0
by: shoorik | last post by:
Folks, SiteID is an exciting new protocol that I've been planning and designing during the past couple of months. It's currently in early release, but I've been hoping to make somewhat of a...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
5
by: Tom Anderson | last post by:
Hi all, This is a little function to compare two iterators: def icmp(a, b): for xa in a: try: xb = b.next()
9
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and...
9
by: selvialagar | last post by:
I've tried to implement icmp protocol in my application(vc++.net 2003).I am using windows xp..My program works fine..but it takes lot of time to reply the message..what is the reason for it?Round...
5
by: mike.coakley | last post by:
Does stream_socket_client use the /etc/hosts file? I'm using Mac OSX 10.5.3 as a development platform and VMware Fusion for VM hosting. I have a OpenSUSE Linux VM that has an Apache 2 web server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.