diff options
author | etienne | 2016-05-19 11:05:22 +0000 |
---|---|---|
committer | etienne | 2016-05-19 11:05:22 +0000 |
commit | ba3628ea8da6c4d152da1c1784a3eea6b1e12566 (patch) | |
tree | 8159b999aae33a692dcde680c1ac7002f8fa9818 /src | |
parent | 7c0f57755fc633295363b320aa3b20c31b3654b9 (diff) | |
download | ivymon-ba3628ea8da6c4d152da1c1784a3eea6b1e12566.zip ivymon-ba3628ea8da6c4d152da1c1784a3eea6b1e12566.tar.gz ivymon-ba3628ea8da6c4d152da1c1784a3eea6b1e12566.tar.bz2 ivymon-ba3628ea8da6c4d152da1c1784a3eea6b1e12566.tar.xz |
* Default history size is restored to 200000 messages (previous value
was 60 minutes)
* Popup warning message when history size is reached.
Diffstat (limited to 'src')
-rwxr-xr-x | src/ivymon | 55 |
1 files changed, 43 insertions, 12 deletions
@@ -94,7 +94,7 @@ use Tk::CmdLine; use vars qw/$VERSION $opt_help $opt_b $opt_bus $opt_history @opt_bind $opt_verbose @opt_send $opt_size $opt_undersize $opt_out $opt_debug $opt_buf/; # **** VERSION **** -$VERSION = '1.25'; +$VERSION = '1.26'; # TODO a modifier # options initialisation # geometry @@ -104,10 +104,10 @@ my $smallsized = 0; my $coef = 1; my $ivy_port; # undef:=> default value is treated by ivy-perl -my $historynumber = 0; # history messages number +my $historynumber = 200000; # history messages number my $infinitehistory = 0; # set to 1 if infinite -my $historyduration = 60; # history duration in minutes -my $historylabel = "$historyduration minutes"; # history label +my $historyduration = undef; # history duration in minutes or undef +my $historylabel = &historylabel(); my $casesensitiveflag = 1; my $regexpflag = 0; @@ -186,6 +186,7 @@ my @bind_def; # Effective bindings array my @effectivebind; +my $historywarning = 0; #---------------------------------------------------------------------------------- # command line options management @@ -233,20 +234,17 @@ if ($opt_history) { if ($opt_history =~ /^(\d+)m$/) { my $m = $1; $m = 1 if $m == 0; - my $s = "s" if $m > 1; - $historylabel = "$m minute".$s; $historyduration = $m; } elsif ($opt_history =~ /^(\d+)$/) { $historynumber = $opt_history; - $historylabel = "$historynumber msgs"; $historyduration = undef; - } elsif ($opt_history eq "infinite") { + } elsif ($opt_history eq "infinite" or $opt_history eq "inf") { $infinitehistory = 1; - $historylabel = "all msgs"; } else { print "Bad value (=$opt_history) for -history option.\n"; exit 1; } + $historylabel = &historylabel(); } my $title; @@ -1568,6 +1566,7 @@ sub bufferizeMessage { $bufSize += length($message) if $opt_verbose; push(@databuffer, [$sender, $message, $time]); } else { + &historywarning() unless $historywarning; &increment_deleted(); } } # end bufferizeMessage @@ -1617,6 +1616,7 @@ sub updateMessagesFrame { # history size is taken in account here } elsif (defined $historyduration) { if ($runningtime_min >= $historyduration) { + &historywarning() unless $historywarning; &increment_deleted(1); $messageadded = 0; } else { @@ -1625,6 +1625,7 @@ sub updateMessagesFrame { } else { my $diff = $bufNumber + $displayedNumber - $historynumber + 1; # diff if message is added if ($diff > 0) { + &historywarning() unless $historywarning; &increment_deleted($diff); $messageadded = 0; } else { @@ -2495,7 +2496,7 @@ sub loadfileForDisplay { $status_lb->configure(-text => "History is set to infinite when file is loaded"); $infinitehistory = 1; - $historylabel = 'all'; + $historylabel = &historylabel(); $messagesMaxLabel->configure(-text => "Recordable : $historylabel"); # disable other buttons @@ -3020,6 +3021,36 @@ sub quit { } # end quit +sub historylabel { + + my $label; + if ($infinitehistory == 1) { + $label = "all msgs"; + } elsif ($historyduration > 0) { + my $s = "s" if $historyduration > 1; + $label = "$historyduration minute".$s; + } elsif ($historynumber > 0) { + $label = "$historynumber msgs"; + } + return $label + +} # end historylabel + +sub historywarning { + + return if $historywarning > 0; + $historywarning = 1; + use Tk::Dialog; + my $msg = "History size ($historylabel) reached.\nMessages recording stopped."; + my $diag = $mw->Dialog(-text => $msg, + -bitmap => "warning", + -title => "Warning!", + -buttons => ["OK"]); + $diag->Show(-popover => $mw, -popanchor => 'c'); + $diag->destroy(); + +} # end + __END__ @@ -3070,9 +3101,9 @@ Get some help. Bufferize received messages from the beginning. To display them in the 'Messages' window, you need to press the Scroll button. Use this option when ivymon is intended to receive very large flows of messages. -=item B<-history> size, minutes_number or infinite +=item B<-history> size, minutes_number or infinite|inf -Set the history size of kept messages (default: 200000). If size is integer, only the <size> first received messages will be kept. If size ends with 'm' character, only the messages received during the <size> first minutes will be kept. If size is set to 'infinite', ivymon will keep all messages. +Set the history size of kept messages (default: 200000). If size is integer, only the <size> first received messages will be kept. If size ends with 'm' character, only the messages received during the <size> first minutes will be kept. If size is set to 'infinite' or 'inf', ivymon will keep all messages. =item B<-size> window size |