症状:通过虚拟IP能访问到监控页面:http://192.168.253.110/ipvsadm.php,但是却无法读出LVS任务分发及集群负载信息。
打开ipvsadm.php页面,源码如下:
";$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 = ""; $content = $content."$con[1]"; $content = $content."$con[3]"; $content = $content."$con[4]"; $content = $content."$con[5]"; $content .= ""; echo $content; } else { if ($table_begin == 1) { echo ""; echo "
"; } $head = ""; $head .= "".$line."
"; $head .= ""?>
"; $head .=" "; echo $head; $table_begin = 1; } }echo "server:port "; $head .="Weight "; $head .="Active "; $head .="Inactive "; $head .="
脚本文件lvsstatus.sh如下:
#!/bin/bashecho "geohpc" | /usr/bin/sudo -S ipvsadm -L
问题:上述脚本文件的含义为以超级用户的权限请求ipvsadm服务,查看其转发状态,而echo后引号内为su用户的密码,这样每次刷新页面执行上述脚本时将自动为sudo填入密码。
可是,此处输入的密码确是错误的,因为为安全起见,2013年初集群演示完毕后更改过一次密码,修改为正确密码后,集群LVS的监控页面马上显示出来了,如下: