Oliver Gorwits > YATG-5.130520 > usr/lib/cgi-bin/yatgview.cgi

Download:
YATG-5.130520.tar.gz

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Source   Latest Release: YATG-5.140510

IMPORTANT NOTE ^

Do not place this script on a public or Internet-accessible web server!

It is a proof-of-concept, and contains no parameter checking whatsoever, so your users can pass any old junk parameters in, and they will be assumed valid. This could cause your web-server to be hacked.

The author and copyright holder take no responsibility whatsoever for any damages incurred as a result of using this software.

DESCRIPTION ^

The two CGI scripts included in this distribution offer an example of how you might visualize data polled by YATG. Specifically, they are designed for showing traffic counter levels on switch ports, as polled by YATG.

The first CGI script creates a basic HTML web page, with some boilerplate text determined by GET parameters. The second CGI retrieves data from your YATG storage back-end and outputs a PNG image. It is called three times by the first CGI script for day, week and month graphs.

LIMITATIONS ^

You need to poll the ifHCInOctets and ifHCOutOctets SNMP leaf names with YATG, and mark them with the ifindex magic word in your configuration.

Further, this code expects to use the Disk or RPC YATG retreival modules. The main configuration file for your YATG system needs to be available on the web server running this CGI. In the examples/ folder of this distribution, that would be the yatg.yml file. Of course, this configuration file must have the right settings for your local YATG installation.

Graphs are generated by this CGI using the excellent ChartDirector graphing component from ASE. Please support the product by buying a license - it's very good value for money.

USAGE ^

The first thing is to have the two CGI scripts installed in a location where your web server will execute them as Perl CGI.

The script names can be anything you like, but if you change them from the defaults of yatview.cgi and yatggraph.cgi then be sure to update your main configuration file.

Then, make sure your web server is setting the following two environment variables when calling the CGI:

 YATG_CONFIG_FILE  # main YATG configuration, e.g. yatg.yml
 YATG_GRAPH_CONF   # graph hints file, copied from examples/yatg_graph.pl

For example, in your Apache2 config:

 SetEnv YATG_CONFIG_FILE /etc/yatg.yml
 SetEnv YATG_GRAPH_CONF  /etc/yatg_graph.pl

You will see the CGI die, and an error in your Apache error log if these variables are not being set correctly.

The author has patched the NetDisco network management tool web interface to generate links to this CGI with the correct GET parameters for each device port, and you will have to do something similar locally. These are the parameters accepted, and of course they should be URI-escaped:

ip

This must be the IP address of the device of which you want to retrieve stored YATG results.

dns

This should be a human-readable name for the device mentioned in ip. It is used verbatim in the boilerplate HTML text and graph title.

port

This must be the port on the device, as used by YATG to store the results, e.g. GigabitEthernet5/1 (but URI-escaped, of course).

As a special case, if the port CGI parameter is given more than once, then the data values for the two ports are summed together and a graph drawn of that. This might be handy if you load share over multiple links but want a single utilization graph.

name

This should be a human-readable description for the device interface mentioned in port. For example the value obtained from the ifAlias SNMP OID, something like Trunk Link to Campus.

CONFIGURATION ^

There is one required configuration setting in the main YATG configuration, and some optional parameters.

graph_generator

This setting is required. It must be the complete URI linking to the yatggraph.cgi CGI script as available through your web server. For example:

 yatg:
     graph_generator:
         'https://my.web-server.example.com/cgi-bin/yatggraph.cgi'
background_image

Set this parameter if you want a background image on the main HTML page, for example:

 yatg:
     background_image: '/images/grey-back.gif'
homepage

If there is an error in the HTML page gneration (although be warned there isn't much error checking!) then you will see a link back to your site homepage if set in this parameter, e.g.:

 yatg:
     homepage: '/netdisco'
perlchartdir_key

Graphs are generated by this CGI using the excellent ChartDirector graphing component from ASE. If you have registered the product, then set this parameter to your license key. Otherwise, things will work fine but you'll see the small ASE banner on each graph.

SEE ALSO ^

http://www.advsofteng.com/cdperl.html

Graphs are generated by this CGI using the excellent ChartDirector graphing component from ASE. Please support the product by buying a license - it's very good value for money.

ACKNOWLEDGEMENTS ^

This CGI is based upon the RTG CGIs by Anthony Tonns.

syntax highlighting: