jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [traffic/] [setup.pl] - Rev 3 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: setup.pl,v 1.13 2004/07/12 07:50:16 bernisys Exp $

# include PERL libraries
use strict;
use warnings;
use diagnostics;

# include HotSaNIC libraries
use lib "../../lib";
use lib "./platform";
use HotSaNICparser;
use HotSaNICshellio;
use HotSaNIClog;
use common;

$|=1;

(my $VERSION = '$Revision: 1.13 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: setup.pl,v 1.13 2004/07/12 07:50:16 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_interfaces(); }
if (@{$MODCONF{DEV}}) { $MODCONF{DEV}="DEV=\"".join("\"\nDEV=\"",@{$MODCONF{DEV}})."\""; }
else { $MODCONF{DEV}=""; }

print OUTFILE "# SHORT DESCRIPTION
#
# Which kind of legend shall be used
# set  GRAPH_BASE=\"bytes\"  to display all values in bytes/s
# set  GRAPH_BASE=\"bits\"   to display all values in bits/s
#
# This item was previously named \"STYLE\"
#
GRAPH_BASE=\"$MODCONF{GRAPH_BASE}\"

# Shall input and output traffic be swaped ?
# (possible values meaning \"yes\" are: \"yes\" \"true\" \"1\")
#
SWAPIO=\"$MODCONF{SWAPIO}\"

# Configure graph layout
#
# GRAPH_MIN sets the lower border
# GRAPH_MAX sets the upper border
# GRAPH_RIGID defines wether the borders may be crossed or not
#
# if you want all graphs to be plotted from -200 up to 2000, no matter
# wether the graph contains higher or lower values than configured, you
# set the following:
# 
# GRAPH_MIN=\"-200\"
# GRAPH_MAX=\"2000\"
# GRAPH_RIGID=\"true\"
#
# if you set GRAPH_RIGID=\"false\", the graphs will be automatically
# scaled if higher / lower values have to be plotted.
#
# These three options were previously configured via the \"SCALE\" option
#
GRAPH_MIN=\"$MODCONF{GRAPH_MIN}\"
GRAPH_MAX=\"$MODCONF{GRAPH_MAX}\"
GRAPH_RIGID=\"$MODCONF{GRAPH_RIGID}\"

# Configure one line for each device that shall be sampled:
#
# DEV=<device>,<max bytes/s input>,<max bytes/s output>,<description>
# 
# <device> is the network-device you like to sample
#
# for SNMP queries the <device> entry has the following format:
#
# SNMP:<host>:<community>:<interface>
#
# <host> is the name or the IP of the host you want to query
#
# <community> self explaining (for newbies: the community acts almost
#             like a \"password\" for SNMP)
#
# <interface> the name of the interface on the remote-host
#
# Examples:
#
# DEV=\"eth0,12500000,12500000,100 MBit ethernet\"
# DEV=\"SNMP:192.168.1.1:public:eth0,12500000,12500000,100 MBit ethernet via SNMP\"
# DEV=\"SNMP:cisco.my.net:public:Serial0/0,12500000,12500000,some line on a Cisco\"
#
$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.
If you have any interfaces other than 100 MBit, please change the
corrosponding default values.
Maybe there are some additional interfaces or SNMP hosts you want
to query.\n";


sub get_interfaces {
  my @devs=();
  if (index($^O,"bsd") >=0) {
    open OUTPUT,"ifconfig -l -u| fmt -1 |";
    while (<OUTPUT>) {
      chomp;
      my $input=lc HotSaNICshellio::askyesno("Use $_?","n");
      if ($input eq "y") { push @devs,"$_,12500000,12500000,100 MBit ethernet"; }
      }
    close OUTPUT;
    }
  else {
    open LIST,"ifconfig|";
    while (<LIST>) {
      if (/^[^\s]/) {
        (my $interface)=split;
        my $input=lc HotSaNICshellio::askyesno("Use $interface?","n");
        if ($input eq "y") { push @devs,"$interface,12500000,12500000,100 MBit ethernet"; }
        }
      }
    }
  return @devs;
  }


Powered by WebSVN 2.2.1