AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 3.129.211.190


Current Path : /var/www/lhjmq-records.qc.ca/public_html/cron_compile/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/cron_compile/isslaveup.php

#!/usr/bin/php
<?php
//variables needed to setup connection
//Check if on wrong server, you should never be on .27 in the admin, cause any mod will stop replication
if($_SERVER['HOSTNAME'] == 'sambuca.xl5.net'){
	//Connection data
	$mysql_host = "localhost";
	$mysql_user = "lhjmq_readonly";
	$mysql_pass = "45GhiLk19cQ";
	$mysql_db = "lhjmq_pii";
	$stat_db = "lhjmqstats_pii";

	//Handle error by SMS if db unavailable
	$mysql_link = @mysql_connect($mysql_host, $mysql_user, $mysql_pass);
	if(!is_resource($mysql_link)){
		@include('../cache/mysql_server_alert.php');
		if(!isset($alert_mysql_connect_errror)){
			$alert_mysql_connect_errror = time()-1;
		}
		if($alert_mysql_connect_errror < time() && $ALERTS_DISABLED == false){
			$alert_mysql_connect_errror = time() + (5*60);
			mail('webalerts@groupimage.com', 'ALERT for '.$_SERVER['SERVER_NAME'], 'ALERT: '.$_SERVER['SERVER_NAME'].', could not connect to mysql server, disable this in index file.');
			$afp = fopen('../cache/mysql_server_alert.php', 'w');
			fwrite($afp, '<?php $alert_mysql_connect_errror = '.$alert_mysql_connect_errror.'; ?>');
			fclose($afp);
		}
		exit('MySQL is not responding'."\n");
	}
	//Handle error by SMS if db unavailable
	if(!@mysql_select_db($mysql_db, $mysql_link)){
		@include('../cache/mysql_server_alert.php');
		if(!isset($alert_mysql_connect_errror)){
			$alert_mysql_connect_errror = time()-1;
		}
		if($alert_mysql_connect_errror < time() && $ALERTS_DISABLED == false){
			$alert_mysql_connect_errror = time() + (5*60);
			mail('webalerts@groupimage.com', 'ALERT for '.$_SERVER['SERVER_NAME'], 'ALERT: '.$_SERVER['SERVER_NAME'].', could not select database, disable this in index file.');
			$afp = fopen('../cache/mysql_server_alert.php', 'w');
			fwrite($afp, '<?php $alert_mysql_connect_errror = '.$alert_mysql_connect_errror.'; ?>');
			fclose($afp);
		}
		exit('MySQL lhjmq_pii db is not valid'."\n");
	}
	//Handle error by SMS if slave is down
	$res = mysql_fetch_assoc(mysql_query('SHOW SLAVE STATUS', $mysql_link));
	if($res['Last_Errno'] != 0 && $res['Last_Error'] != ''){
		@include('../cache/mysql_server_alert.php');
		if(!isset($alert_mysql_connect_errror)){
			$alert_mysql_connect_errror = time()-1;
		}
		if($alert_mysql_connect_errror < time() && $ALERTS_DISABLED == false){
			$alert_mysql_connect_errror = time() + (5*60);
			mail('webalerts@groupimage.com', 'ALERT for '.$_SERVER['SERVER_NAME'], 'ALERT: '.$_SERVER['SERVER_NAME'].', SLAVE IS DOWN, disable this message in index file.');
			$afp = fopen('../cache/mysql_server_alert.php', 'w');
			fwrite($afp, '<?php $alert_mysql_connect_errror = '.$alert_mysql_connect_errror.'; ?>');
			fclose($afp);
		}
		exit('MySQL Slave replication is DOWN'."\n");
	}
	
	mysql_close($mysql_link);
	exit('MySQL Slave replication is working'."\n");
}else{
	exit('Not running slave checker on a master server.'."\n");
}
?>