From 6225f98deaf8619ae008f1fd13b19801678a584e Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 19 Dec 2007 20:05:24 +0000 Subject: [PATCH] Fix disk space monitoring on MacOS, expand supported OS for modules --- fastrpc.cgi | 3 ++- mount/module.info | 1 + rpc.cgi | 3 ++- status/space-monitor.pl | 2 +- status/status-lib.pl | 4 ++-- web-lib-funcs.pl | 19 ++++++++++++------- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/fastrpc.cgi b/fastrpc.cgi index 517cf406a..d6b5b215d 100755 --- a/fastrpc.cgi +++ b/fastrpc.cgi @@ -93,7 +93,8 @@ while(1) { print STDERR "fastrpc: check $arg->{'module'}\n" if ($gconfig{'rpcdebug'}); $rawrv = &serialise_variable( { 'status' => 1, - 'rv' => &foreign_check($arg->{'module'}) } ); + 'rv' => &foreign_check($arg->{'module'}, undef, undef, + $arg->{'api'}) } ); } elsif ($arg->{'action'} eq 'config') { # Get the config for some module diff --git a/mount/module.info b/mount/module.info index b3b34aca1..11d417c89 100644 --- a/mount/module.info +++ b/mount/module.info @@ -10,6 +10,7 @@ desc_pt=Sistema de Ficheiros de Disco e Rede category=system desc_tr=Disk ve Að Dosya Sistemi os_support=slackware-linux redhat-linux mandrake-linux solaris debian-linux suse-linux united-linux freebsd hpux unixware open-linux turbo-linux corel-linux openbsd cobalt-linux lfs-linux msc-linux generic-linux gentoo-linux irix netbsd trustix-linux sol-linux coherent-linux openmamba-linux +api_os_support=macos desc=Disk and Network Filesystems desc_es=Sistemas de Archivo de Disco y Red desc_sv=Filsystem för diskar och nätverk diff --git a/rpc.cgi b/rpc.cgi index 4c67ddad9..f117f095e 100755 --- a/rpc.cgi +++ b/rpc.cgi @@ -116,7 +116,8 @@ elsif ($arg->{'action'} eq 'check') { # Check if some module is supported print &serialise_variable( { 'status' => 1, - 'rv' => &foreign_check($arg->{'module'}) } ); + 'rv' => &foreign_check($arg->{'module'}, undef, undef, + $arg->{'api'}) } ); } elsif ($arg->{'action'} eq 'config') { # Get the config for some module diff --git a/status/space-monitor.pl b/status/space-monitor.pl index c13c49f26..c9896f8c5 100644 --- a/status/space-monitor.pl +++ b/status/space-monitor.pl @@ -3,7 +3,7 @@ sub get_space_status { -return { 'up' => -1 } if (!&foreign_check("mount")); +return { 'up' => -1 } if (!&foreign_check("mount", 1)); &foreign_require("mount", "mount-lib.pl"); local $m; foreach $f (&mount::list_mounted()) { diff --git a/status/status-lib.pl b/status/status-lib.pl index fed14ca15..f3e6b9a65 100644 --- a/status/status-lib.pl +++ b/status/status-lib.pl @@ -219,7 +219,7 @@ return if ($_[0]->{'id'}); # only check for new services if ($_[0]->{'remote'}) { # Check on the remote server foreach $m (@_[1..$#_]) { - &remote_foreign_check($_[0]->{'remote'}, $m) || + &remote_foreign_check($_[0]->{'remote'}, $m, 1) || &error(&text('depends_remote', "$m", "$_[0]->{'remote'}")); } @@ -229,7 +229,7 @@ else { foreach $m (@_[1..$#_]) { local %minfo = &get_module_info($m); %minfo || &error(&text('depends_mod', "$m")); - &check_os_support(\%minfo) || + &check_os_support(\%minfo, undef, undef, 1) || &error(&text('depends_os', "$minfo{'desc'}")); } $_[0]->{'depends'} = join(" ", @_[1..$#_]); diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index ded209304..646ec0ff2 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -1347,12 +1347,16 @@ else { } } -# check_os_support(&minfo, [os-type, os-version]) +# check_os_support(&minfo, [os-type, os-version], [api-only]) # Returns 1 if some module is supported on the current operating system, or the # OS supplies as parameters. sub check_os_support { local $oss = $_[0]->{'os_support'}; +if ($_[3] && $oss && $_[0]->{'api_os_support'}) { + # May provide usable API + $oss .= " ".$_[0]->{'api_os_support'}; + } if ($_[0]->{'nozone'} && &running_in_zone()) { # Not supported in a Solaris Zone return 0; @@ -2073,14 +2077,15 @@ elsif (!$_[1] && $gconfig{'db_sizeuser'}) { return "\n"; } -# foreign_check(module) +# foreign_check(module, [api-only]) # Checks if some other module exists and is supported on this OS sub foreign_check { +local ($mod, $api) = @_; local %minfo; -local $mdir = &module_root_directory($_[0]); +local $mdir = &module_root_directory($mod); &read_file_cached("$mdir/module.info", \%minfo) || return 0; -return &check_os_support(\%minfo); +return &check_os_support(\%minfo, undef, undef, $api); } # foreign_exists(module) @@ -3594,7 +3599,6 @@ while(1) { last; } } -close(OUT); if (kill('TERM', $pid) && time() - $start >= $_[1]) { $timed_out = 1; } @@ -3926,12 +3930,13 @@ return &remote_rpc_call($_[0], { 'action' => 'call', 'args' => [ @_[3 .. $#_] ] } ); } -# remote_foreign_check(server, module) +# remote_foreign_check(server, module, [api-only]) # Checks if some module is installed and supported on a remote server sub remote_foreign_check { return &remote_rpc_call($_[0], { 'action' => 'check', - 'module' => $_[1] }); + 'module' => $_[1], + 'api' => $_[2] }); } # remote_foreign_config(server, module)