学习笔记(5)——实验室集群LVS监控Web界面配置
2024-10-13 04:36:38
症状:通过虚拟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的监控页面马上显示出来了,如下:
最新文章
- 利用jquery.validate以及bootstrap的tooltip开发气泡式的表单校验组件
- Memcached: List all keys
- js节点操作
- C++虚方法(虚函数)随笔
- Windows的同步I/O和异步I/O
- Python 手册——Python的非正式介绍
- UNIQUE NullAble
- Android应用开发学习笔记之绘图
- iOS开发 Android开发 移动Web开发
- 洛谷P2319 [HNOI2006]超级英雄
- Python:matplotlib绘制条形图
- Java微信二次开发(六)
- 【ZZ】号称“开发者神器”的GitHub,到底该怎么用?
- win静态库动态库
- 1、webpack编译打包Sass编译的css进js文件
- route命令使用
- September 22nd 2017 Week 38th Friday
- Egret引擎开发基础(一)
- 统计时间段内周分类SQL语句
- NOI 2018 酱油记