[freeside-commits] freeside/FS/FS/Cron check.pm,1.2.2.5,1.2.2.6
Ivan,,,
ivan at wavetail.420.am
Wed Sep 23 20:14:34 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS/Cron
In directory wavetail.420.am:/tmp/cvs-serv21908/FS/FS/Cron
Modified Files:
Tag: FREESIDE_1_7_BRANCH
check.pm
Log Message:
add SG and SGNG ping, RT#4610
Index: check.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Cron/check.pm,v
retrieving revision 1.2.2.5
retrieving revision 1.2.2.6
diff -u -d -r1.2.2.5 -r1.2.2.6
--- check.pm 22 Aug 2009 00:28:10 -0000 1.2.2.5
+++ check.pm 24 Sep 2009 03:14:32 -0000 1.2.2.6
@@ -13,6 +13,7 @@
@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 @@
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" );
More information about the freeside-commits
mailing list