summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-09-24 03:14:27 +0000
committerivan <ivan>2009-09-24 03:14:27 +0000
commit25cf511573ebff303700ce71611450ad72debcbc (patch)
treec5f93b8ac660892eff2264d6615788afd9049c36
parent345710417c36b3521bc44def48e1a85ece4ae4df (diff)
add SG and SGNG ping, RT#4610
-rw-r--r--FS/FS/ClientAPI/SGNG.pm7
-rw-r--r--FS/FS/Cron/check.pm49
-rw-r--r--FS/bin/freeside-check9
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm1
4 files changed, 64 insertions, 2 deletions
diff --git a/FS/FS/ClientAPI/SGNG.pm b/FS/FS/ClientAPI/SGNG.pm
index 872148a..7f784dc 100644
--- a/FS/FS/ClientAPI/SGNG.pm
+++ b/FS/FS/ClientAPI/SGNG.pm
@@ -20,6 +20,13 @@ sub _cache {
} );
}
+sub ping {
+ #my $p = shift;
+
+ return { 'pong' => '1' };
+
+}
+
#this might almost be general-purpose
sub decompify_pkgs {
my $p = shift;
diff --git a/FS/FS/Cron/check.pm b/FS/FS/Cron/check.pm
index c4e712c..b331014 100644
--- a/FS/FS/Cron/check.pm
+++ b/FS/FS/Cron/check.pm
@@ -13,6 +13,7 @@ use FS::cust_pay_pending;
@ISA = qw( Exporter );
@EXPORT_OK = qw(
check_queued check_selfservice check_apache check_bop_failures
+ check_sg check_sgng
alert error_msg
);
@@ -44,6 +45,54 @@ sub check_selfservice {
return 1;
}
+sub check_sg {
+ my $conf = new FS::Conf;
+ return 1 unless $conf->exists('sg-multicustomer_hack');
+
+ my $ua = new LWP::UserAgent;
+ $ua->agent("FreesideCronCheck/0.1 " . $ua->agent);
+
+ #XXX shiiiiit.
+ my $USER = '';
+ my $PASS = '';
+ my $req = new HTTP::Request GET=>"https://$USER:$PASS\@localhost/sg/ping.cgi";
+ my $res = $ua->request($req);
+
+ return 1 if $res->is_success
+ && $res->content =~ /OK/;
+
+ $error_msg = $res->is_success ? $res->content : Rres->status_line;
+ return 0;
+
+}
+
+sub check_sgng {
+ my $conf = new FS::Conf;
+ return 1 unless $conf->exists('sg-multicustomer_hack');
+
+ eval 'use RPC::XML; use RPC::XML::Client;';
+ if ($@) { $error_msg = $@; return 0; };
+
+ my $cli = RPC::XML::Client->new('https://localhost/selfservice/xmlrpc.cgi');
+ my $resp = $cli->send_request('FS.SelfService.XMLRPC.ping');
+
+ return 1 if ref($resp)
+ && ! $resp->is_fault
+ && ref($resp->value)
+ && $resp->value->{'pong'} == 1;
+
+ #hua
+ $error_msg = ref($resp)
+ ? ( $resp->is_fault
+ ? $resp->string
+ : ( ref($resp->value) ? $resp->value->{'error'}
+ : $resp->value
+ )
+ )
+ : $resp;
+ return 0;
+}
+
sub _check_fsproc {
my $arg = shift;
_check_pidfile( "freeside-$arg.pid" );
diff --git a/FS/bin/freeside-check b/FS/bin/freeside-check
index f2d596b..ac2fc3d 100644
--- a/FS/bin/freeside-check
+++ b/FS/bin/freeside-check
@@ -6,6 +6,7 @@ use Email::Send;
use FS::UID qw( adminsuidsetup );
use FS::Cron::check qw(
check_queued check_selfservice check_apache check_bop_failures
+ check_sg check_sgng
alert error_msg
);
@@ -17,9 +18,13 @@ eval { adminsuidsetup $user };
if ( $@ ) { alert("Database down: $@", @emails); exit; }
-check_queued or alert("Queue daemon not running", @emails);
+check_queued or alert('Queue daemon not running', @emails);
check_selfservice or alert(error_msg(), @emails);
-check_apache or alert("Apache not running: ". error_msg(), @emails);
+check_apache or alert('Apache not running: '. error_msg(), @emails);
+
+#no-ops unless you are sg
+check_sg or alert('FS::ClientAPI::SG not responding', @emails);
+check_sgng or alert('FS::ClientAPI::SGNG not responding', @emails);
check_bop_failures or alert(error_msg(), @emails);
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 4173e28..49629d4 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -76,6 +76,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
'bulk_processrow' => 'Bulk/processrow',
'check_username' => 'Bulk/check_username',
#sg
+ 'ping' => 'SGNG/ping',
'decompify_pkgs' => 'SGNG/decompify_pkgs',
'previous_payment_info' => 'SGNG/previous_payment_info',
'previous_payment_info_renew_info'