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 #stuff to add/replace later
21 #'pg_version' => qr/^8\.[1-9]/,
22 #'apache_version' => qr/^2/,
23 #'apache_mpm' => qw/^Prefork/,
30 if ( ref($cust_svc) ) {
31 $svc_external = $cust_svc->svc_x;
33 $svc_external = qsearchs('svc_external', { 'svcnum' => $cust_svc } );
34 $cust_svc = $svc_external->cust_svc;
37 #don't scan again if things are okay
39 foreach my $option ( keys %desired ) {
40 my $current = $cust_svc->option($option);
41 $bad++ unless $current =~ $desired{$option};
43 return '' unless $bad;
47 my $machine = $svc_external->title; # or better as a cust_svc_option??
48 sshopen2($machine, *READER, *WRITER, '/usr/local/bin/freeside-yori all');
51 my($option, $value) = split(/: ?/);
52 next unless defined($option) && exists($desired{$option});
53 $hash{$option} = $value;
57 unless ( keys %hash ) {
58 return "error scanning $machine\n";
62 foreach my $option ( keys %hash ) {
63 my %opthash = ( 'optionname' => $option,
64 'svcnum' => $cust_svc->svcnum,
66 my $cust_svc_option = qsearchs('cust_svc_option', \%opthash )
67 || new FS::cust_svc_option \%opthash;
68 next if $cust_svc_option->optionvalue eq $hash{$option};
69 $cust_svc_option->optionvalue( $hash{$option} );
70 my $error = $cust_svc_option->optionnum
71 ? $cust_svc_option->replace
72 : $cust_svc_option->insert;
73 return $error if $error;
84 foreach my $option ( keys %desired ) {
85 my $current = $cust_svc->option($option);
86 push @lint, "$option is $current" unless $current =~ $desired{$option};