1 | 1 | simandl | package HotSaNICmod::common; |
2 | | | |
3 | | | sub version { |
4 | | | ($VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/; |
5 | | | return "common.pm $VERSION"; |
6 | | | } |
7 | | | |
8 | | | sub configure { |
9 | | | my %MODCONF=HotSaNICparser::get_moduleconfig(".",(SWAPIO=>"bool",DEV=>"array",STYLE=>"var",SCALE=>"var")); |
10 | | | |
11 | | | if ($MODCONF{STYLE} ne "") { $MODCONF{GRAPH_BASE}=$MODCONF{STYLE}; } |
12 | | | if ($MODCONF{SCALE} ne "") { |
13 | | | $MODCONF{GRAPH_MIN}=-abs($MODCONF{SCALE}); |
14 | | | $MODCONF{GRAPH_MAX}=abs($MODCONF{SCALE}); |
15 | | | if ($MODCONF{SCALE}>0 ) { $MODCONF{GRAPH_RIGID}="yes"; } |
16 | | | } |
17 | | | foreach (@{$MODCONF{DEV}}) { if (index($_,"SNMP:") >=0) { $MODCONF{USE_SNMP}=1; } } |
18 | | | return %MODCONF; |
19 | | | } |
20 | | | |
21 | | | sub get_names { |
22 | | | my $entry=shift || ","; |
23 | | | |
24 | | | my $host=""; |
25 | | | my $community=""; |
26 | | | |
27 | | | my ($item,$maxin,$maxout,$description)=split /,/,$entry; |
28 | | | if( index($item, "SNMP:") >= 0) { (undef,$host,$community,$item,$num) = split /:/,$item; } |
29 | | | if (defined $num) { $item = "$item:$num"; } |
30 | | | if ($host ne "") { $name="$host:$item"; } |
31 | | | else { $name=$item; } |
32 | | | ($dbname=$name) =~ s/:/_/g; |
33 | | | ($file=$name) =~ s/[.:\/]/_/g; |
34 | | | |
35 | | | return ($host,$community,$item,$dbname,$name,$file,$description,$maxin,$maxout); |
36 | | | } |
37 | | | |
38 | | | 1; |
39 | | | |