1 <& /elements/header.html, 'System Status' &>
2 % foreach my $section ( keys %status ) {
3 <FONT CLASS="fsinnerbox-title"><% mt($section) |h %></FONT>
4 <TABLE CLASS="fsinnerbox">
5 % foreach my $item ( @{ $status{$section} } ) {
7 <TD ALIGN="right"><% $item->{title} %></TH>
8 <TD><B><% $item->{value} %></B></TD>
14 <& /elements/footer.html &>
22 -e '/usr/bin/lsb_release' and run( ['lsb_release', '-d'], '>',\$os );
23 if ( ! $@ && $os =~ /^\s*Description:\s*(.+)$/ ) {
25 } elsif ( my $deb_version = slurp('/etc/debian_version') ) {
26 $os = "Debian $deb_version";
29 ( my $perl_ver = $^V ) =~ s/^v//;
32 $db = 'PostgreSQL' if $db =~ /^Pg/;
33 $db = 'MySQL/MariaDB' if $db =~ /^mysql/;
35 my $db_ver = FS::Record->scalar_sql('SELECT VERSION()');
36 if ( $db eq 'PostgreSQL' && $db_ver =~ /^\s*PostgreSQL\s+([\w\.]+)\s+on\s+/ ) {
40 my $db_size = 'Unknown';
41 if ( $db eq 'PostgreSQL' ) {
42 $db_size = FS::Record->scalar_sql(qq(
43 SELECT pg_size_pretty(pg_database_size('freeside'))
47 tie my %status, 'Tie::IxHash',
49 { 'title' => 'Freeside version',
50 'value' => $FS::VERSION,
52 { 'title' => 'Operating System',
55 { 'title' => 'Perl version',
58 { 'title' => 'Database engine',
61 { 'title' => 'Database version',
64 { 'title' => 'Database size',
68 'Required Daemons' => [
69 { 'title' => 'Queue daemon',
70 'value' => _is_running('queued') ? 'Running' : 'Not running',
73 'Optional Daemons' => [
74 { 'title' => 'Self-service server(s)',
75 'value' => '(Not checked)', #XXX multiple pid files, per machine etc
77 { 'title' => 'Self-service XML-RPC server',
78 'value' => _is_running('selfservice-xmlrpcd') ? 'Running' : 'Not running',
80 { 'title' => 'Back office XML-RPC server',
81 'value' => _is_running('xmlrpcd') ? 'Running' : 'Not running',
83 { 'title' => 'RADIUS accounting import daemon',
84 'value' => _is_running('sqlradius-radacctd') ? 'Running' : 'Not running',
86 { 'title' => 'Prepaid daemon',
87 'value' => _is_running('prepaidd') ? 'Running' : 'Not running',
89 { 'title' => 'CDR Rewrite daemon',
90 'value' => _is_running('cdrrewrited') ? 'Running' : 'Not running',
92 { 'title' => 'CDR Prepaid daemon',
93 'value' => _is_running('cdrd') ? 'Running' : 'Not running',
95 { 'title' => 'CDR Real-time rating daemon',
96 'value' => _is_running('cdrrated') ? 'Running' : 'Not running',
98 #{ 'title' => 'Network monitoring port combiner', #?
99 # 'value' => _is_running('torrus-srvderive') ? 'Running' : 'Not running',
109 if ( $db eq 'PostgreSQL' ) {
111 my $enabled = FS::Record->scalar_sql('SHOW wal_level') eq 'hot_standby'
112 && FS::Record->scalar_sql('SHOW archive_mode') eq 'on';
115 FS::Record->scalar_sql('SHOW archive_command') =~ / postgres\@([\w\.\-]+): /
118 $status{'Replication'} = [
119 { 'title' => 'Status', #?
120 'value' => $enabled ? 'Enabled' : 'Disabled',
125 push @{ $status{'Replication'} },
126 { 'title' => 'Slave',
127 'value' => $slave || '(Missing, or unparseable archive_command)',
131 #how far behind is it? will be easier once we're off 9.1
132 # http://www.keithf4.com/monitoring_streaming_slave_lag/
133 # except pg_stat_replication still doesn't fill in the columns we need as
135 push @{ $status{'Replication'} },
136 { 'title' => 'Slave',
137 'value' => $slave || '(Missing, or unparseable archive_command)',
145 $status{'Replication'} = [
146 { 'title' => 'Enabled',
147 'value' => "(Not yet checked on $db)",
158 if ( _is_running('cdrd') ) {
160 my $delay = FS::Record->scalar_sql('
161 SELECT AVG(end_date-insert_date)
164 ORDER BY statnum DESC
168 my $h = int($delay/3600);
169 my $m = int( ($delay%3600) / 60 );
172 $delay = ( $h ? $h. 'h' : '' ).
173 ( $h||$m ? $m. 'm' : '').
178 my $pr_delay = FS::Record->scalar_sql('
179 SELECT AVG(end_date-start_date)
182 ORDER BY statnum DESC
186 my $h = int($delay/3600);
187 my $m = int( ($delay%3600) / 60 );
190 $pr_delay = ( $h ? $h. 'h' : '' ).
191 ( $h||$m ? $m. 'm' : '').
196 my $dayago = time2str('%Y-%m-%d %X', time - 86400);
197 my $cdrs = FS::Record->scalar_sql(qq{
198 SELECT COUNT(*) FROM cdr
199 WHERE ( freesidestatus IS NULL OR freesidestatus = '' )
200 AND calldate > '$dayago'
203 $status{'CDR Processing'} = [
204 { 'title' => 'Current processing delay',
207 { 'title' => 'Average billing time',
208 'value' => $pr_delay,
210 { 'title' => 'Unprocessed CDRs (last 24 hours)',
222 my($store, $tokenize) = (0,0);
226 'hashref' => { 'disabled' => '', },
227 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
230 my $gateway = $agent->payment_gateway('method'=>'VISA card', 'nofatal'=>1, );
232 && $gateway->gateway_namespace eq 'Business::OnlinePayment';
233 eval "use Business::OnlinePayment";
235 my $bop = new Business::OnlinePayment( $gateway->gateway_module,
238 : @{ $gateway->get('options') }
240 my %actions = $bop->info('supported_actions');
241 if ( $actions{'CC'} && grep /^Tokenize$/, @{$actions{'CC'}} ) {
249 if ( $tokenize && ! $store ) {
251 $status{'PCI Compliance'} = [
252 { 'title' => 'Tokenization',
253 'value' => 'Enabled',
255 { 'title' => 'SAQ type',
256 'value' => 'A / A-EP',
262 my $conf = new FS::Conf; #wow, didn't need this before?
264 $status{'PCI Compliance'} = [
265 { 'title' => 'Tokenization',
266 'value' => $tokenize ? 'Partialy enabled (some agents)' : 'Disabled'
268 { 'title' => 'Encryption',
270 ( $conf->exists('encryption') && $conf->config('encryptionpublickey')
271 ? 'Enabled' : 'Disabled'
274 { 'title' => 'SAQ type',
275 'value' => 'D (enable tokenization for A / A-EP)',
288 my $pid_path = '/var/run'; #XXX hardcoded path
291 -e "$pid_path/freeside/$thing.pid" ? "$pid_path/freeside/$thing.pid" :
292 -e "$pid_path/freeside-$thing.pid" ? "$pid_path/freeside-$thing.pid" :
295 -e $pidfile and kill 0, slurp($pidfile)