diff options
author | ivan <ivan> | 2009-09-24 03:14:27 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-09-24 03:14:27 +0000 |
commit | 25cf511573ebff303700ce71611450ad72debcbc (patch) | |
tree | c5f93b8ac660892eff2264d6615788afd9049c36 /FS/FS | |
parent | 345710417c36b3521bc44def48e1a85ece4ae4df (diff) |
add SG and SGNG ping, RT#4610
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/ClientAPI/SGNG.pm | 7 | ||||
-rw-r--r-- | FS/FS/Cron/check.pm | 49 |
2 files changed, 56 insertions, 0 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" ); |