summaryrefslogtreecommitdiff
path: root/loadbars.pl
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2011-08-05 20:02:32 +0000
committerPaul Buetow <paul@buetow.org>2011-08-05 20:02:32 +0000
commit0d99786d145574323ee8559b2f5ee49dcc4a23ce (patch)
tree365b687b6fcab1e70995e716076b6606a03b5d82 /loadbars.pl
parent90cae195f07768fb76fabd545b293c8d395dd921 (diff)
Adding SIGKILL if ssh does not terminate
Diffstat (limited to 'loadbars.pl')
-rwxr-xr-xloadbars.pl25
1 files changed, 22 insertions, 3 deletions
diff --git a/loadbars.pl b/loadbars.pl
index cfbd0b6..3df9fcf 100755
--- a/loadbars.pl
+++ b/loadbars.pl
@@ -70,6 +70,9 @@ use constant {
USER_RED => 90,
USER_ORANGE => 70,
USER_YELLOW0 => 50,
+
+ # For developing or other debugging purporses
+ DEBUG => 1,
};
$| = 1;
@@ -94,6 +97,7 @@ my $MSG :shared;
);
sub say (@) { print "$_\n" for @_; return undef }
+sub newline () { say ''; return undef }
sub debugsay (@) { say "DEBUG: $_" for @_; return undef }
sub sum (@) {
@@ -142,10 +146,24 @@ BASH
};
$SIG{STOP} = sub {
- say "Shutting down get_stat($host) & PID $pid";
+ print "Shutting down get_stat($host) & PID $pid";
kill 1, $pid;
close $pipe;
+
$sigstop = 1;
+
+ my $killcounter = 0;
+ while (kill 0, $pid) {
+ ++$killcounter;
+ print '.';
+
+ if ($killcounter >= 3) {
+ print " forcing using SIGKILL";
+ kill 0, $pid;
+ }
+ }
+
+ newline;
};
# Toggle CPUs
@@ -240,9 +258,8 @@ sub thr_display_stats () {
-resizeable => 0,
);
- wait_for_stats;
-
SDL::Font->new('font.png')->use();
+ wait_for_stats;
my $num_stats = keys %CPUSTATS;
my $factor = $CONF{factor};
@@ -300,6 +317,7 @@ sub thr_display_stats () {
my %stat = map {
my ($k, $v) = split '='; $k => $v
+
} split ';', $CPUSTATS{$key};
unless (exists $prev_stats{$key}) {
@@ -323,6 +341,7 @@ sub thr_display_stats () {
my %heights = map {
$_ => defined $cpuaverage{$_} ? $cpuaverage{$_} * ($CONF{height}/100) : 1
+
} keys %cpuaverage;
my $rect_user = get_rect $rects, "$key;user";