summaryrefslogtreecommitdiff
path: root/httemplate/view
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-07-27 12:29:12 -0700
committerIvan Kohler <ivan@freeside.biz>2014-07-27 12:29:12 -0700
commit08cf05e4cb9a5367eae210205e38ce33a871b9e7 (patch)
tree99376813daa2643735b55c272a71bcc2ff0b02d7 /httemplate/view
parentdf2a87672acaed825b7399bf909a69314bb0d9c0 (diff)
status, RT#30241
Diffstat (limited to 'httemplate/view')
-rw-r--r--httemplate/view/Status.html131
1 files changed, 131 insertions, 0 deletions
diff --git a/httemplate/view/Status.html b/httemplate/view/Status.html
new file mode 100644
index 000000000..019470eb9
--- /dev/null
+++ b/httemplate/view/Status.html
@@ -0,0 +1,131 @@
+<& /elements/header.html &>
+% foreach my $section ( keys %status ) {
+<FONT CLASS="fsinnerbox-title"><% mt($section) |h %></FONT>
+<TABLE CLASS="fsinnerbox">
+% foreach my $item ( @{ $status{$section} } ) {
+ <TR>
+ <TD ALIGN="right"><% $item->{title} %></TH>
+ <TD><B><% $item->{value} %></B></TD>
+ </TR>
+% }
+</TABLE>
+<BR><BR>
+% }
+<& /elements/footer.html &>
+<%init>
+
+my $os;
+-e '/usr/bin/lsb_release' and run( ['lsb_release', '-d'], '>',\$os );
+if ( ! $@ && $os =~ /^\s*Description:\s*(.+)$/ ) {
+ $os = $1;
+} elsif ( my $deb_version = slurp('/etc/debian_version') ) {
+ $os = "Debian $deb_version";
+}
+
+( my $perl_ver = $^V ) =~ s/^v//;
+
+my $db = driver_name;
+$db = 'PostgreSQL' if $db =~ /^Pg/;
+$db = 'MySQL' 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;
+}
+
+tie my %status, 'Tie::IxHash',
+ 'Basics' => [
+ { 'title' => 'Freeside version',
+ 'value' => $FS::VERSION,
+ },
+ { 'title' => 'Operating System',
+ 'value' => $os,
+ },
+ { 'title' => 'Perl version',
+ 'value' => $perl_ver,
+ },
+ { 'title' => 'Database engine',
+ 'value' => $db,
+ },
+ { 'title' => 'Database version',
+ 'value' => $db_ver,
+ },
+ ],
+ 'Required Daemons' => [
+ { 'title' => 'Queue daemon',
+ 'value' => _is_running('queued') ? 'Running' : 'Not running',
+ },
+ ],
+ 'Optional Daemons' => [
+ { 'title' => 'Self-service server(s)',
+ 'value' => '(Not checked)', #XXX multiple pid files, per machine etc
+ },
+ { 'title' => 'Self-service XML-RPC server',
+ 'value' => _is_running('selfservice-xmlrpcd') ? 'Running' : 'Not running',
+ },
+ { 'title' => 'Back office XML-RPC server',
+ 'value' => _is_running('xmlrpcd') ? 'Running' : 'Not running',
+ },
+ { 'title' => 'RADIUS accounting import daemon',
+ 'value' => _is_running('sqlradius-radacctd') ? 'Running' : 'Not running',
+ },
+ { 'title' => 'Prepaid daemon',
+ 'value' => _is_running('prepaidd') ? 'Running' : 'Not running',
+ },
+ { 'title' => 'CDR Rewrite daemon',
+ 'value' => _is_running('cdrrewrited') ? 'Running' : 'Not running',
+ },
+ { 'title' => 'CDR Prepaid daemon',
+ 'value' => _is_running('cdrd') ? 'Running' : 'Not running',
+ },
+ { 'title' => 'CDR Real-time rating daemon',
+ 'value' => _is_running('cdrrated') ? 'Running' : 'Not running',
+ },
+ #{ 'title' => 'Network monitoring port combiner', #?
+ # 'value' => _is_running('torrus-srvderive') ? 'Running' : 'Not running',
+ #},
+ ],
+;
+
+if ( _is_running('cdrd') ) {
+
+ my $delay = FS::Record->scalar_sql('
+ SELECT AVG(end_date-insert_date)
+ FROM queue_stat
+ GROUP BY statnum
+ ORDER BY statnum DESC
+ LIMIT 100
+ ');
+ if ( $delay ) {
+ my $h = int($delay/3600);
+ my $m = int( ($delay%3600) / 60 );
+ my $s = $delay%60;
+
+ $delay = ( $h ? $h. 'h' : '' ).
+ ( $h||$m ? $m. 'm' : '').
+ $s. 's';
+
+ }
+
+ $status{'CDR Processing'} = [
+ { 'title' => 'Current processing delay',
+ 'value' => $delay,
+ },
+ ];
+
+}
+
+sub _is_running {
+ my $thing = shift;
+
+ my $pid_path = '/var/run'; #XXX hardcoded path
+
+ my $pidfile =
+ -e "$pid_path/freeside/$thing.pid" ? "$pid_path/freeside/$thing.pid" :
+ -e "$pid_path/freeside-$thing.pid" ? "$pid_path/freeside-$thing.pid" :
+ return 0;
+
+ -e $pidfile and kill 0, slurp($pidfile)
+}
+
+</%init>