} );
}
+sub ping {
+ #my $p = shift;
+
+ return { 'pong' => '1' };
+
+}
+
#this might almost be general-purpose
sub decompify_pkgs {
my $p = shift;
@ISA = qw( Exporter );
@EXPORT_OK = qw(
check_queued check_selfservice check_apache check_bop_failures
+ check_sg check_sgng
alert error_msg
);
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" );
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
);
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);
'agent_info' => 'Agent/agent_info',
'agent_list_customers' => 'Agent/agent_list_customers',
#sg
+ 'ping' => 'SGNG/ping',
'decompify_pkgs' => 'SGNG/decompify_pkgs',
'previous_payment_info' => 'SGNG/previous_payment_info',
'previous_payment_info_renew_info'