X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2FStatus.html;h=7fd019e8c89ee93d0a0059f6c22bbb22460f6eee;hp=8dddd144e128b0c6ae701c99335ce04acf42f6ea;hb=ce71ca0fc6ca933af93c76c2f8e5f764e304b3a0;hpb=f231eae341e7f438a1a1eea9f4ddad8f0a7b4fb7 diff --git a/httemplate/view/Status.html b/httemplate/view/Status.html index 8dddd144e..7fd019e8c 100644 --- a/httemplate/view/Status.html +++ b/httemplate/view/Status.html @@ -25,14 +25,23 @@ if ( ! $@ && $os =~ /^\s*Description:\s*(.+)$/ ) { ( my $perl_ver = $^V ) =~ s/^v//; my $db = driver_name; -$db = 'PostgreSQL' if $db =~ /^Pg/; -$db = 'MySQL' if $db =~ /^mysql/; +$db = 'PostgreSQL' if $db =~ /^Pg/; +$db = 'MySQL/MariaDB' if $db =~ /^mysql/; my $db_ver = FS::Record->scalar_sql('SELECT VERSION()'); if ( $db eq 'PostgreSQL' && $db_ver =~ /^\s*PostgreSQL\s+([\w\.]+)\s+on\s+/ ) { $db_ver = $1; } +my $db_size = 'Unknown'; +if ( $db eq 'PostgreSQL' ) { + $db_size = FS::Record->scalar_sql(qq( + SELECT pg_size_pretty(pg_database_size(datname)) + FROM pg_catalog.pg_database + WHERE datname = 'freeside' + )); +} + tie my %status, 'Tie::IxHash', 'Basics' => [ { 'title' => 'Freeside version', @@ -50,6 +59,9 @@ tie my %status, 'Tie::IxHash', { 'title' => 'Database version', 'value' => $db_ver, }, + { 'title' => 'Database size', + 'value' => $db_size, + }, ], 'Required Daemons' => [ { 'title' => 'Queue daemon', @@ -87,6 +99,50 @@ tie my %status, 'Tie::IxHash', ], ; +if ( $db eq 'PostgreSQL' ) { + + my $enabled = FS::Record->scalar_sql('SHOW wal_level') eq 'hot_standby' + && FS::Record->scalar_sql('SHOW archive_mode') eq 'on'; + + my $slave = + FS::Record->scalar_sql('SHOW archive_command') =~ / postgres\@([\w\.\-]+): / + ? $1 : ''; + + $status{'Replication'} = [ + { 'title' => 'Status', #? + 'value' => $enabled ? 'Enabled' : 'Disabled', + }, + ]; + + if ( $enabled ) { + push @{ $status{'Replication'} }, + { 'title' => 'Slave', + 'value' => $slave || '(Missing, or unparseable archive_command)', + }, + ; + if ( $slave ) { + #how far behind is it? will be easier once we're off 9.1 + # http://www.keithf4.com/monitoring_streaming_slave_lag/ + # except pg_stat_replication still doesn't fill in the columns we need as + # non-Pg user :/ + push @{ $status{'Replication'} }, + { 'title' => 'Slave', + 'value' => $slave || '(Missing, or unparseable archive_command)', + }, + ; + } + } + +} else { + + $status{'Replication'} = [ + { 'title' => 'Enabled', + 'value' => "(Not yet checked on $db)", + }, + ]; + +} + if ( _is_running('cdrd') ) { my $delay = FS::Record->scalar_sql(' @@ -106,11 +162,6 @@ if ( _is_running('cdrd') ) { $s. 's'; } - $status{'CDR Processing'} = [ - { 'title' => 'Current processing delay', - 'value' => $delay, - }, - ]; my $pr_delay = FS::Record->scalar_sql(' SELECT AVG(end_date-start_date) @@ -129,19 +180,21 @@ if ( _is_running('cdrd') ) { $s. 's'; } - $status{'CDR Processing'} = [ - { 'title' => 'Average billing time', - 'value' => $pr_delay, - }, - ]; - my $24ago = time2str('%Y-%m-$d %X', time - 86400); + my $dayago = time2str('%Y-%m-%d %X', time - 86400); my $cdrs = FS::Record->scalar_sql(qq{ SELECT COUNT(*) FROM cdr WHERE ( freesidestatus IS NULL OR freesidestatus = '' ) - AND calldate > '$24ago' + AND calldate > '$dayago' }); + $status{'CDR Processing'} = [ + { 'title' => 'Current processing delay', + 'value' => $delay, + }, + { 'title' => 'Average billing time', + 'value' => $pr_delay, + }, { 'title' => 'Unprocessed CDRs (last 24 hours)', 'value' => $cdrs, },