jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [Documentation/] [module-howto/] [howto-default.pm] - Blame information for rev 30

 

Line No. Rev Author Line
11simandlThe "default.pm" file in the "platform" directory does the data-acquisition and storage.
2It is there as a fallback in case a OS-dependent library could not be found.
3 
4This library must match the following skeleton:
5 
6---------- BEGIN CODE ----------
7package HotSaNICmod::OSdep;
8 
9sub version { return "version string"; }
10 
11sub sample {
12 my %args=@_;
13 
14 # for each datasource do this:
15 # - query datasource(s)
16 # - update database(s)
17 
18 }
19 
201;
21---------- END CODE ----------
22 
23 
24 
25 
26---------- The "version" funciton ----------
27 
28This function just has to return some identifier string including the library name. If the file is going to be checked into some CVS repository, it is wise to use the CVS keyword "Revision" to automatically include the version number in the version string:
29 
30 
31Example:
32 sub version {
33 ($VERSION = '$Revision: 1.1 $') =~ s/.*(\d+\.\d+).*/$1/;
34 return "default.pm $VERSION";
35 }
36 
37 This will return the string "default.pm 1.1".
38 
39 
40 
41---------- The "sample" funciton ----------
42 
43This function will be called regularly by the rrdtimer script using a "USR1" signal that is sent to the running module.
44The function has to parse all datasources and store all results in the corrosponding databases.
45 
46The hash %args contains the module's confguration hash including some global configuration items as well.
47Global items that are put into the hash are:
48 
49 DEBUGLEVEL the maximum of the debuglevels configured in the module's and the global settings.
50 MODNAME name of the module in upprecase
51 SNMPGET path to "snmpget" (as far as configured)
52 SNMPWALK path to "snmpwalk" (as far as configured)
53 VARDIR path to the "var" directory for this module (i.e. globally configured vardir plus "/modules/<module name>")
54 
55All other items from the module's "settings" file will be added as defined in the module's "commpn.pm" library.
56 
57 
58 
59As an example, let's assume the following situation:
60 
61settings contain some lines of the format:
62TARGET="<script_to_call>"
63TARGET="<another_one>"
64TARGET="<yet_another_one>"
65 
66 
67the common.pm should contain an initialization of the "TARGET" items as array type
68 
69 
70The "default.pm" code may for example look like this:
71 
72 
73---------- BEGIN CODE ----------
74package HotSaNICmod::OSdep;
75 
76sub version {
77 ($VERSION = '$Revision: 1.1 $') =~ s/.*(\d+\.\d+).*/$1/;
78 return "default.pm $VERSION";
79 }
80 
81sub sample {
82 %args=@_;
83 
84 foreach $script (@{$args{TARGET}}) {
85 $result=system "$script";
86 HotSaNICmod::do_rrd($script,"U",time,$result);
87 }
88 
89 return %MODARGS
90 }
91 
921;
93 
94---------- END CODE ----------
95 
96 
97This will cause the "TARGET" array to be traversed. All array entries will be taken as scripts that have to be called, and the result of these scripts are assumed to be single values that can be fed directly into a .rrd database using the "do_rrd" function from the "HotSaNICmod.pm" library.
98 
99The parameters for "do_rrd" are:
100 
101 HotSaNICmod::do_rrd(<RRD name>,<max. expected value>,<time>,<array of results>);
102 
103 this will update the given database with the contents of the corrosponding array.
104 If the DB doesn't exist, it will be created using the given maximum.
105 
106 

Powered by WebSVN 2.2.1