From c7effea426d7cefcebc4b32f162fd1719095fc12 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Dec 2000 13:44:05 +0000 Subject: beginnings of web status for session monitor --- htdocs/browse/nas.cgi | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ htdocs/index.html | 1 + 2 files changed, 76 insertions(+) create mode 100755 htdocs/browse/nas.cgi (limited to 'htdocs') 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)
". + &table(). "Nas
Port #Global
Port #
". + "IP addressUserSinceDuration", + ; + foreach my $port ( sort { + $a->nasport <=> $b->nasport || $a->portnum <=> $b->portnum + } qsearch( 'port' ) ) { + print "". $port->nasport. "". $port->portnum. "". + $port->ip. "". 'user'. "". 'since'. "". + 'duration'. "" + ; + } + print "
"; +} + +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(), < +# # +# NASunlinked accounts (by service number) (by username) (by uid)
  • unlinked domains (by service number) (by domain) +
  • NAS ports
  • Administration
      -- cgit v1.2.1