Needed
======

  Before doing anythings you need to install the MRTG package. This
simple progy is an interface between LVS & MRTG.

  So go to www.mrtg.org and install it as described into the MRTG
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  10.10.10.2:1358 rr persistent 50
      -> 192.168.10.4:80             Masq    1      9          4         
      -> 192.168.10.3:80             Masq    1      5          6         
      -> 192.168.10.2:80             Masq    1      3          7         
      -> 192.168.10.1:80             Masq    1      8          1         
    TCP  10.10.10.2:8080 rr persistent 50
      -> 192.168.10.4:8080           Masq    1      0          0         
      -> 192.168.10.3:8080           Masq    1      0          0         
      -> 192.168.10.2:8080           Masq    1      0          0         
      -> 192.168.10.1:8080           Masq    1      0          0         
    FWM  1 wlc
      -> 192.168.10.13:80            Route   2      1          3         
      -> 192.168.10.12:80            Route   2      4          1         
      -> 192.168.10.11:80            Route   2      6          2         
      -> 192.168.10.10:80            Route   1      2          8         
    [root@lvs1 /tmp]#

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

    [root@lvs1 /tmp]# ./lvsgsp -v 10.10.10.2 1358
    25
    18
    time
    [root@lvs1 /tmp]#

    If you want to use lvsgsp with the FWMARK VS :

    [root@lvs1 /tmp]# ./lvsgsp -f 1
    13
    14
    time
    [root@lvs1 /tmp]#

  3. Then must configure MRTG to parse this output values.
     jump into your mrtg.cfg and fill it like this :

    [root@lvs1 /tmp]# cat /etc/mrtg.cfg 
    # WorkDir: directory where mrtg will send its html output,
    # must be readable by your httpd/browser.
    # you need to create /Workdir/LVS

    WorkDir: /usr/local/mrtg
    IconDir: /usr/local/mrtg/images/

    # LVS stats
    Target[LVS]: `/usr/local/bin/lvsgsp -v 10.10.10.2 1358`
    Directory[LVS]: LVS
    MaxBytes[LVS]: 150
    Options[LVS]: gauge growright
    Title[LVS]: LVS connections stats
    PageTop[LVS]: <H1>LVS connections stats</H1>
    XSize[LVS]: 500
    YSize[LVS]: 50
    WithPeak[LVS]: dwmy
    YLegend[LVS]: Connections nb
    ShortLegend[LVS]: connections
    LegendI[LVS]: &nbsp;Active:
    LegendO[LVS]: &nbsp;Inactive:
    [root@lvs1 /tmp]#

    ATTENTION: you must create the directory /usr/local/mrtg/LVS
    before. All computed graphics will reside in that location.

  4. Just verify that mrtg is started every 5 minutes into your
     crontab. For example on my redhat box :

    [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

    # MRTG refresh
    */05 * * * * root /usr/local/mrtg/bin/mrtg /etc/mrtg.cfg 2>/dev/null
    [root@lvs1 /tmp]#

  5. Well that's all. All the stats of the LVS connections table will
     be in /usr/local/mrtg/LVS

  6. Link this directory to your webserver to view stats with your browser.


Rem1: If you want to monitor more than 1 Virtual Service, you simply
      need to add multiple Target entry into your mrtg.cfg.
      For example :

      [root@lvs1 /tmp]# cat /etc/mrtg.cfg
      # WorkDir: directory where mrtg will send its html output,
      # must be readable by your httpd/browser.
      # you need to create /Workdir/LVS

      WorkDir: /usr/local/mrtg
      IconDir: /usr/local/mrtg/images/

      # VS1 10.10.10.2:1358
      Target[VS1]: `/usr/local/bin/lvsgsp -v 10.10.10.2 1358`
      Directory[VS1]: LVS
      MaxBytes[VS1]: 150
      Options[VS1]: gauge growright
      Title[VS1]: LVS connections stats for VS1
      PageTop[VS1]: <H1>LVS connections stats for VS1</H1>
      XSize[VS1]: 500
      YSize[VS1]: 50
      WithPeak[VS1]: dwmy
      YLegend[VS1]: Connections nb
      ShortLegend[VS1]: connections
      LegendI[VS1]: &nbsp;Active:
      LegendO[VS1]: &nbsp;Inactive:

      # VS2 10.10.10.2:8080
      Target[VS2]: `/usr/local/bin/lvsgsp -v 10.10.10.2 8080`
      Directory[VS2]: LVS
      MaxBytes[VS2]: 150
      Options[VS2]: gauge growright
      Title[VS2]: LVS connections stats for VS2
      PageTop[VS2]: <H1>LVS connections stats for VS2</H1>
      XSize[VS2]: 500
      YSize[VS2]: 50
      WithPeak[VS2]: dwmy
      YLegend[VS2]: Connections nb
      ShortLegend[VS2]: connections
      LegendI[VS2]: &nbsp;Active:
      LegendO[VS2]: &nbsp;Inactive:
      [root@lvs1 /tmp]#

      All generated graphs will be located into WorkDir/LVS.

Rem2: We can also create multiple storage directory changing the
      Directory entry (to VS1 and VS2). That way generated graphs
      will be located into WorkDir/VS1 and WorkDir/VS2 (assuming
      those two directories are created).


Have fun with it !
Alexandre

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