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_ping tron_scan tron_lint);
15 #less lenient, we need to make sure we upgrade deb 4 & pg 7.4
16 'freeside_version' => qr/^1\.(7\.3|9\.0)/,
17 'debian_version' => qr/^5/, #qr/^5.0.[2-9]$/ #qr/^4/,
18 'apache_mpm' => qw/^(Prefork|$)/,
19 'pg_version' => qr/^8\.[1-9]/,
20 'apache_version' => qr/^2/,
22 #payment gateway survey
23 # 'payment_gateway' => qw/^authorizenet$/,
25 #stuff to add/replace later
26 #'apache_mpm' => qw/^Prefork/,
27 #'pg_version' => qr/^8\.[3-9]/,
30 sub _cust_svc_external {
31 my $cust_svc_or_svcnum = shift;
33 my ( $cust_svc, $svc_external );
34 if ( ref($cust_svc_or_svcnum) ) {
35 $cust_svc = $cust_svc_or_svcnum;
36 $svc_external = $cust_svc->svc_x;
38 $svc_external = qsearchs('svc_external', { svcnum=>$cust_svc_or_svcnum } );
39 $cust_svc = $svc_external->cust_svc;
42 ( $cust_svc, $svc_external );
47 my( $cust_svc, $svc_external ) = _cust_svc_external(shift);
50 my $machine = $svc_external->title; # or better as a cust_svc_option??
51 sshopen2($machine, *READER, *WRITER, '/bin/echo pong');
52 my $pong = scalar(<READER>);
60 my( $cust_svc, $svc_external ) = _cust_svc_external(shift);
62 #don't scan again if things are okay
64 foreach my $option ( keys %desired ) {
65 my $current = $cust_svc->option($option);
66 $bad++ unless $current =~ $desired{$option};
68 return '' unless $bad;
72 my $machine = $svc_external->title; # or better as a cust_svc_option??
73 #sshopen2($machine, *READER, *WRITER, '/usr/local/bin/freeside-yori all');
74 #fix freeside users' patch if necessary, since packages put this in /usr/bin
75 sshopen2($machine, *READER, *WRITER, 'freeside-yori all');
78 my($option, $value) = split(/: ?/);
79 next unless defined($option) && exists($desired{$option});
80 $hash{$option} = $value;
85 unless ( keys %hash ) {
86 return "error scanning $machine\n";
90 foreach my $option ( keys %hash ) {
91 my %opthash = ( 'optionname' => $option,
92 'svcnum' => $cust_svc->svcnum,
94 my $cust_svc_option = qsearchs('cust_svc_option', \%opthash )
95 || new FS::cust_svc_option \%opthash;
96 next if $cust_svc_option->optionvalue eq $hash{$option};
97 $cust_svc_option->optionvalue( $hash{$option} );
98 my $error = $cust_svc_option->optionnum
99 ? $cust_svc_option->replace
100 : $cust_svc_option->insert;
101 return $error if $error;
109 my $cust_svc = shift;
112 foreach my $option ( keys %desired ) {
113 my $current = $cust_svc->option($option);
114 push @lint, "$option is $current" unless $current =~ $desired{$option};
117 push @lint, 'unchecked' unless scalar($cust_svc->options);