![]() ![]() |
hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/usr/bin/env perl# $Id: setup.pl,v 1.14 2004/07/12 07:50:13 bernisys Exp $# include PERL librariesuse strict;use warnings;use diagnostics;# include HotSaNIC librariesuse lib "../../lib";use lib "./platform";use HotSaNICparser;use HotSaNICshellio;use HotSaNIClog;use common;$|=1;(my $VERSION = '$Revision: 1.14 $') =~ s/.*(\d+\.\d+).*/$1/;(my $IDENTIFIER = '$Id: setup.pl,v 1.14 2004/07/12 07:50:13 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;my $MODNAME=HotSaNICparser::get_module_name();my %MODCONF=HotSaNICmod::common::configure();my $OUTFILE="settings.new";if ( ! -e "settings" ) { $OUTFILE="settings"; }open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n";if (! @{$MODCONF{DEV}}) { @{$MODCONF{DEV}}=get_devs(); }if (@{$MODCONF{DEV}}) { $MODCONF{DEV}="DEV=\"".join("\"\nDEV=\"",@{$MODCONF{DEV}})."\""; }else { $MODCONF{DEV}=""; }print OUTFILE "# SHORT DESCRIPTION## kernel version# KERNEL=\"2.2\" for 2.1.x and 2.2.x kernels# KERNEL=\"2.4\" for 2.3.x and 2.4.x kernels# etc.#KERNEL=\"$MODCONF{KERNEL}\"# set the correct datasource for kernel 2.4 and later# use \"stat\" for kernels <2.4 and for 2.4 kernels# without /proc/partitions stats support# 2.6 kernels might support /proc/diskstats as well, which# seems to be pretty identical with /proc/partitions## SOURCE=\"stat\"# SOURCE=\"partitions\"# SOURCE=\"diskstats\"#SOURCE=\"$MODCONF{SOURCE}\"# all entries have to be of the form:# DEV=<device>,<device name>## <device> the device-number as in /proc/stat -> disk_io# for kernels < 2.3 \"0\" is the first drive, \"1\" the second ...# <2.3 kernels support (unless patched) only 4 drives.## <device name> a description for the device## Example for Kernel >= 2.3:# DEV=8_0,sda# DEV=3_0,hda# DEV=22_0,hdc## Example for Kernel <= 2.2:# DEV=0,hda# DEV=1,hdb#$MODCONF{DEV}";close OUTFILE;if ($OUTFILE eq "settings.new") {HotSaNICparser::backup_file("settings");rename "settings.new","settings";}print "Please check the settings file and adapt it to satisfy your needs.\n";sub get_devs {# see kernel2.4 /usr/src/linux/fs/proc/proc_misc.cmy @devs=();my %devlist = ( "3_0" => "/dev/hda", "3_64" => "/dev/hdb", "22_0" => "/dev/hdc", "22_64" => "/dev/hdd","33_0" => "/dev/hde", "33_64" => "/dev/hdf", "34_0" => "/dev/hdg", "34_64" => "/dev/hdh","8_0" => "/dev/sda", "8_1" => "/dev/sdb", "8_2" => "/dev/sdc", "8_3" => "/dev/sdd","8_4" => "/dev/sde", "8_5" => "/dev/sdf", "8_6" => "/dev/sdg", "8_7" => "/dev/sdh","8_8" => "/dev/sdi", "8_9" => "/dev/sdj", "8_10" => "/dev/sdk", "8_11" => "/dev/sdl","8_12" => "/dev/sdm", "8_13" => "/dev/sdn", "8_14" => "/dev/sdo");if ($^O eq "netbsd") {open RESULT,"/usr/sbin/iostat -Ix|";while (<RESULT>) {chomp;my ($drv) = split / /, $_;next if ($drv =~ /device/ || $drv =~ /md?/ ||$drv =~ /fd?/);push @devs,"$drv,$drv";}}elsif ($^O eq "linux") {my $usepart=0;if (-e "/proc/partitions") {open STAT,"/proc/partitions";my $check=<STAT>;if ($check =~ /rio/) {$usepart=1;while (<STAT>) {if ($_ ne "\n") {my ($major,$minor,undef,$device)=split;if (HotSaNICshellio::askyesno("Use $device","y") eq "y") {push @devs,$major."_$minor,$device";}}}}close STAT;}if ($usepart == 0) {open STAT,"/proc/stat";while (<STAT>) {chomp;if (/disk_io/) {foreach (split) {next if /disk_io:/;my $major;my $minor;/\(([0-9]+),([0-9]+)\)/, $major=$1, $minor=$2;my $device=$devlist{$major."_$minor"};if (HotSaNICshellio::askyesno("Use $device","y") eq "y") {push @devs,$major."_$minor,$device";}}last;}}}}else { print "not supported yet, sorry\n"; }return @devs;}