From fd3dd0628b557780648888e86f3697eb9bb1e743 Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Sun, 22 Feb 2009 12:10:13 +0100 Subject: [PATCH] Add a cgi to display atm-modem status --- config/menu/20-status.menu | 5 +++ config/rootfiles/common/apache2 | 1 + config/rootfiles/core/27/files | 2 + html/cgi-bin/atm-status.cgi | 77 +++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 html/cgi-bin/atm-status.cgi diff --git a/config/menu/20-status.menu b/config/menu/20-status.menu index daf5f49a8c..3e80adae6c 100644 --- a/config/menu/20-status.menu +++ b/config/menu/20-status.menu @@ -64,3 +64,8 @@ 'title' => "$Lang::tr{'qos graphs'}", 'enabled' => 1, }; + $substatus->{'75.atm-status'} = {'caption' => 'Atm-status', + 'uri' => '/cgi-bin/atm-status.cgi', + 'title' => 'Atm-status', + 'enabled' => `find /sys/class/atm/*/device`, + }; diff --git a/config/rootfiles/common/apache2 b/config/rootfiles/common/apache2 index eb6d38d109..0154fd45d5 100644 --- a/config/rootfiles/common/apache2 +++ b/config/rootfiles/common/apache2 @@ -1298,6 +1298,7 @@ etc/httpd/conf/uid.conf #etc/httpd/conf/vhosts.d etc/httpd/conf/vhosts.d/ipfire-interface-ssl.conf etc/httpd/conf/vhosts.d/ipfire-interface.conf +srv/web/ipfire/cgi-bin/atm-status.cgi srv/web/ipfire/cgi-bin/backup.cgi srv/web/ipfire/cgi-bin/chpasswd.cgi srv/web/ipfire/cgi-bin/connections.cgi diff --git a/config/rootfiles/core/27/files b/config/rootfiles/core/27/files index 32537b66a8..b69e5bfe92 100644 --- a/config/rootfiles/core/27/files +++ b/config/rootfiles/core/27/files @@ -55,3 +55,5 @@ usr/bin/madwifi-unload usr/bin/wlanconfig usr/bin/wpakey usr/local/bin/rebuild-initrd +var/ipfire/menu.d/20-status.menu +srv/web/ipfire/cgi-bin/atm-status.cgi diff --git a/html/cgi-bin/atm-status.cgi b/html/cgi-bin/atm-status.cgi new file mode 100644 index 0000000000..5c0fa8be94 --- /dev/null +++ b/html/cgi-bin/atm-status.cgi @@ -0,0 +1,77 @@ +#!/usr/bin/perl +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2008 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +use strict; + +# enable only the following on debugging purpose +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; + +require '/var/ipfire/general-functions.pl'; +require "${General::swroot}/lang.pl"; +require "${General::swroot}/header.pl"; + +my %color = (); +my %mainsettings = (); + +&General::readhash("${General::swroot}/main/settings", \%mainsettings); +&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); + +&Header::showhttpheaders(); +&Header::openpage($Lang::tr{'status information'}, 1, ''); +&Header::openbigbox('100%', 'left'); + +my @modems = `find /sys/class/atm/*/device 2>/dev/null | cut -d'/' -f5`; +foreach (@modems){ + chomp($_); + &Header::openbox('100%', 'left',"ATM MODEM $_ State"); + my $lines=0; + print "
"; + my $modem=$_; + my @pfile = `grep . /sys/class/atm/$modem/device/* 2>/dev/null`; + foreach (@pfile){ + chomp($_); + my $param= `echo $_ | cut -d'/' -f7 | cut -d':' -f1`; + my $value= `cat /sys/class/atm/$modem/device/$param`; + chomp($param); + chomp($value); + if (!($param =~"uevent") + && !($param =~"modalias") + && !($param =~"bInterface") + && !($param =~"bAlternateSetting") + && !($param =~"bNumEndpoints") + && !($param eq "") + ) { + + $lines++; + if ($lines % 2){ + print ""; + }else{ + print ""; + } + print " "; + } + } + print "
$param$value

\n"; + &Header::closebox(); +} +&Header::closebigbox(); +&Header::closepage(); -- 2.39.2