症状:通过虚拟IP能访问到监控页面:http://192.168.253.110/ipvsadm.php,但是却无法读出LVS任务分发及集群负载信息。

打开ipvsadm.php页面,源码如下:

<html>
<meta http-equiv="refresh" content="1">
<?php
$cmd = '/home/geohpc/zmq/lvsstatus.sh';//页面每间隔2s会自动刷新,执行该脚本读取LVS负载信息
$result=shell_exec($cmd);
echo "<hr>";
$i = 0;
$table_begin = 0; while ($result)
{
$i++;
$len = strpos ($result, "\n");
$line = substr ($result, 0, $len);
$result = substr ($result, $len + 1);
if ($i <= 3)
continue;
$result = trim ($result, " "); $isReal = strpos ($line, ">");
if ($isReal == 1)
{
// list($jiantou, $ip, $route, $weight, $act, $inact) = split(" ",$line);
$con = preg_split("[ ]",$line,-1,PREG_SPLIT_NO_EMPTY);
$content = "<tr>"; $content = $content."<td>$con[1]</td>";
$content = $content."<td>$con[3]</td>";
$content = $content."<td>$con[4]</td>";
$content = $content."<td>$con[5]</td>";
$content .= "<tr>";
echo $content;
}
else
{
if ($table_begin == 1)
{
echo "</table><div>";
echo "<hr>";
}
$head = "<div align=\"middle\">";
$head .= "<h1>".$line."</h1>";
$head .= "<table border=\"1\" width=\"50%\"><tr>";
$head .="<th width=\"10\">server:port</th>";
$head .="<th>Weight</th>";
$head .="<th>Active</th>";
$head .="<th>Inactive</th>";
$head .="</tr>";
echo $head; $table_begin = 1;
}
}
echo "</table>"
?>
<script>
sleep(2);
window.location.reload();
</script>
</html>

脚本文件lvsstatus.sh如下:

#!/bin/bash
echo "geohpc" | /usr/bin/sudo -S ipvsadm -L

问题:上述脚本文件的含义为以超级用户的权限请求ipvsadm服务,查看其转发状态,而echo后引号内为su用户的密码,这样每次刷新页面执行上述脚本时将自动为sudo填入密码。

可是,此处输入的密码确是错误的,因为为安全起见,2013年初集群演示完毕后更改过一次密码,修改为正确密码后,集群LVS的监控页面马上显示出来了,如下:

最新文章

  1. 利用jquery.validate以及bootstrap的tooltip开发气泡式的表单校验组件
  2. Memcached: List all keys
  3. js节点操作
  4. C++虚方法(虚函数)随笔
  5. Windows的同步I/O和异步I/O
  6. Python 手册——Python的非正式介绍
  7. UNIQUE NullAble
  8. Android应用开发学习笔记之绘图
  9. iOS开发 Android开发 移动Web开发
  10. 洛谷P2319 [HNOI2006]超级英雄
  11. Python:matplotlib绘制条形图
  12. Java微信二次开发(六)
  13. 【ZZ】号称“开发者神器”的GitHub,到底该怎么用?
  14. win静态库动态库
  15. 1、webpack编译打包Sass编译的css进js文件
  16. route命令使用
  17. September 22nd 2017 Week 38th Friday
  18. Egret引擎开发基础(一)
  19. 统计时间段内周分类SQL语句
  20. NOI 2018 酱油记

热门文章

  1. mxonline 总结
  2. Hadoop集群搭建中时间同步步骤
  3. 神经网络优化方法总结:SGD,Momentum,AdaGrad,RMSProp,Adam
  4. linux开机自启动设置,自定义开机启动模版,nginx开机自启动服务
  5. jQuery实用Demo
  6. WPF性能优化的一些建议
  7. CRM项目完成实现
  8. java的构造方法链
  9. FormData序列化及file文件上传
  10. POJ 1740(构造博弈)