summaryrefslogtreecommitdiff
path: root/htdocs
diff options
context:
space:
mode:
authorivan <ivan>2000-12-03 13:44:05 +0000
committerivan <ivan>2000-12-03 13:44:05 +0000
commitc7effea426d7cefcebc4b32f162fd1719095fc12 (patch)
tree6a7e15cf2d676c0d2e2e059e49fa3f187bc8d25f /htdocs
parente966cec8367fbc5f21b366f9c497fc0260292407 (diff)
beginnings of web status for session monitor
Diffstat (limited to 'htdocs')
-rwxr-xr-xhtdocs/browse/nas.cgi75
-rwxr-xr-xhtdocs/index.html1
2 files changed, 76 insertions, 0 deletions
diff --git a/htdocs/browse/nas.cgi b/htdocs/browse/nas.cgi
new file mode 100755
index 000000000..2aafbc1fd
--- /dev/null
+++ b/htdocs/browse/nas.cgi
@@ -0,0 +1,75 @@
+#!/usr/bin/perl -Tw
+
+use strict;
+use vars qw( $cgi $p );
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+use Date::Format;
+use FS::UID qw(cgisuidsetup);
+use FS::Record qw(qsearch); # qsearchs);
+use FS::CGI qw(header menubar table popurl);
+use FS::nas;
+use FS::port;
+use FS::session;
+
+$cgi = new CGI;
+&cgisuidsetup($cgi);
+
+$p=popurl(2);
+
+print $cgi->header( '-expires' => 'now' ), header('NAS ports', menubar(
+ 'Main Menu' => $p,
+));
+
+my $now = time;
+
+foreach my $nas ( sort { $a->nasnum <=> $b->nasnum } qsearch( 'nas', {} ) ) {
+ print $nas->nasnum. ": ". $nas->nas. " ".
+ $nas->nasfqdn. " (". $nas->nasip. ") ".
+ "as of ". time2str("%c",$nas->last).
+ " (". &pretty_interval($now - $nas->last). " ago)<br>".
+ &table(). "<TR><TH>Nas<BR>Port #</TH><TH>Global<BR>Port #</BR></TH>".
+ "<TH>IP address</TH><TH>User</TH><TH>Since</TH><TH>Duration</TH><TR>",
+ ;
+ foreach my $port ( sort {
+ $a->nasport <=> $b->nasport || $a->portnum <=> $b->portnum
+ } qsearch( 'port' ) ) {
+ print "<TR><TD>". $port->nasport. "</TD><TD>". $port->portnum. "</TD><TD>".
+ $port->ip. "</TD><TD>". 'user'. "</TD><TD>". 'since'. "</TD><TD>".
+ 'duration'. "</TD></TR>"
+ ;
+ }
+ print "</TABLE><BR>";
+}
+
+sub pretty_interval {
+ my $interval = shift;
+ my %howlong = (
+ '604800' => 'week',
+ '86400' => 'day',
+ '3600' => 'hour',
+ '60' => 'minute',
+ '1' => 'second',
+ );
+
+ my $pretty = "";
+ foreach my $key ( sort { $b <=> $a } keys %howlong ) {
+ my $value = int( $interval / $key );
+ if ( $value ) {
+ if ( $value == 1 ) {
+ $pretty .=
+ ( $howlong{$key} eq 'hour' ? 'an ' : 'a ' ). $howlong{$key}. " "
+ } else {
+ $pretty .= $value. ' '. $howlong{$key}. 's ';
+ }
+ }
+ $interval -= $value * $key;
+ }
+ $pretty =~ /^\s*(\S.*\S)\s*$/;
+ $1;
+}
+
+#print &table(), <<END;
+#<TR>
+# <TH>#</TH>
+# <TH>NAS</
diff --git a/htdocs/index.html b/htdocs/index.html
index 0ae8b5dbb..75c301f75 100755
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -61,6 +61,7 @@
<LI>unlinked accounts (<A HREF="search/svc_acct.cgi?UN_svcnum">by service number</A>) (<A HREF="search/svc_acct.cgi?UN_username">by username</A>) (<A HREF="search/svc_acct.cgi?UN_uid">by uid</A>)
<LI>unlinked domains (<A HREF="search/svc_domain.cgi?UN_svcnum">by service number</A>) (<A HREF="search/svc_domain.cgi?UN_domain">by domain</A>)
</UL>
+ <LI><A HREF="browse/nas.cgi">NAS ports</A>
</ul>
<li><A NAME="admin">Administration</a>
<ul>