hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::common;
sub version {
($VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/;
return "common.pm $VERSION";
}
sub configure {
%MODCONF=HotSaNICparser::get_moduleconfig(".",("KERNEL"=>"var","SOURCE"=>"var",DEV=>"array"));
if ($MODCONF{KERNEL} eq "") { $MODCONF{KERNEL}=HotSaNICparser::identify_kernel(); }
if ($MODCONF{SOURCE} eq "") { $MODCONF{SOURCE}=get_source(); }
return %MODCONF;
}
sub get_source {
my $source="stat";
if (-e "/proc/partitions") {
open FILE,"/proc/partitions";
my $check=<FILE>;
close FILE;
if ($check =~ /rio/) { $source="partitions"; }
}
if (-e "/proc/diskstats") {
open FILE,"/proc/diskstats";
my $check=<FILE>;
close FILE;
if ($check =~ /rio/) { $source="diskstats"; }
}
return $source;
}
sub get_names {
my $entry=shift || ",";
my $host="";
my $community="";
my ($item,$description)=split /,/,$entry;
if( index($item, "SNMP:") >= 0) { (undef,$host,$community,$item) = split /:/, $item; }
if ($host ne "") { $name="$host:$description"; }
else { $name=$description; }
$dbname=$item;
($file=$name) =~ s/[\/.:]/_/g;
$description="device: $description";
return ($host,$community,$item,$dbname,$name,$file,$description);
}
1;