|
|
|
|
|
|
| |
Autor: Antonio Leal Elizondo 12/Ago/03
e-mail: invasor@hotmail.com
This script pings a machine and checks if it's alive or not.
It can run a command in case the machine is not answering
|
<?php
// Variables
//-------------------------
$unix = 1; //Put 1 here if you are using a UNIX machine
$windows = 0; //Put 1 here if you are using a Windown machine
$unix = (bool) $unix;
$win = (bool) $windows;
$count= 3; // Number of times to ping
$host = "177.17.31.165"; // IP of the remote server
$find = "Tiempo de espera agotado"; // String to look for
$shell= "pwd"; // Command to execute if the machine does not answer.
$findUnix="0 packets received";
// Replaced nonvalued characters
$host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
echo("Resultados: ");
//Check the IP
if ($unix==1){
$comm="ping -t $count $host";
$res=shell_exec($comm);
}else{
$comm="ping -n $count $host";
$res=shell_exec($comm);
}
// system("killall ping");// Kill all pings in case they exist.
//echo $res;
$flag= strstr($res,$findUnix);
$long=strlen($flag);
if ($long<>0){
echo "\n An error has occured at $host\n ";
echo date("D F Y h:i a");
echo "\n Executng auxiliary command \n ";
$res=shell_exec($shell);
echo $res;
}else{
echo "\n There are no problems with $host \n";
echo date("D F Y h:i a"). "\n" ;
}
?> | |
|
|
| DB Connection Function with error handling and email failure notices Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging | | | How to strip non-alpha characters from a string Categories : Regexps, PHP | | | Get the AppStore Ranking for any iPhone App Categories : PHP, Web Services, Regexps | | | Visits-tracking Categories : PHP, Databases, MySQL, Errors and Logging, Functions | | | Building a basic error handler with custom error types Categories : PHP, PHP Classes, Errors and Logging | | | grab the result of any calculation you submit to the Google Calculator. Categories : PHP, Arrays, Web Services, Regexps, Math. | | | Check if a file exists on a remote FTP server with PHP Categories : PHP, FTP, Regexps | | | The GTV.class allows you to extract a value between any HTML tag or between any TEXT on a web page. Categories : PHP, PHP Classes, Regexps | | | validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email
addresses via SMTP and regex. Categories : Email, Regexps, PHP | | | BBCode Formatting String Categories : PHP, HTML, Regexps, Arrays | | | Making sure a string containes only digits or no digits. Categories : Strings, PHP, Regexps | | | a PHP Function to Get only the filename (remove the extension) using regular expressions. Categories : PHP, Regexps, Beginner Guides | | | email validator check checker email e-mail email address Categories : PHP, Email, Regexps | | | Example of function to send out email if error occurs Categories : PHP, Email, Debugging, Errors and Logging | | | Newbie Notes #7 - Ridiculous regex Categories : PHP, Beginner Guides, Regexps | |
|
|