First of all, if you have any suggestions on improving this (in fact just-thrown-together-on-request) documentation, or if you encountered any important facts or questions which are not discussed here, please contact us! In fact it's not too hard to hack your own module. For example all parsing of settings and commandline parameters will be done by a set of functions in HotSaNIC.pm and return a quite easy to use hash or array. I'll discuss this later in this document. If you intend to write a module, best thing would be to take a closer look at the other modules to understand what's going on at all. In this document I'll give you a brief overview about the scripts and their roles. First thing is to understand the underlying structure: I splitted each module in some functional parts, this was easier to handle than a one-in-all script, since some parts get called only once and some (read-data) will be called every 10sec. and this way i spare some compilation-time since everything is only parsed/compiled when really needed.
How the data will be queried and stored is up to you, you just have to follow some simple rules: read-data(.pl)
#!/usr/bin/perl -w # include RRDs.pm (from rrdtool) and HotSaNIC.pm using its relative path... # use lib ".."; use HotSaNIC; use RRDs; # get cmdline arguments (i.e. options passed by the daemon) # and other global parameters # %ARGS=arg2opt(@ARGV); dupe_control("start",$ARGS{"MODNAME"},""); # read module-specific settings # foreach (read_settings("."),$ARGS{"MODNAME"}) { ($var,$values)=parse_line($_); ... (evaluation) ... } ... (query data) ... ... (store data) ... dupe_control("stop",$ARGS{"MODNAME"},""); Best thing is to take a closer look at the other modules to learn more about it. makeindex.plthe script creates a file "idxdata" and some .html files in the "index" directory of the module. The format of idxdata has to be as follows:0## <td colspan=2 align=center valign=top> <font size="+3">modulename</font><br> 0## <a href="modulename/6h.html">6 hours</a>(optional) 0## <a href="modulename/week.html">week</a> 0## </td> 1## <td><a href="modulename/device1.html"><img src="modulename/thumb-device1.gif"></a></td> 1## <td valign=top><a href="modulename/device1.html">device1</a><br><font size="-2">description 1</font></td> 2## <td><a href="modulename/device2.html"><img src="modulename/thumb-device2.gif"></a></td> 2## <td valign=top><a href="modulename/device2.html">device2</a><br><font size="-2">description 2</font></td> ... modulename is the name of the module in lower-case, device... and description... refer to some datasources you wish to show. The main makeindex script parses these files to create the main index page (the overview) and moves the files in the modules' "index" directories to the proper places. The numbers preceding each line refer to the position where the devices will be placed in the main index.html - lines beginning with 0## will be üplaced in the title. diagrams(.pl)The only really important thing is that you should take care that the weekly graphs should be generated, because the thumbnails for the main index page will be derived from the weekly graphs. The function HotSaNIC::get_diagram_properties will help you to retrieve all necessary information used in the diagrams. (see HotSaNIC.pm for details)useful hintsSince HotSaNIC samples every 10sec., you should take a closer look at how much time will be spent on sampling the data. If it takes much longer than let's say 5sec., please take a closer look at the PING module, this mod uses an own timebase for exactly the above reaseon.future changesPlease be prepared to "modularize" your module (nice wordplay ;D), because we want to change our concept a bit. This probably would dramatically increase processing speed, since perl does not need to re-compile each script every 10sec. any more.As a side-effect there would then be a separate .pm for each OS in each module that keeps the module's OS-specific parts. This will make debugging a hell of a lot easier. When all this is done, we probably are able to offer a kind of a "skeleton" for homwbrewn modules which holds the core functions. |