summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/net_monitor
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/net_monitor')
-rwxr-xr-xperl-install/standalone/net_monitor92
1 files changed, 67 insertions, 25 deletions
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 8cf3ca160..8ed2523b7 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -39,12 +39,12 @@ my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel
$window1->signal_connect ( delete_event => sub { Gtk->exit(0); });
$window1->set_position(1);
$window1->set_title(_("Network Monitoring"));
-#$window1->set_policy(0, 0, 0);
+$window1->set_policy(1, 1, 1);
$window1->set_border_width(5);
-#$::isEmbedded or $window1->set_usize(600, 200);
+#$::isEmbedded or $window1->set_usize(580, 320);
my $colorr = my_gtk::gtkcolor(50400, 655, 20000);
-my $colort = my_gtk::gtkcolor(55400, 65400, 655);
+my $colort = my_gtk::gtkcolor(55400, 55400, 655);
my $colora = my_gtk::gtkcolor(655, 50400, 655);
my $isconnected=0;
my @interfaces;
@@ -93,12 +93,16 @@ gtkadd($window1,
),
0, gtksignal_connect(my $button_connect = new Gtk::Button(), clicked => \&connection),
0, new Gtk::HSeparator,
- 0, gtksignal_connect(my $button_close = new Gtk::Button(_("Close")), clicked => sub { Gtk->exit(0) })
+ 0, gtkpack(new Gtk::HBox(0,5),
+ gtksignal_connect(new Gtk::Button(_("Logs")), clicked => sub { system("/usr/sbin/logdrake --file /var/log/messages &") }),
+ gtksignal_connect(my $button_close = new Gtk::Button(_("Close")), clicked => sub { Gtk->exit(0) }),
+ )
)
),
0, my $statusbar = new Gtk::Statusbar
)
);
+$window1->show_all;
$window1->realize;
$combo1->entry->signal_connect( 'changed', sub {
network::netconnect::set_profile($netcnx, $combo1->entry->get_text());
@@ -121,10 +125,10 @@ $button_connect->add(gtkpack__(new Gtk::VBox(0,3),
$statusbar->push(1, _("Not connected"));
$window1->show_all();
#$window1->set_policy (1, 1, 1);
-update();
-my ($labelr, $labelt);
my $time_tag = Gtk->timeout_add(1000, \&rescan);
my $time_tag2 = Gtk->timeout_add(5000, \&update);
+update();
+
rescan();
connection() if ($connect && ! $isconnected);
Gtk->main;
@@ -189,7 +193,7 @@ sub rescan {
push(@{$monitor->{$intf}{stack_r}}, $recv - $refr);
shift @{$monitor->{$intf}{stack_r}} if @{$monitor->{$intf}{stack_r}} > 250;
- $labelr->set(formatXiB($recv - $monitor->{$intf}{initialr}));
+ $monitor->{$intf}{labelr}->set(formatXiB($recv - $monitor->{$intf}{initialr}));
$monitor->{$intf}{referencer} = $recv;
$monitor->{$intf}{transmita} += $transmit - $reft;
@@ -202,7 +206,7 @@ sub rescan {
push(@{$monitor->{$intf}{stack_t}}, $transmit - $reft);
shift @{$monitor->{$intf}{stack_t}} if @{$monitor->{$intf}{stack_t}} > 250;
- $labelt->set(formatXiB($transmit - $monitor->{$intf}{initialt}));
+ $monitor->{$intf}{labelt}->set(formatXiB($transmit - $monitor->{$intf}{initialt}));
$monitor->{$intf}{referencet} = $transmit;
draw_monitor($monitor->{$intf});
@@ -240,6 +244,32 @@ sub get_val {
@ret;
}
+sub change_color {
+ my ($color) = @_;
+ my $window = new Gtk::Window -toplevel;
+ my $doit;
+ $window->signal_connect ( delete_event => sub { Gtk->main_quit() });
+ $window->set_position(1);
+ $window->set_title(_("Color configuration"));
+ $window->set_border_width(5);
+ gtkadd(gtkset_modal($window,1),
+ gtkpack_(new Gtk::VBox(0,5),
+ 1, my $colorsel = new Gtk::ColorSelection,
+ 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -end),
+ gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { $doit=1; Gtk->main_quit() }),
+ gtksignal_connect(new Gtk::Button(_("Cancel")), clicked => sub { Gtk->main_quit() }),
+ )
+ )
+ );
+ $colorsel->set_color($color->red()/65535, $color->green()/65535, $color->blue()/65535, $color->pixel());
+ $window->show_all();
+ Gtk->main;
+ $window->destroy();
+ $doit or return $color;
+ my (@color) = $colorsel->get_color();
+ my_gtk::gtkcolor($color[0]*65535, $color[1]*65535, $color[2]*65535);
+}
+
sub update {
my @intfs = get_val();
if($combo1->entry->get_text ne ($netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default")) {
@@ -253,29 +283,41 @@ sub update {
$monitor->{$intf}{initialt} = $monitor->{$intf}{val}->[8];
$notebook->append_page(gtkshow(my $page = gtkpack_(new Gtk::VBox(0,0),
0, gtkpack__(gtkset_border_width(new Gtk::HBox(0,0), 5),
- gtksize(my $darea = $monitor->{$intf}{darea} = new Gtk::DrawingArea(),300, 150)),
+ gtksize($monitor->{$intf}{darea} = new Gtk::DrawingArea(),300, 150)),
+ 0, gtkpack__(gtkset_border_width(new Gtk::HBox(0,5), 5),
+ gtksignal_connect(my $button_t = new Gtk::Button(), clicked => sub {
+ $colort = change_color($colort);
+ $gct->set_foreground($colort);
+ $_[0]->draw(undef);
+ }),
+ _("sent: "), $monitor->{$intf}{labelt} = new Gtk::Label("0")),
0, gtkpack__(gtkset_border_width(new Gtk::HBox(0,5), 5),
- gtksize(my $dareat = new Gtk::DrawingArea(),15, 15),
- _("sent: "), $labelt = new Gtk::Label("0")),
+ gtksignal_connect(my $button_r = new Gtk::Button(), clicked => sub {
+ $colorr = change_color($colorr);
+ $gcr->set_foreground($colorr);
+ $_[0]->draw(undef);
+ }),
+ _("received: "), $monitor->{$intf}{labelr} = new Gtk::Label("0")),
0, gtkpack__(gtkset_border_width(new Gtk::HBox(0,5), 5),
- gtksize(my $darear = new Gtk::DrawingArea(),15, 15),
- _("received: "), $labelr = new Gtk::Label("0")),
- )),
+ gtksignal_connect(my $button_a = new Gtk::Button(), clicked => sub {
+ $colora = change_color($colora);
+ $gca->set_foreground($colora);
+ $_[0]->draw(undef);
+ }),
+ _("average"))
+ )),
new Gtk::Label($intf));
- $dareat->signal_connect( expose_event => sub {
- $dareat->window->draw_rectangle ($gct, 1, 0, 0, 15, 15);
- });
- $darear->signal_connect( expose_event => sub {
- $darear->window->draw_rectangle ($gcr, 1, 0, 0, 15, 15);
- });
+ foreach my $i ([$button_t, $gct],[$button_r, $gcr],[$button_a, $gca]) {
+ $i->[0]->add(gtksignal_connect(gtkshow(gtksize(gtkset_usize(new Gtk::DrawingArea(), 10, 10), 10, 10)), expose_event => sub{ $_[0]->window->draw_rectangle ($i->[1], 1, 0, 0, 10, 10)} ));
+ }
$notebook->set_page($notebook->page_num($page));
$monitor->{$intf}{page}=($notebook->page_num($page));
- $monitor->{$intf}{pixmap_db} = new Gtk::Gdk::Pixmap($darea->window, 300, 150);
+ $monitor->{$intf}{pixmap_db} = new Gtk::Gdk::Pixmap($monitor->{$intf}{darea}->window, 300, 150);
$monitor->{$intf}{referencer} = $monitor->{$intf}{val}->[0];
$monitor->{$intf}{referencet} = $monitor->{$intf}{val}->[8];
$monitor->{$intf}{pixmap_db}->draw_rectangle ($monitor->{$intf}{darea}->style->black_gc, 1, 0, 0, 300, 150);
- $darea->signal_connect( expose_event => sub {
- $darea->window->draw_pixmap ($darea->style->bg_gc('normal'),
+ $monitor->{$intf}{darea}->signal_connect( expose_event => sub {
+ $monitor->{$intf}{darea}->window->draw_pixmap ($monitor->{$intf}{darea}->style->bg_gc('normal'),
$monitor->{$intf}{pixmap_db}, 0, 0, 0, 0, 300, 150);
});
}
@@ -320,7 +362,7 @@ sub draw_monitor {
if($_ != -1) {
if( !defined $av1) { $av1 = $_ } else { defined $av2 or $av2 = $_ }
if ($av1 && $av2) {
- $o->{pixmap_db}->draw_line($gca, $step-10, $av1*150/$ech, $step, $av2*150/$ech);
+ $o->{pixmap_db}->draw_line($gca, $step-15, $av1*150/$ech, $step-5, $av2*150/$ech);
$av1 = $av2;
undef $av2;
$last_a = $step-50;
@@ -339,7 +381,7 @@ sub draw_monitor {
if($_ != -1) {
if(!defined $av1) { $av1 = $_ } else { defined $av2 or $av2 = $_ }
if ((defined $av1) && (defined $av2)) {
- $o->{pixmap_db}->draw_line($gca, $step-10, 151-$av1*150/$ech, $step, 151-$av2*150/$ech);
+ $o->{pixmap_db}->draw_line($gca, $step-15, 151-$av1*150/$ech, $step-5, 151-$av2*150/$ech);
$av1 = $av2;
undef $av2;
}