Needed
======

  Before doing anythings you need to install the RRDTOOL package.
  LVSGSP is an interface between LVS & RRDtool.

  So go to http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/ and
  install it as described into the RRDtool documentation.

Installing  LVSGSP
==================

  1. uncompress the tarball
  2. cd into the directory
  3. 'make' and 'make install'. This will install lvsgsp into
     /usr/local/bin

Configuration
=============

  1. First run ipvsadm -Ln to see your current LVS topology :

    [root@lvs1 /tmp]# ipvsadm -Ln
    IP Virtual Server version 1.0.8 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port          Forward Weight ActiveConn InActConn
    TCP  192.168.0.9:1358 rr persistent 50
      -> 192.168.6.4:1358             Masq    1      9          4         
      -> 192.168.6.3:1358             Masq    1      5          6         
      -> 192.168.6.2:1358             Masq    1      3          7         
    TCP  192.168.0.9:8080 rr persistent 50
      -> 192.168.6.4:8080             Masq    1      0          0         
      -> 192.168.6.3:8080             Masq    1      0          0         
      -> 192.168.6.2:8080             Masq    1      0          0         
    FWM  1 wlc
      -> 192.168.6.4:80               Route   2      1          3         
      -> 192.168.6.3:80               Route   2      4          1         
      -> 192.168.6.2:80               Route   2      6          2         
    [root@lvs1 /tmp]#

  2. Then test lvsgsp to a specific VS. 
     For example VS 10.10.10.2:1358 :

    [root@lvs1 /tmp]# ./lvsgsp -v 192.168.0.9 1358
    17
    17
    time
    [root@lvs1 /tmp]#

    If you want to use lvsgsp with the FWMARK VS :

    [root@lvs1 /tmp]# ./lvsgsp -f 1
    11
    6
    time
    [root@lvs1 /tmp]#

  3. In the current directoty you will find some shell scripts.
     This script are used to intitialize RRDtool database & 
     RRDtool database update. Those scripts are :

     * Pre-requis : This sample script will deal with the following
                    tree :

       /home/httpd/
               |
               +-- rrdtool (RRDtool database location)
               |
               +-- html    (RRDtool html/images output location)

     * lvsgsp.dbcreate.VS :
       - def : Create the database structure for the virtual 
               server monitoring.
       - synopsis : lvsgsp.dbcreate.VS [vsXXXX]
       - output : will create the wile vsXXXX.rrd into the location
                  /home/httpd/rrdtool/

     * lvsgsp.dbcreate.RS :
       - def : Create the database structure for the real server
               monitoring.
       - synopsis : lvsgsp.dbcreate.RS [rsXXXX]
       - output : will create the wile rsXXXX.rrd into the location
                  /home/httpd/rrdtool/

     * lvsgsp.daily :
       - def : update a VS RRDtool database with refreshed values.
       - synopsis : lvsgsp.daily [vsXXXX] [VIP] [VPORT]
       - output : will create the wile vsXXX-daily.gif into the location
                  /home/httpd/html/

     * lvsgsp.daily.rs :
       - def : update a RS RRDtool database with refreshed values.
               For our sample, this script is hard coded (I know uggly :))
               for our realservers : 192.168.6.2, .3 & .4. This script will
               trace one line per realserver on the same picture.
       - synopsis : lvsgsp.daily.rs [rsXXXX] [RPORT]
       - output : will create the wile rsXXX-daily.gif into the location
                  /home/httpd/html/

     => The same scripts are created for different period : weekly, monthly
        lvsgsp.weekly, lvsgsp.weekly.rs
        lvsgsp.monthly, lvsgsp.monthly.rs

     => Simply copy all this scripts to /usr/local/bin/

  4. Initialize RRDtool databases. For our LVS topology we define one RRDtool
     database per virtual services & realservers : 

     * vs8080 : Database storing informations on global Active/Inactive
                connections for Virtual Server 192.168.0.9 port 8080.
     * vs1358 : Idem as vs8080 but for VPORT 1358
     * rs8080 : Database storing informations on active connections of
                each realserver belonging to VS 192.168.0.9 port 8080.
     * rs1358 : Idem as rs8080 but for VPORT 1358.
              
     [root@lvs1 /tmp]# lvsgsp.dbcreate.VS vs8080
     [root@lvs1 /tmp]# lvsgsp.dbcreate.VS vs1358
     [root@lvs1 /tmp]# lvsgsp.dbcreate.RS rs8080
     [root@lvs1 /tmp]# lvsgsp.dbcreate.RS rs1358

     => Will create RRDttol storing database into /home/httpd/rrdtool/

  5. Ok our databases are created, so we need update it. To update RRDtools
     database, simply use linux CRONTAB, and fill it as follow :

     [root@lvs1 /tmp]# cat /etc/crontab
     SHELL=/bin/bash
     PATH=/sbin:/bin:/usr/sbin:/usr/bin
     MAILTO=root
     HOME=/
     # run-parts
     01 * * * * root run-parts /etc/cron.hourly
     02 4 * * * root run-parts /etc/cron.daily
     22 4 * * 0 root run-parts /etc/cron.weekly
     42 4 1 * * root run-parts /etc/cron.monthly

     # LVS Stats update
     */01 * * * * root /usr/local/bin/lvsgsp.daily vs8080 192.168.0.9 8080 > /dev/null
     */01 * * * * root /usr/local/bin/lvsgsp.daily vs1358 192.168.0.9 1358 > /dev/null
     */01 * * * * root /usr/local/bin/lvsgsp.daily.rs rs8080 8080 > /dev/null
     */01 * * * * root /usr/local/bin/lvsgsp.daily.rs rs1358 1358 > /dev/null
     # LVS Stats weekly refresh
     01 * * * * root /usr/local/bin/lvsgsp.weekly vs8080 > /dev/null
     01 * * * * root /usr/local/bin/lvsgsp.weekly vs1358 > /dev/null
     01 * * * * root /usr/local/bin/lvsgsp.weekly.rs rs8080 > /dev/null
     01 * * * * root /usr/local/bin/lvsgsp.weekly.rs rs1358 > /dev/null
     # LVS Stats monthly & yearly refresh
     01 01 * * * root /usr/local/bin/lvsgsp.monthly vs8080 > /dev/null
     01 01 * * * root /usr/local/bin/lvsgsp.monthly vs1358 > /dev/null
     01 01 * * * root /usr/local/bin/lvsgsp.monthly.rs rs8080 > /dev/null
     01 01 * * * root /usr/local/bin/lvsgsp.monthly.rs rs1358 > /dev/null

     => This will create pictures :
        rs1358-daily.gif    rs8080-monthly.gif  vs1358-weekly.gif   vs8080-yearly.gif
        rs1358-monthly.gif  rs8080-weekly.gif   vs8080-daily.gif
        rs1358-weekly.gif   vs1358-daily.gif    vs8080-monthly.gif
        rs8080-daily.gif    vs1358-monthly.gif  vs8080-weekly.gif

  6. Ok that's all... the next step is to call your web design creativity to
     put this pictures into a nice web page. I have included into this package
     a template html page for displaying RRDtool stats.


Have fun with it !
Alexandre

--
http://www.linuxvirtualserver.org/~acassen/
