• 学习笔记(5)——实验室集群LVS监控Web界面配置


    症状:通过虚拟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, "
    ");
        $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的监控页面马上显示出来了,如下:

  • 相关阅读:
    (16)C#继承
    (3)新概念英语一(11-20)lessons
    (15)C#集合
    (14)编码
    (2)新概念英语一(1-10)lessons
    (13)C#数组和元组
    Uva 11729 Commando War
    Uva 11292 Dragon of Loowater
    谈谈单元最短路
    [USACO 3.3.1]骑马修栅栏t
  • 原文地址:https://www.cnblogs.com/yeahgis/p/3470066.html
Copyright © 2020-2023  润新知