Remstats Home


  About remstats
  architecture
  Release Notes
  FAQ
  Conventions
  Prerequisites
  Installation
  Configuration
  Configuration Tools
  Servers
  Collectors
  Updater
  Monitors
  pagemakers
      graph-writer
      snmpif-setspeed
      datapage-alert-writer
      datapage-interfaces
      datapage-inventory
      datapage-status
      page-writer
      view-writer
  run-remstats2
  CGIs
  troubleshooting
  do-traceroutes
  Miscellany
  Thank-you
  Index


  Live Data

  Remstats was written by
  Thomas Erskine at the
  CRC in Canada and now
  at SourceWorks.

[Top] [Prev] [Next]

page-writer

Note: I intend to completely replace graph-writer with page-writer as soon as I'm comfortable with it. If you've made changes to graph-writer, then you will need to look at page-writer to see how to incorporate your changes. Luckily, page-writer is intended to be configurable, unlike graph-writer, so you oughtn't to need to change the program, only the page templates.

Usage:

Can't locate RRDs.pm in @INC (@INC contains: . /usr/lib/remstats/lib /usr/lib/perl5/ /etc/perl /usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8.0 /usr/share/perl/5.8.0 /usr/local/lib/site_perl) at ../page-writer line 38.
BEGIN failed--compilation aborted at ../page-writer line 38.

Description:

Like view-writer's templates, it generates pages from templates with special mark-up. It is triggered as a pagemaker and attempts to generate the pages specified in the pages config-file.

Simple Tags

The first lot are the most important as they produce the graphs:

  • <REMSTATS::GRAPH imagedir host rrd graph graphtime>

    - which gets translated to a <RRD::GRAPH...> tag for rrdcgi to generate the requested graph.

    Note: don't get attached to the form of the tag as I'm considering modifying it to something like:

    	<REMSTATS::GRAPH HOST="host" RRD="rrdname" GRAPH="graphname" 
    	[TIME="timename"] [START="starttime"] [END="endtime"] [SIZE="XxY"]>

    to accomodate the need for extra optional things, like overriding the size.

  • <REMSTATS::CUSTOMGRAPH imagedir customname graphtime> - which get translated to a <RRD::GRAPH ...> tag for rrdcgi.

The next lot make it easy to produce the original look of remstats:

  • <REMSTATS::HEADER title> - produces a remstats standard page header
  • <REMSTATS::STATUSHEADER> (for hosts status headers) and
  • <REMSTATS::RRDHEADER> (for graph headers) and
  • <REMSTATS::BAREHEADER> - for page-top HTML up to the begining of the body.
  • <REMSTATS::TOOLBAR hostname> - produces a remstats host toolbar
  • <REMSTATS::FOOTER> - produces a remstats page footer

The next group are to allow you to design your own look:

  • <REMSTATS::INCLUDE filename> - translated to <RRD::INCLUDE ...> for rrdcgi
  • <REMSTATS::TEMPLATE templatename> - inserts a copy of the named template at this point, substituted as usual. (See <REMSTATS::PAGE...> below.)
  • <REMSTATS::VAR varname> - inserts the value of the variable "varname" (usually one of: NAME, FILE, GROUP, HOST, RRD, GRAPH or GRAPHTIME)
  • <REMSTATS::VAR::WILD varname> - inserts the value of the variable "varname" (usually one of: NAME, FILE, GROUP, HOST, RRD, GRAPH or GRAPHTIME), but doesn't substitute wild graph-names.
  • <REMSTATS::VAR::FIXED varname> - as <REMSTATS::VAR...> but applies the to_filename function to the value so that it can be used in a path (file or URL) without worrying about, e.g., "/" characters screwing things up.
  • <REMSTATS::VAR::FIXED::WILD varname> - as <REMSTATS::VAR...> but applies the to_filename function to the value so that it can be used in a path (file or URL) without worrying about, e.g., "/" characters screwing things up, but doesn't substitute wild graph-names.
  • <REMSTATS::SET::VAR varname the value> - define a variable for later use.
  • <REMSTATS::SET::VAR::FIXED varname the value> - as <REMSTATS::SET::VAR...>, but applies the to_filename function to the value as does <REMSTATS::VAR::FIXED...>.
  • <REMSTATS::SET::VAR::CONFIG varname key1 ...> - sets a variable to a value from the configuration specified by the keys

