Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1719426
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类: 系统运维

2011-08-15 19:20:52

$ver = '2011090989';

$db_host = "192.168.1.4";
$db_port = 8808;
$db_name = "fivetrees_manage";
$db_user = "root";
$db_pass = '123456';

$db = new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port);

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$sql = "
SELECT
  `name` AS `id`,
  `api_server` AS `node`,
  `db_server` AS `db`
FROM
  `servers`
WHERE
  `cid` != 2 AND
  `open` = 1 AND
  `server_ver` != '$ver'
ORDER BY
  `db_server`, `sid` ASC
";

$plan = '';
$plan_id = 0;
$last_db = '';
$counts = array();

if ($result = $db->query($sql)) {
  while($row = $result->fetch_array(MYSQLI_ASSOC)) {
    $server = substr($row['node'], 0, 5);
    $code = "./shell-update {$row['id']} $server $ver\n";

    if ($last_db != $row['db']) {
      $plan_id = 1;
      $last_db = $row['db'];
      $counts[$plan_id] = 0;
      file_put_contents("update_plan_$plan_id.sh", "");
    }

    $counts[$plan_id] = 1;

    file_put_contents("update_plan_$plan_id.sh", $code, FILE_APPEND);
  }

  $result->close();
}

$db->close();

print_r($counts);
?>

阅读(1142) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

2011-08-17 16:08:00

211阳光生活网 大学生信用卡
http://www.211sun.com/
http://www.83193999.com/