jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [traffic/] [setup.pl] - Blame information for rev 17

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: setup.pl,v 1.13 2004/07/12 07:50:16 bernisys Exp $
4 
5# include PERL libraries
6use strict;
7use warnings;
8use diagnostics;
9 
10# include HotSaNIC libraries
11use lib "../../lib";
12use lib "./platform";
13use HotSaNICparser;
14use HotSaNICshellio;
15use HotSaNIClog;
16use common;
17 
18$|=1;
19 
20(my $VERSION = '$Revision: 1.13 $') =~ s/.*(\d+\.\d+).*/$1/;
21(my $IDENTIFIER = '$Id: setup.pl,v 1.13 2004/07/12 07:50:16 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;
22 
23my $MODNAME=HotSaNICparser::get_module_name();
24my %MODCONF=HotSaNICmod::common::configure();
25my $OUTFILE="settings.new";
26if ( ! -e "settings" ) { $OUTFILE="settings"; }
27open OUTFILE,">$OUTFILE" || die "could not open ".HotSaNICparser::get_module_name()." settings file for writing.\n";
28 
29if (! @{$MODCONF{DEV}}) { @{$MODCONF{DEV}}=get_interfaces(); }
30if (@{$MODCONF{DEV}}) { $MODCONF{DEV}="DEV=\"".join("\"\nDEV=\"",@{$MODCONF{DEV}})."\""; }
31else { $MODCONF{DEV}=""; }
32 
33print OUTFILE "# SHORT DESCRIPTION
34#
35# Which kind of legend shall be used
36# set GRAPH_BASE=\"bytes\" to display all values in bytes/s
37# set GRAPH_BASE=\"bits\" to display all values in bits/s
38#
39# This item was previously named \"STYLE\"
40#
41GRAPH_BASE=\"$MODCONF{GRAPH_BASE}\"
42 
43# Shall input and output traffic be swaped ?
44# (possible values meaning \"yes\" are: \"yes\" \"true\" \"1\")
45#
46SWAPIO=\"$MODCONF{SWAPIO}\"
47 
48# Configure graph layout
49#
50# GRAPH_MIN sets the lower border
51# GRAPH_MAX sets the upper border
52# GRAPH_RIGID defines wether the borders may be crossed or not
53#
54# if you want all graphs to be plotted from -200 up to 2000, no matter
55# wether the graph contains higher or lower values than configured, you
56# set the following:
57#
58# GRAPH_MIN=\"-200\"
59# GRAPH_MAX=\"2000\"
60# GRAPH_RIGID=\"true\"
61#
62# if you set GRAPH_RIGID=\"false\", the graphs will be automatically
63# scaled if higher / lower values have to be plotted.
64#
65# These three options were previously configured via the \"SCALE\" option
66#
67GRAPH_MIN=\"$MODCONF{GRAPH_MIN}\"
68GRAPH_MAX=\"$MODCONF{GRAPH_MAX}\"
69GRAPH_RIGID=\"$MODCONF{GRAPH_RIGID}\"
70 
71# Configure one line for each device that shall be sampled:
72#
73# DEV=<device>,<max bytes/s input>,<max bytes/s output>,<description>
74#
75# <device> is the network-device you like to sample
76#
77# for SNMP queries the <device> entry has the following format:
78#
79# SNMP:<host>:<community>:<interface>
80#
81# <host> is the name or the IP of the host you want to query
82#
83# <community> self explaining (for newbies: the community acts almost
84# like a \"password\" for SNMP)
85#
86# <interface> the name of the interface on the remote-host
87#
88# Examples:
89#
90# DEV=\"eth0,12500000,12500000,100 MBit ethernet\"
91# DEV=\"SNMP:192.168.1.1:public:eth0,12500000,12500000,100 MBit ethernet via SNMP\"
92# DEV=\"SNMP:cisco.my.net:public:Serial0/0,12500000,12500000,some line on a Cisco\"
93#
94$MODCONF{DEV}
95";
96close OUTFILE;
97 
98if ($OUTFILE eq "settings.new") {
99 HotSaNICparser::backup_file("settings");
100 rename "settings.new","settings";
101 }
102 
103print "Please check the settings file and adapt it to satisfy your needs.
104If you have any interfaces other than 100 MBit, please change the
105corrosponding default values.
106Maybe there are some additional interfaces or SNMP hosts you want
107to query.\n";
108 
109 
110sub get_interfaces {
111 my @devs=();
112 if (index($^O,"bsd") >=0) {
113 open OUTPUT,"ifconfig -l -u| fmt -1 |";
114 while (<OUTPUT>) {
115 chomp;
116 my $input=lc HotSaNICshellio::askyesno("Use $_?","n");
117 if ($input eq "y") { push @devs,"$_,12500000,12500000,100 MBit ethernet"; }
118 }
119 close OUTPUT;
120 }
121 else {
122 open LIST,"ifconfig|";
123 while (<LIST>) {
124 if (/^[^\s]/) {
125 (my $interface)=split;
126 my $input=lc HotSaNICshellio::askyesno("Use $interface?","n");
127 if ($input eq "y") { push @devs,"$interface,12500000,12500000,100 MBit ethernet"; }
128 }
129 }
130 }
131 return @devs;
132 }
133 

Powered by WebSVN 2.2.1