Iterator Tags

Thes tags have begin and end markers and replicate the text between them. For example, a <REMSTATS::FOR::GROUP ...> tag will replicate the enclosed text once for each selected group.

  • <REMSTATS::FOR::GROUP [NAME="groupname"] [LIST="g1,g2,..."]> ... </REMSTATS::FOR::GROUP>
  • <REMSTATS::FOR::HOST [NAME="hostname"] [LIST="h1,h2,..."] [WITHIN="GROUP"] [TAG="TAG"]> ... </REMSTATS::FOR::HOST>
  • <REMSTATS::FOR::RRD [NAME="rrdname"] [LIST="r1,r2,..."] [WITHIN="HOST"] [TAG="TAG"]> ... </REMSTATS::FOR::RRD>
  • <REMSTATS::FOR::GRAPH [NAME="rrdname"] [LIST="g1,g2,..."] [WITHIN="RRD|CUSTOMGRAPH"]> ... </REMSTATS::FOR::GRAPH>
  • <REMSTATS::FOR::GRAPHTIME [NAME="rrdname"] [LIST="t1,t2,..."] [WITHIN="GRAPH"]> ... </REMSTATS::FOR::GRAPHTIME>
  • <REMSTATS::FOR::CUSTOMGRAPH [NAME="customgraphname"] [LIST="c1,c2,..."] [WITHIN="HOST"]> ... </REMSTATS::FOR::CUSTOMGRAPH>

All of these group everything inside them and evaluate the contents with the appropriate variables set as specified. There are four cases:

  1. The tag has no parameters. This means that the block will be replicated once for each instance of that kind of thing. E.G. the <REMSTATS::FOR::HOST> tag with no parameters will be replicated as many times as there are hosts, and each copy will have HOST set to one of the possible hosts, sorted alphabetically.
  2. The tag supplies a variable the same as its type. E.G. <REMSTATS::FOR::HOST HOST="xxx"> This will produce one copy of the block, with the variable set to the specified value (in the example, HOST will be "xxx").
  3. The tag supplies a parameter LIST="x,y,...". This kind of tag will be copied as many times as there are elements of the list (comma-separated, no spaces). The copies will be ordered as they are in the list.
  4. The tag supplies a parameter WITHIN="xxx". This will select a subset of the items:

The <REMSTATS::PAGE ...> Tag

The powerful one which allows a page to cause the generation of other pages.

  • <REMSTATS::PAGE pagename filename>

This will cause page-writer to generate the specified page at this point. If it's within one of the iterators, then it will be triggered multiple times with various values for the variables. This way, specifying a single page in the pages config-file, can trigger the generation of a whole family of pages.

The <REMSTATS::CHDIR ...> Tag

This changes the current directory for page generation. This allows a PAGE directive to generate a full sub-directory tree of pages, with the correct templates. Note that it will create missing directories, but not missing hierarchies. This is intentional; it would be tedious and error-prone to have to create them by hand. It will, however, note as a non-fatal error when it creates directories.

The <REMSTATS::CHMOD mode file> Tag

Changes the mode (an octal number) of the file. Mainly to make the GRAPHS sub-directories writable by the remstats group.

The <REMSTATS::CHGRP group file> Tag

Changes the group of the file file to group. Mainly to make the GRAPHS sub-directories writable by the remstats group.

The <REMSTATS::MKDIR ...> Tag

This is identical to the <REMSTATS::CHDIR> tag, except that it doesn't change the current directory. Note that it won't complain if the directory already exists.

Variable substitution within tags

Since I don't want to get into the hairy parsing required, you can't embed tags within other tags. I've found, so far, that the only thing that I've needed to insert into a tag was the value of a variable, so that's the only non-simple-text that you can use inside a tag.

To insert the value of a variable, include a string like "##XXX##" where "XXX" is the name of the variable whose value you want.

Avoiding extra whitespace

End a line in a page template with a backslash "\" and the newline that would normally be present will not be passed on to the generated page.


[
Top] [Remstats] [SourceWorks] [RRDtool] [SourceForge]
Last updated Fri Sep 5 07:34:17 UTC 2003 by <terskine@users.sourceforge.net>.