1 <& /elements/header.html, 'System Status' &>
3 <& /elements/init_overlib.html &>
5 % foreach my $section ( keys %status ) {
6 <FONT CLASS="fsinnerbox-title"><% mt($section) |h %></FONT>
7 <TABLE CLASS="fsinnerbox">
8 % foreach my $item ( @{ $status{$section} } ) {
10 <TD ALIGN="right"><% $item->{title} %></TH>
11 <TD><B><% $item->{value} %></B></TD>
18 <& /elements/footer.html &>
26 -e '/usr/bin/lsb_release' and run( ['lsb_release', '-d'], '>',\$os );
27 if ( ! $@ && $os =~ /^\s*Description:\s*(.+)$/ ) {
29 } elsif ( my $deb_version = slurp('/etc/debian_version') ) {
30 $os = "Debian $deb_version";
33 ( my $perl_ver = $^V ) =~ s/^v//;
36 $db = 'PostgreSQL' if $db =~ /^Pg/;
37 $db = 'MySQL/MariaDB' if $db =~ /^mysql/;
39 my $db_ver = FS::Record->scalar_sql('SELECT VERSION()');
40 if ( $db eq 'PostgreSQL' && $db_ver =~ /^\s*PostgreSQL\s+([\w\.]+)\s+on\s+/ ) {
44 my $db_size = 'Unknown';
45 if ( $db eq 'PostgreSQL' ) {
46 $db_size = FS::Record->scalar_sql(qq(
47 SELECT pg_size_pretty(pg_database_size('freeside'))
49 include('/elements/popup_link.html',
50 'action' => 'Status-db_size_detail.html',
51 'label' => '(details)',
52 'actionlabel' => 'Database size details',
56 tie my %status, 'Tie::IxHash',
58 { 'title' => 'Freeside version',
59 'value' => $FS::VERSION,
61 { 'title' => 'Operating System',
64 { 'title' => 'Perl version',
67 { 'title' => 'Database engine',
70 { 'title' => 'Database version',
73 { 'title' => 'Database size',
77 'Required Daemons' => [
78 { 'title' => 'Queue daemon',
79 'value' => _is_running('queued') ? 'Running' : 'Not running',
82 'Optional Daemons' => [
83 { 'title' => 'Self-service server(s)',
84 'value' => '(Not checked)', #XXX multiple pid files, per machine etc
86 { 'title' => 'Self-service XML-RPC server',
87 'value' => _is_running('selfservice-xmlrpcd') ? 'Running' : 'Not running',
89 { 'title' => 'Back office XML-RPC server',
90 'value' => _is_running('xmlrpcd') ? 'Running' : 'Not running',
92 { 'title' => 'RADIUS accounting import daemon',
93 'value' => _is_running('sqlradius-radacctd') ? 'Running' : 'Not running',
95 { 'title' => 'Prepaid daemon',
96 'value' => _is_running('prepaidd') ? 'Running' : 'Not running',
98 { 'title' => 'CDR Rewrite daemon',
99 'value' => _is_running('cdrrewrited') ? 'Running' : 'Not running',
101 { 'title' => 'CDR Prepaid daemon',
102 'value' => _is_running('cdrd') ? 'Running' : 'Not running',
104 { 'title' => 'CDR Real-time rating daemon',
105 'value' => _is_running('cdrrated') ? 'Running' : 'Not running',
107 #{ 'title' => 'Network monitoring port combiner', #?
108 # 'value' => _is_running('torrus-srvderive') ? 'Running' : 'Not running',
118 if ( $db eq 'PostgreSQL' ) {
120 my $enabled = FS::Record->scalar_sql('SHOW wal_level') eq 'hot_standby'
121 && FS::Record->scalar_sql('SHOW archive_mode') eq 'on';
124 FS::Record->scalar_sql('SHOW archive_command') =~ / postgres\@([\w\.\-]+): /
127 $status{'Replication'} = [
128 { 'title' => 'Status', #?
129 'value' => $enabled ? 'Enabled' : 'Disabled',
134 push @{ $status{'Replication'} },
135 { 'title' => 'Slave',
136 'value' => $slave || '(Missing, or unparseable archive_command)',
140 #how far behind is it? will be easier once we're off 9.1
141 # http://www.keithf4.com/monitoring_streaming_slave_lag/
142 # except pg_stat_replication still doesn't fill in the columns we need as
144 push @{ $status{'Replication'} },
145 { 'title' => 'Slave',
146 'value' => $slave || '(Missing, or unparseable archive_command)',
154 $status{'Replication'} = [
155 { 'title' => 'Enabled',
156 'value' => "(Not yet checked on $db)",
167 if ( _is_running('cdrd') ) {
169 my $delay = FS::Record->scalar_sql('
170 SELECT AVG(end_date-insert_date)
173 ORDER BY statnum DESC
177 my $h = int($delay/3600);
178 my $m = int( ($delay%3600) / 60 );
181 $delay = ( $h ? $h. 'h' : '' ).
182 ( $h||$m ? $m. 'm' : '').
187 my $pr_delay = FS::Record->scalar_sql('
188 SELECT AVG(end_date-start_date)
191 ORDER BY statnum DESC
195 my $h = int($delay/3600);
196 my $m = int( ($delay%3600) / 60 );
199 $pr_delay = ( $h ? $h. 'h' : '' ).
200 ( $h||$m ? $m. 'm' : '').
205 my $dayago = time2str('%Y-%m-%d %X', time - 86400);
206 my $cdrs = FS::Record->scalar_sql(qq{
207 SELECT COUNT(*) FROM cdr
208 WHERE ( freesidestatus IS NULL OR freesidestatus = '' )
209 AND calldate > '$dayago'
212 $status{'CDR Processing'} = [
213 { 'title' => 'Current processing delay',
216 { 'title' => 'Average billing time',
217 'value' => $pr_delay,
219 { 'title' => 'Unprocessed CDRs (last 24 hours)',
231 my($store, $tokenize) = (0,0);
235 'hashref' => { 'disabled' => '', },
236 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
239 my $gateway = $agent->payment_gateway('method'=>'VISA card', 'nofatal'=>1, );
241 && $gateway->gateway_namespace eq 'Business::OnlinePayment';
242 eval "use Business::OnlinePayment";
244 my $bop = new Business::OnlinePayment( $gateway->gateway_module,
247 : @{ $gateway->get('options') }
249 my %actions = $bop->info('supported_actions');
250 if ( $actions{'CC'} && grep /^Tokenize$/, @{$actions{'CC'}} ) {
258 if ( $tokenize && ! $store ) {
260 $status{'PCI Compliance'} = [
261 { 'title' => 'Tokenization',
262 'value' => 'Enabled',
264 { 'title' => 'SAQ type',
265 'value' => 'A / A-EP',
271 my $conf = new FS::Conf; #wow, didn't need this before?
273 $status{'PCI Compliance'} = [
274 { 'title' => 'Tokenization',
275 'value' => $tokenize ? 'Partialy enabled (some agents)' : 'Disabled'
277 { 'title' => 'Encryption',
279 ( $conf->exists('encryption') && $conf->config('encryptionpublickey')
280 ? 'Enabled' : 'Disabled'
283 { 'title' => 'SAQ type',
284 'value' => 'D (enable tokenization for A / A-EP)',
297 my $pid_path = '/var/run'; #XXX hardcoded path
300 -e "$pid_path/freeside/$thing.pid" ? "$pid_path/freeside/$thing.pid" :
301 -e "$pid_path/freeside-$thing.pid" ? "$pid_path/freeside-$thing.pid" :
304 -e $pidfile and kill 0, slurp($pidfile)