[freeside-commits] branch master updated. 726016f6288d017c748a8d4cdc0157ad7abfe13a

Ivan ivan at 420.am
Sun Jul 27 12:29:19 PDT 2014


The branch, master has been updated
       via  726016f6288d017c748a8d4cdc0157ad7abfe13a (commit)
      from  01af84c2028da7c7607c3936e01a72725bb6a1f2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 726016f6288d017c748a8d4cdc0157ad7abfe13a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Jul 27 12:29:00 2014 -0700

    status, RT#30241

diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 1ae60ed..4f43c6b 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -83,6 +83,7 @@ if ( -e $addl_handler_use_file ) {
   use IO::File;
   use IO::Scalar;
   use IO::String;
+  use File::Slurp qw( slurp );
   #not actually using this yet anyway...# use IPC::Run3 0.036;
   use Net::Whois::Raw qw(whois);
   if ( $] < 5.006 ) {
@@ -385,6 +386,7 @@ if ( -e $addl_handler_use_file ) {
   use FS::part_pkg_fcc_option;
   use FS::state;
   use FS::state;
+  use FS::queue_stat;
   # Sammath Naur
 
   if ( $FS::Mason::addl_handler_use ) {
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index fdd4962..6268cf9 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -499,6 +499,9 @@ $tools_menu{'Importing'} =  [ \%tools_importing, 'Import tools' ]
   if $curuser->access_right('Import');
 $tools_menu{'Exporting'} =  [ \%tools_exporting, 'Export tools' ]
   if $curuser->access_right('Export');
+$tools_menu{'Status'} = [ $fsurl.'view/Status.html', 'System status' ]
+  if $curuser->access_right('Configuration'); # 'View system status');
+
 
 tie my %config_employees, 'Tie::IxHash',
   'Employees' => [ $fsurl.'browse/access_user.html', 'Setup internal users' ],
diff --git a/httemplate/view/Status.html b/httemplate/view/Status.html
new file mode 100644
index 0000000..019470e
--- /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>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Mason.pm                |    2 +
 httemplate/elements/menu.html |    3 +
 httemplate/view/Status.html   |  131 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 136 insertions(+)
 create mode 100644 httemplate/view/Status.html




More information about the freeside-commits mailing list