本帖最后由 andy 于 2009-11-18 09:45 编辑
#!/usr/local/php/bin/php
<?php
$master = mysql_connect('192.168.111.36', 'discuz', 'mysqlpaswd');
$slave['35'] = mysql_connect('192.168.111.35', 'discuz', 'mysqlpaswd');
$slave['28'] = mysql_connect('192.168.111.28', 'discuz', 'mysqlpaswd');
while(1) {
$members_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_members", $master), 0);
$threads_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_threads", $master), 0);
$posts_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_posts", $master), 0);
echo "\r\n";
echo "\033[05;32mShou\033[0m \033[01;031mshou\033[0m";
echo "\r\n".date("Y-m-d H:i:s");
echo "\r\n"."host members threads posts"."\r\n";
echo "master ".$members_master." ".$threads_master." ".$posts_master."\r\n";
foreach($slave as $k=>$v){
$slave_members_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_members", $v), 0);
$slave_threads_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_threads", $v), 0);
$slave_posts_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_posts", $v), 0);
echo $k." ".
$slave_members_master.($slave_members_master==$members_master?" ":"*")." ".
$slave_threads_master.($slave_threads_master==$threads_master?" ":"*")." ".
$slave_posts_master.($slave_posts_master==$posts_master?" ":"*")."\r\n";
}
sleep(2);
}
?>
#!/usr/local/php/bin/php
<?php
$master = mysql_connect('192.168.111.36', 'discuz', 'mysqlpaswd');
$slave['35'] = mysql_connect('192.168.111.35', 'discuz', 'mysqlpaswd');
$slave['28'] = mysql_connect('192.168.111.28', 'discuz', 'mysqlpaswd');
while(1) {
$members_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_members", $master), 0);
$threads_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_threads", $master), 0);
$posts_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_posts", $master), 0);
echo "\r\n";
echo "\033[05;32mShou\033[0m \033[01;031mshou\033[0m";
echo "\r\n".date("Y-m-d H:i:s");
echo "\r\n"."host members threads posts"."\r\n";
echo "master ".$members_master." ".$threads_master." ".$posts_master."\r\n";
foreach($slave as $k=>$v){
$slave_members_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_members", $v), 0);
$slave_threads_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_threads", $v), 0);
$slave_posts_master = mysql_result(mysql_query("SELECT COUNT(*) FROM discuz.cdb_posts", $v), 0);
echo $k." ".
$slave_members_master.($slave_members_master==$members_master?" ":"*")." ".
$slave_threads_master.($slave_threads_master==$threads_master?" ":"*")." ".
$slave_posts_master.($slave_posts_master==$posts_master?" ":"*")."\r\n";
}
sleep(2);
}
?>
编辑回复