1 | 1 | simandl | package HotSaNICmod::common; |
2 | | | |
3 | | | sub version { |
4 | | | ($VERSION = '$Revision: 1.5 $') =~ s/.*(\d+\.\d+).*/$1/; |
5 | | | return "common.pm $VERSION"; |
6 | | | } |
7 | | | |
8 | | | sub configure { |
9 | | | my %MODCONF=HotSaNICparser::get_moduleconfig(".",("ITEM"=>"array",INTERVAL=>"var",LOGPATH=>"var",LOGNAME=>"var")); |
10 | | | |
11 | | | if ($MODCONF{LOGNAME} eq "") { |
12 | | | @dummy=split /\//,$MODCONF{LOGPATH}; |
13 | | | $MODCONF{LOGNAME}=pop @dummy; |
14 | | | $MODCONF{LOGPATH}=join "/",@dummy; |
15 | | | } |
16 | | | if (! @{$MODCONF{ITEM}}) { @{$MODCONF{ITEM}}=("default.ida,CodeRed","cmd.exe,Nimda","root.exe,Nimda"); } |
17 | | | foreach (@{$MODCONF{ITEM}}) { $_ =~ s/:/,/g; } |
18 | | | return %MODCONF; |
19 | | | } |
20 | | | |
21 | | | sub get_names { |
22 | | | my $entry=shift || ","; |
23 | | | |
24 | | | my $host=""; |
25 | | | my $community=""; |
26 | | | |
27 | | | my ($item,$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 | | | 1; |
38 | | | |