5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my ($dummy,$wu1,$wu2,$bgcolor,$status,$pid);
my $seti = '/home/fs/setiathome/';
&getvalues;
my $mw = MainWindow->new;
my $tk_wu1 = $mw->Label( -textvariable => \$wu1 );
my $tk_wu2 = $mw->Label( -textvariable => \$wu2 );
my $tk_status = $mw->Label( -foreground => "$bgcolor", -textvariable => \$status );
$tk_wu1->pack( );
$tk_wu2->pack( );
$tk_status->pack( );
$mw->repeat( 120000, \&refresh );
$mw->MainLoop( );
exit( 0 );
sub getvalues {
open( STAT, '<', $seti.'user_info.sah' ) or die "!user_info.sah";
while( <STAT> ) {
chomp;
if( /^nresults=.{3,4}/ ) {
($dummy,$wu1) = split( /\=/, $_ );
$wu1 = "WU's $wu1";
}
}
close STAT;
open( STAT2, '<', $seti.'state.sah' ) or die "!state.sah";
while( <STAT2> ) {
chomp;
if( /^prog=.*/ ) {
($dummy,$wu2) = split( /\=/, $_ );
$wu2 = $wu2 * 100;
$wu2 = sprintf( "%.1f", $wu2 );
$wu2 = "WU $wu2\%";
}
}
close STAT2;
$bgcolor = 'darkred';
$status = 'offline';
open( PID, '<', $seti.'pid.sah' ) or die "pid.sah";
while( <PID> ) {
chomp;
$pid = $_;
}
if( -e '/proc/'.$pid.'/stat' ) {
open( STATUS, '<', '/proc/'.$pid.'/stat' ) or die "!/proc/$pid/stat";
while( <STATUS> ) {
chomp;
if( /\(setiathome\)/ ) {
$bgcolor = 'darkgreen';
$status = 'online';
}
}
close STATUS;
}
}
sub refresh {
&getvalues;
$mw->update;
}
5 Einträge, 1 Seite |