Skip to content

Commit

Permalink
clusterd: Remove special code for alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Jan 27, 2025
1 parent cacf391 commit 9570162
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions clusterd/clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ sub machine {
return $machine;
}

sub is_alpha {
return machine() eq 'alpha';
}

sub uptime {
open U,'<','/proc/uptime' or die "/proc/uptime: $!\n";
my $data;
Expand Down Expand Up @@ -345,7 +341,7 @@ package My::Select::INET ;
use Carp;
use IO::Socket::INET;

our $UDP_MAX = 1472; # for broadcast on alphas
our $UDP_MAX = 1472;

our $SOL_SOCKET=1;
our $SO_ERROR=4;
Expand Down Expand Up @@ -719,7 +715,7 @@ use Sys::Syslog;
use IO::Socket::INET;
use Data::Dumper;

our $UDP_MAX=1472; # for broadcast on alphas
our $UDP_MAX=1472;
our $UDP_PORT=234;
our $BC_RATE = 8; # packets per second broadcast
our $TCP_TIMEOUT=30; # default timeout for tcp processing
Expand Down Expand Up @@ -1012,9 +1008,6 @@ if ($machine eq 'i686') {
$UTIME_OMIT=(1<<30)-2; # /usr/include/bits/stat.h
$AT_SYMLINK_NOFOLLOW=0x100; # /usr/include/fcntl.h
$lmtime_sub=\&lmtime_utimensat;
} elsif ($machine eq 'alpha') {
$SYS_lchown=208; # SYS_lchown in /usr/include/syscall.h
$SYS_mknod=14; # SYS_mknod
} elsif ($machine eq 'amd64') {
$SYS_lchown=254; # SYS_lchown in /usr/include/syscall.h
$SYS_mknod=14; # SYS_mknod
Expand Down Expand Up @@ -1198,33 +1191,24 @@ sub sample_rproc { # every 5 seconds
our ($CPUS,$BOGOMIPS);

sub init_cpuinfo {
Donald::Tools::is_alpha and return;
open L,'<','/proc/cpuinfo' or return;
while (<L>) {
if (/^bogomips\s*:\s*([\d.]+)/) {$CPUS++;$BOGOMIPS+=$1;}
}
}

sub loadavg { # AXP : (system load average) , LINUX: (system load average, pload, freebogo)
if (Donald::Tools::is_alpha) {
my $data=pack 'l!3lx4l!3';
my $i=syscall(85,3,0,$data,1,length($data)); # table(id=TBL_LOADAVG,index=0,addr=data,nel=1,lel=56)
my ($l0,$l1,$l2,$scale,$mach0,$mach1,$mach2)=unpack 'l!3lx4l!3',$data;
$scale or return undef;
return $l0/$scale;
$CPUS or init_cpuinfo();
my $running_proc=running_proc();
open L,'<','/proc/loadavg' or return undef;
my $data;
sysread(L,$data,1024);
close L;
$data =~ /^(\d+\.?\d*)/ or return undef; # 5 min loadavg
if ($CPUS) {
return ($1+0,($running_proc)/$CPUS,($running_proc>=$CPUS?0:($CPUS-$running_proc)*$BOGOMIPS));
} else {
$CPUS or init_cpuinfo();
my $running_proc=running_proc();
open L,'<','/proc/loadavg' or return undef;
my $data;
sysread(L,$data,1024);
close L;
$data =~ /^(\d+\.?\d*)/ or return undef; # 5 min loadavg
if ($CPUS) {
return ($1+0,($running_proc)/$CPUS,($running_proc>=$CPUS?0:($CPUS-$running_proc)*$BOGOMIPS));
} else {
return $1+0;
}
return $1+0;
}
}

Expand Down Expand Up @@ -2081,7 +2065,7 @@ if (defined $options{'push'}) {

My::Select::timeout(60,\&purge_old_receiver);
My::Select::timeout(rand(60),\&send_stat);
My::Select::timeout(0,\&sample_rproc) unless Donald::Tools::is_alpha;
My::Select::timeout(0,\&sample_rproc);
$my_hostname eq $STAT_TARGET and My::Cluster::Updown::init();
$my_hostname eq 'macheteinfach' and My::NetlogReceiver::init();
My::Select::timeout(600,\&check_overload);
Expand Down

0 comments on commit 9570162

Please sign in to comment.