2 # a program to monitor outside systems
7 use Net::SSH qw( sshopen2 ); #sshopen3 );
8 use FS::Record qw( qsearchs );
10 use FS::cust_svc_option;
12 our @EXPORT_OK = qw( tron_scan tron_lint);
15 #lenient for now, so we can fix up important stuff
16 'freeside_version' => qr/^1\.(7\.3|9\.0)/,
17 'debian_version' => qr/^4/,
18 'apache_mpm' => qw/^(Prefork|$)/,
20 #payment gateway survey
21 # 'payment_gateway' => qw/^authorizenet$/,
23 #stuff to add/replace later
24 #'pg_version' => qr/^8\.[1-9]/,
25 #'apache_version' => qr/^2/,
26 #'apache_mpm' => qw/^Prefork/,
33 if ( ref($cust_svc) ) {
34 $svc_external = $cust_svc->svc_x;
36 $svc_external = qsearchs('svc_external', { 'svcnum' => $cust_svc } );
37 $cust_svc = $svc_external->cust_svc;
40 #don't scan again if things are okay
42 foreach my $option ( keys %desired ) {
43 my $current = $cust_svc->option($option);
44 $bad++ unless $current =~ $desired{$option};
46 return '' unless $bad;
50 my $machine = $svc_external->title; # or better as a cust_svc_option??
51 sshopen2($machine, *READER, *WRITER, '/usr/local/bin/freeside-yori all');
54 my($option, $value) = split(/: ?/);
55 next unless defined($option) && exists($desired{$option});
56 $hash{$option} = $value;
61 unless ( keys %hash ) {
62 return "error scanning $machine\n";
66 foreach my $option ( keys %hash ) {
67 my %opthash = ( 'optionname' => $option,
68 'svcnum' => $cust_svc->svcnum,
70 my $cust_svc_option = qsearchs('cust_svc_option', \%opthash )
71 || new FS::cust_svc_option \%opthash;
72 next if $cust_svc_option->optionvalue eq $hash{$option};
73 $cust_svc_option->optionvalue( $hash{$option} );
74 my $error = $cust_svc_option->optionnum
75 ? $cust_svc_option->replace
76 : $cust_svc_option->insert;
77 return $error if $error;
88 foreach my $option ( keys %desired ) {
89 my $current = $cust_svc->option($option);
90 push @lint, "$option is $current" unless $current =~ $desired{$option};
93 push @lint, 'unchecked' unless scalar($cust_svc->options);