|
|
|
|
|
|
| |
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 | | | Check if a file exists on a remote FTP server with PHP Categories : PHP, FTP, Regexps | | | Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS) | | | Simple way to replace a variable value in a .conf (.ini) file using a
webbrowser - the first stage of a complete universal configuration editor Categories : PHP, Regexps, Code Editors, Filesystem | | | ereg -- Regular expression match Categories : PHP, PHP Functions, Regexps | | | Intelligent 404 Handler Categories : PHP, Errors and Logging | | | Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP Categories : PHP, HTTP, Regexps | | | BBCode Formatting String Categories : PHP, HTML, Regexps, Arrays | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | I need a trim function/regexp that will trim all " " from the ends of a string. Categories : Regexps, PHP, Strings | | | This script is a contact form between users of a
website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps | | | Form input return conformance Categories : HTML and PHP, PHP, Regexps | | | Simple PHP program which calls other PHP program you can pass the
variables to other PHP program : by Raju Categories : PHP, PHP Options and Info, Regexps, Program Execution | | | A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors Categories : PHP, Variables, Errors and Logging | | | How to build a search query for any N number of words in a search string Categories : PHP, Regexps, Search Engines, Search | |
|
|
|