1 <& /elements/header.html &>
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 &>
18 -e '/usr/bin/lsb_release' and run( ['lsb_release', '-d'], '>',\$os );
19 if ( ! $@ && $os =~ /^\s*Description:\s*(.+)$/ ) {
21 } elsif ( my $deb_version = slurp('/etc/debian_version') ) {
22 $os = "Debian $deb_version";
25 ( my $perl_ver = $^V ) =~ s/^v//;
28 $db = 'PostgreSQL' if $db =~ /^Pg/;
29 $db = 'MySQL/MariaDB' if $db =~ /^mysql/;
31 my $db_ver = FS::Record->scalar_sql('SELECT VERSION()');
32 if ( $db eq 'PostgreSQL' && $db_ver =~ /^\s*PostgreSQL\s+([\w\.]+)\s+on\s+/ ) {
36 my $db_size = 'Unknown';
37 if ( $db eq 'PostgreSQL' ) {
38 $db_size = FS::Record->scalar_sql(qq(
39 SELECT pg_size_pretty(pg_database_size(datname))
40 FROM pg_catalog.pg_database
41 WHERE datname = 'freeside'
45 tie my %status, 'Tie::IxHash',
47 { 'title' => 'Freeside version',
48 'value' => $FS::VERSION,
50 { 'title' => 'Operating System',
53 { 'title' => 'Perl version',
56 { 'title' => 'Database engine',
59 { 'title' => 'Database version',
62 { 'title' => 'Database size',
66 'Required Daemons' => [
67 { 'title' => 'Queue daemon',
68 'value' => _is_running('queued') ? 'Running' : 'Not running',
71 'Optional Daemons' => [
72 { 'title' => 'Self-service server(s)',
73 'value' => '(Not checked)', #XXX multiple pid files, per machine etc
75 { 'title' => 'Self-service XML-RPC server',
76 'value' => _is_running('selfservice-xmlrpcd') ? 'Running' : 'Not running',
78 { 'title' => 'Back office XML-RPC server',
79 'value' => _is_running('xmlrpcd') ? 'Running' : 'Not running',
81 { 'title' => 'RADIUS accounting import daemon',
82 'value' => _is_running('sqlradius-radacctd') ? 'Running' : 'Not running',
84 { 'title' => 'Prepaid daemon',
85 'value' => _is_running('prepaidd') ? 'Running' : 'Not running',
87 { 'title' => 'CDR Rewrite daemon',
88 'value' => _is_running('cdrrewrited') ? 'Running' : 'Not running',
90 { 'title' => 'CDR Prepaid daemon',
91 'value' => _is_running('cdrd') ? 'Running' : 'Not running',
93 { 'title' => 'CDR Real-time rating daemon',
94 'value' => _is_running('cdrrated') ? 'Running' : 'Not running',
96 #{ 'title' => 'Network monitoring port combiner', #?
97 # 'value' => _is_running('torrus-srvderive') ? 'Running' : 'Not running',
102 if ( $db eq 'PostgreSQL' ) {
104 my $enabled = FS::Record->scalar_sql('SHOW wal_level') eq 'hot_standby'
105 && FS::Record->scalar_sql('SHOW archive_mode') eq 'on';
108 FS::Record->scalar_sql('SHOW archive_command') =~ / postgres\@([\w\.\-]+): /
111 $status{'Replication'} = [
112 { 'title' => 'Status', #?
113 'value' => $enabled ? 'Enabled' : 'Disabled',
118 push @{ $status{'Replication'} },
119 { 'title' => 'Slave',
120 'value' => $slave || '(Missing, or unparseable archive_command)',
124 #how far behind is it? will be easier once we're off 9.1
125 # http://www.keithf4.com/monitoring_streaming_slave_lag/
126 # except pg_stat_replication still doesn't fill in the columns we need as
128 push @{ $status{'Replication'} },
129 { 'title' => 'Slave',
130 'value' => $slave || '(Missing, or unparseable archive_command)',
138 $status{'Replication'} = [
139 { 'title' => 'Enabled',
140 'value' => "(Not yet checked on $db)",
146 if ( _is_running('cdrd') ) {
148 my $delay = FS::Record->scalar_sql('
149 SELECT AVG(end_date-insert_date)
152 ORDER BY statnum DESC
156 my $h = int($delay/3600);
157 my $m = int( ($delay%3600) / 60 );
160 $delay = ( $h ? $h. 'h' : '' ).
161 ( $h||$m ? $m. 'm' : '').
166 my $pr_delay = FS::Record->scalar_sql('
167 SELECT AVG(end_date-start_date)
170 ORDER BY statnum DESC
174 my $h = int($delay/3600);
175 my $m = int( ($delay%3600) / 60 );
178 $pr_delay = ( $h ? $h. 'h' : '' ).
179 ( $h||$m ? $m. 'm' : '').
184 my $dayago = time2str('%Y-%m-%d %X', time - 86400);
185 my $cdrs = FS::Record->scalar_sql(qq{
186 SELECT COUNT(*) FROM cdr
187 WHERE ( freesidestatus IS NULL OR freesidestatus = '' )
188 AND calldate > '$dayago'
191 $status{'CDR Processing'} = [
192 { 'title' => 'Current processing delay',
195 { 'title' => 'Average billing time',
196 'value' => $pr_delay,
198 { 'title' => 'Unprocessed CDRs (last 24 hours)',
208 my $pid_path = '/var/run'; #XXX hardcoded path
211 -e "$pid_path/freeside/$thing.pid" ? "$pid_path/freeside/$thing.pid" :
212 -e "$pid_path/freeside-$thing.pid" ? "$pid_path/freeside-$thing.pid" :
215 -e $pidfile and kill 0, slurp($pidfile)