![]() |
|
||
|
|
|
||
|
|
|||
|
|
|||||||
| Notices |
| Legacy Archived Main Board Business chat and general industry chat. All participation is welcome. Dont post your fucking spam here. |

![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Stay Out Of The Box
Want to see your own Advertising Here!
Join Date: Oct 2002
Location: Lost in the ozone
Posts: 10,318
|
Thanx for the sticky G
__________________
![]() Free Adult Webcams |
|
|
|
|
|
#2 | ||||||||||||||||||||||||||||||||||||
|
Stay Out Of The Box
Want to see your own Advertising Here!
Join Date: Oct 2002
Location: Lost in the ozone
Posts: 10,318
|
Ok, so I am bored.
I recently had a situation where MYSql tables were crashing on me and because of that all the applications that were accessing the affected tables would grind to a big messy halt. So, I invented a little automated table checking and repair utility that I could launch from the crontab on a regular interval to try to keep the database up and running. My original app checks multiple databases and has a lot of process checking to make sure that no collisions occur. I have modified it down to just check all the tables in one database. And now, I give it to you. Code:
";
//
// This is the address to send the report and errors to
// *** change the line below to indicate the addresses you wish to send reports to
$toaddress="email@address2reportto.com;secondemail@address2reportto.com";
//
// This is the process file. we put this out there at the beginning of the run
// and remove it at the end of the run. If this file exists then
// a maintenance run is already occurring
// **** Change the path below to the proper path on your server
// usually something like /user/web/domain/running
// If you only use it from the browser then this could be
// just running/maint.txt if you create the running folder as a
// subfolder of the folder the app is running from
$processfl="/user/web/domain/running/maint.txt";
//
// database information
//
// *** change the information below to reflect your database settings
//
// database host
$dbhost = "localhost";
//
// database user
$dbuser = "dbusername";
//
// database password
$dbpass = "dbpassword";
//
// database name
$dbname = "dbname";
//
// *** end of data that needs to be modified
//
// End of housekeeping
//
//
// Mainline
//
// check to see if process file already exists.
// if it already exists then email an error report and blow it off
if(file_exists($processfl))
{
$errorstr .="Maintenance tried to start while another instance was running\n\n";
mail_it($errorstr,0,0,1, $fromaddress, $toaddress);
die("Process already running\n\n");
}
//
// ok, another instance is not running so it is ok to run
echo "creating process file\n";
//
// create the process file
// first you open it
$fp=fopen($processfl,'a');
if($fp)
{
// then you close it
fclose($fp);
}
// Check to see if file created ok. I know I know I could just
// look at $fp. But there is always the possibillity that the
// file handler came back ok but the file did not get created
// this covers that.
// if the file did not get created then email an error report and blow it off
if(!file_exists($processfl))
{
$errorstr .="Maintenance could not create the process file\n\n";
mail_it($errorstr,0,0,1, $fromaddress, $toaddress);
die("Could Not Create Process File\n\n");
}
else
{
echo "created the process file\n";
}
// lets hook up to MYSql
// If we dont get a good connection we will
// mail an error report and blow it off
$db = mysql_connect($dbhost, $dbuser, $dbpass);
if(!$db)
{
$errorstr .="Could not connect to MYSQL\n\n";
$errorstr .="MySql error was " . mysql_error() . "\n\n";
mail_it($errorstr,0,0,1, $fromaddress, $toaddress);
die("Could not connect to mysql\n\n");
}
//
// Now we select the database that we are going to check
$selected=mysql_select_db($dbname);
//
// ok, we are good to go
//
// Turn off the server timeout in case of a long winded check or repair operation
set_time_limit(0);
//
// Yeah I know, I am combining appearance and logic here. Bite me.
// This is old school baby, think CGI ;p
// Lets format a table to make our output all need and pretty
// we want a four (4) column table because the commands we will
// use return multiple lines of 4 column output.
$outstr .= "
__________________
![]() Free Adult Webcams |
||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|