From: <ow...@us...> - 2007-10-29 11:24:35
|
Revision: 592 http://ipcop.svn.sourceforge.net/ipcop/?rev=592&view=rev Author: owes Date: 2007-10-29 04:24:37 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Added System Info info page into Status menu. SysInfo is currently a usefull Addon (http://www.ipadd.de) that provides additional info. Especially at this stage of development this info is interesting. Modified Paths: -------------- ipcop/trunk/config/cfgroot/header.pl ipcop/trunk/config/rootfiles/common/apache ipcop/trunk/config/rootfiles/common/misc-progs ipcop/trunk/langs/en/cgi-bin/en.pl ipcop/trunk/src/misc-progs/Makefile Added Paths: ----------- ipcop/trunk/html/cgi-bin/sysinfo.cgi ipcop/trunk/src/misc-progs/sysinfo.c Modified: ipcop/trunk/config/cfgroot/header.pl =================================================================== --- ipcop/trunk/config/cfgroot/header.pl 2007-10-29 09:24:01 UTC (rev 591) +++ ipcop/trunk/config/cfgroot/header.pl 2007-10-29 11:24:37 UTC (rev 592) @@ -72,6 +72,7 @@ 'uri' => '', 'statusText' => "IPCop $Lang::tr{'status information'}", 'subMenu' => [[ $Lang::tr{'sssystem status'} , '/cgi-bin/status.cgi', "IPCop $Lang::tr{'system status information'}" ], + [ $Lang::tr{'system info menu'}, '/cgi-bin/sysinfo.cgi', "IPCop $Lang::tr{'system info menu'}" ], [ $Lang::tr{'ssnetwork status'} , '/cgi-bin/netstatus.cgi', "IPCop $Lang::tr{'network status information'}" ], [ $Lang::tr{'system graphs'} , '/cgi-bin/graphs.cgi', "IPCop $Lang::tr{'system graphs'}" ], [ $Lang::tr{'sstraffic graphs'} , '/cgi-bin/graphs.cgi?graph=network', "IPCop $Lang::tr{'network traffic graphs'}" ], Modified: ipcop/trunk/config/rootfiles/common/apache =================================================================== --- ipcop/trunk/config/rootfiles/common/apache 2007-10-29 09:24:01 UTC (rev 591) +++ ipcop/trunk/config/rootfiles/common/apache 2007-10-29 11:24:37 UTC (rev 592) @@ -91,6 +91,7 @@ home/httpd/cgi-bin/shaping.cgi home/httpd/cgi-bin/shutdown.cgi home/httpd/cgi-bin/status.cgi +home/httpd/cgi-bin/sysinfo.cgi #home/httpd/cgi-bin/test-cgi home/httpd/cgi-bin/time.cgi home/httpd/cgi-bin/updates.cgi Modified: ipcop/trunk/config/rootfiles/common/misc-progs =================================================================== --- ipcop/trunk/config/rootfiles/common/misc-progs 2007-10-29 09:24:01 UTC (rev 591) +++ ipcop/trunk/config/rootfiles/common/misc-progs 2007-10-29 11:24:37 UTC (rev 592) @@ -27,3 +27,4 @@ usr/local/bin/settimenow usr/local/bin/setxtaccess usr/local/bin/snortrules +usr/local/bin/sysinfo Added: ipcop/trunk/html/cgi-bin/sysinfo.cgi =================================================================== --- ipcop/trunk/html/cgi-bin/sysinfo.cgi (rev 0) +++ ipcop/trunk/html/cgi-bin/sysinfo.cgi 2007-10-29 11:24:37 UTC (rev 592) @@ -0,0 +1,233 @@ +#!/usr/bin/perl +# +################################################################################ +# +# IPCop SysInfo Web-Iface +# +# Copyright (C) 2007 Tom 'wintermute' Eichstaedt <win...@to...> +# +# 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA +# +# +# Dieses Programm ist freie Software. Sie k\xF6nnen es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation ver\xF6ffentlicht, weitergeben und/oder modifizieren, entweder gem\xE4\xDF Version 2 der Lizenz oder (nach Ihrer Option) jeder sp\xE4teren Version. +# +# Die Ver\xF6ffentlichung dieses Programms erfolgt in der Hoffnung, da\xDF es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT F\xDCR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. +# +# Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA. +# +################################################################################ +# +# +# +# Based on IPCop http://www.ipcop.org, hddgraph (C) by weizen_42 +# +# +# 2007-02-13 modified by wintermute for SysInfo +# +# $Id$ +# + +use strict; + +# enable only the following on debugging purpose +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; + +use LWP::UserAgent; + +require 'CONFIG_ROOT/general-functions.pl'; +require "${General::swroot}/lang.pl"; +require "${General::swroot}/header.pl"; + +my %cgiparams=(); +my @lines; +my $i; + +&Header::showhttpheaders(); + +&Header::openpage($Lang::tr{'system info page'}, 1, ''); + +&Header::openbigbox('100%', 'left'); + +print <<END +<table width='100%' cellspacing='0' cellpadding='5'border='0'><tr> + <td style="background-color: #EAE9EE;" align='left'> + <a href='#cpu'>$Lang::tr{'system info cpu submenu'}</a> | + <a href='#hdd'>$Lang::tr{'system info hdd submenu'}</a> | + <a href='#pci'>$Lang::tr{'system info pci submenu'}</a> | + <a href='#nic'>$Lang::tr{'system info nic submenu'}</a> | + <a href='#usb'>$Lang::tr{'system info usb submenu'}</a> | + <a href='#irq'>$Lang::tr{'system info irq submenu'}</a> | + <a href='#bios'>$Lang::tr{'system info bios submenu'}</a> | + <a href='#ps'>$Lang::tr{'system info ps submenu'}</a></td> + <td style="background-color: #EAE9EE;" align='right'> </td> +</tr></table> +END +; + +print "<a name='cpu'/>\n"; +&Header::openbox('100%', 'left', $Lang::tr{'system info cpu'}); + my $outputcpu = `/bin/cat /proc/cpuinfo`; + my $cpumhz; + my $bogomips; + my $bogoeff; + $outputcpu = &Header::cleanhtml($outputcpu); + chomp($outputcpu); + + my $outputcpuleft; + my $outputcpumid; + my $outputcpuright; + (@lines) = split(/\n/, $outputcpu); + $outputcpu = ''; + foreach my $line ( @lines ) + { + unless ( $line =~ /(.*):(.*)/ ) + { + $outputcpuleft .= "\n"; + $outputcpumid .= "\n"; + $outputcpuright .= "\n"; + next; + } + (my $l, my $r) = split(/:/, $line, 2); + $outputcpuleft .= "$l\n"; + $outputcpumid .= ":\n"; + if ( length($2) > 100 ) + { + $outputcpuleft .= "\n"; + $outputcpumid .= "\n"; + $outputcpuright .= substr($2, 0, rindex($2, ' ', 100)) . "\n" . substr($2, rindex($2, ' ', 100)) . "\n"; + } + else + { + $outputcpuright .= "$2\n"; + } + $cpumhz = $1 if ( $line =~ /cpu MHz.*: (.*)/ ); + if ( $line =~ /bogomips.*: (.*)/ ) + { + $bogomips = $1; + $bogoeff = $bogomips / $cpumhz * 50; + $outputcpuleft .= "bogomips eff.\n"; + $outputcpumid .= ":\n"; + $outputcpuright .= sprintf(" %.4f %%\n", $bogoeff); + } + } + print <<END + <table cellspacing='0' cellpadding='0' border='0'><tr> + <td valign='top'><pre>$outputcpuleft</pre></td> + <td valign='top'><pre>$outputcpumid</pre></td> + <td valign='top'><pre>$outputcpuright</pre></td> + </tr></table> +END +; +&Header::closebox(); + +print "<a name='hdd'/>\n"; +&Header::openbox('100%', 'left', $Lang::tr{'system info hdd'}); + if (! -e "/proc/scsi/scsi") { + my $outputhdd = `/usr/local/bin/sysinfo hdd`; + $outputhdd = &Header::cleanhtml($outputhdd); + print "<pre>"; + (@lines) = split(/\n/, $outputhdd); + my $counter = 0; + foreach my $line ( @lines ) + { + print $line."\r" if ( $counter++ > 2); + } + print "</pre>\n"; + } + if (-e "/proc/scsi/scsi") { + my $outputscsi = `/bin/cat /proc/scsi/scsi`; + $outputscsi = &Header::cleanhtml($outputscsi); + print "<pre>$outputscsi</pre>\n"; + } +&Header::closebox(); + +print "<a name='pci'/>\n"; +&Header::openbox('100%', 'left', $Lang::tr{'system info pci'}); + my $outputpci = `/usr/sbin/lspci`; + $outputpci = &Header::cleanhtml($outputpci); + print "<pre>$outputpci</pre>\n"; +&Header::closebox(); + +print "<a name='nic'/>\n"; +&Header::openbox('100%', 'left', $Lang::tr{'system info nic'}); + my $outputnic = `/usr/sbin/lspci`; + $outputnic = &Header::cleanhtml($outputnic); + + print "<pre>"; + (@lines) = split(/\n/, $outputnic); + foreach my $line ( @lines ) + { + next if ($line !~ /Ethernet|Network/); + print $line."\r"; + (my $slot) = split(/ /, $line); + $outputnic = `/usr/local/bin/sysinfo nic $slot`; + $outputnic =~ s/$slot/ /; + $outputnic = &Header::cleanhtml($outputnic); + print $outputnic; + } + print "</pre>"; + + print "<table cellspacing='0' cellpadding='0'border='0'><tr>"; + print "<td colspan='2'><pre style='font: 12px; margin: 0px;'>$Lang::tr{'system info mii'}</pre></td>"; + print "</tr><tr>"; + print "<td><pre style='font: 12px; margin: 0px;'> </pre></td>"; + print "<td><pre>"; + + for ($i = 0; $i < 8; $i++) + { + my $presenteth = `/bin/cat /proc/net/dev | /bin/grep eth$i`; + next if ( length($presenteth) <= 5 ); + + my $outputmii = `/sbin/mii-tool eth$i 2>/dev/null`; + if (length ($outputmii) < 5) { + $outputmii = "eth$i: link status: unknown (MII not supported)\n"; + } + $outputmii = &Header::cleanhtml($outputmii); + print $outputmii; + } + + print "</pre></td>"; + print "</tr></table>"; + +&Header::closebox(); + +# Olaf: include this after lsusb is added to IPCop +# +#print "<a name='usb'/>\n"; +#&Header::openbox('100%', 'left', $Lang::tr{'system info usb'}); +# my $outputusb = `/usr/local/sbin/lsusb`; +# $outputusb = &Header::cleanhtml($outputusb); +# print "<pre>$outputusb</pre>\n"; +#&Header::closebox(); + +print "<a name='irq'/>\n"; +&Header::openbox('100%', 'left', $Lang::tr{'system info irq'}); + my $outputirq = `/bin/cat /proc/interrupts`; + $outputirq = &Header::cleanhtml($outputirq); + print "<pre>$outputirq</pre>\n"; +&Header::closebox(); + +# Olaf: need biosdecode from dmidecode for this +# +#print "<a name='bios'/>\n"; +#&Header::openbox('100%', 'left', $Lang::tr{'system info bios'}); +# my $outputbios = `/usr/local/bin/sysinfo bios | grep -v "# biosdecode"`; +# $outputbios = &Header::cleanhtml($outputbios); +# print "<pre>$outputbios</pre>\n"; +#&Header::closebox(); + +print "<a name='ps'/>\n"; +&Header::openbox('100%', 'left', $Lang::tr{'system info ps'}); + my $outputps = `ps fax -o user,pid,ppid,%cpu,%mem,vsz,rss,tty,stat,start,time,command --cols 128`; + $outputps = &Header::cleanhtml($outputps); + print "<pre>$outputps</pre>\n"; +&Header::closebox(); + +&Header::closebigbox(); + +&Header::closepage(); Property changes on: ipcop/trunk/html/cgi-bin/sysinfo.cgi ___________________________________________________________________ Name: svn:keyword + id Modified: ipcop/trunk/langs/en/cgi-bin/en.pl =================================================================== --- ipcop/trunk/langs/en/cgi-bin/en.pl 2007-10-29 09:24:01 UTC (rev 591) +++ ipcop/trunk/langs/en/cgi-bin/en.pl 2007-10-29 11:24:37 UTC (rev 592) @@ -845,6 +845,25 @@ 'system cpu' => 'System CPU', 'system cpu usage' => 'System CPU Usage', 'system graphs' => 'System Graphs', +'system info menu' => 'System Info', +'system info page' => 'System Info', +'system info mii' => 'Link status', +'system info cpu' => 'CPU informations', +'system info hdd' => 'System harddisk', +'system info pci' => 'PCI devices', +'system info nic' => 'Network interface cards', +'system info usb' => 'USB devices', +'system info irq' => 'Used interrupts', +'system info bios' => 'BIOS informations', +'system info ps' => 'Process status', +'system info cpu submenu' => 'CPU informations', +'system info hdd submenu' => 'System harddisk', +'system info pci submenu' => 'PCI devices', +'system info nic submenu' => 'Network interface cards', +'system info usb submenu' => 'USB devices', +'system info irq submenu' => 'Interrupts', +'system info bios submenu' => 'BIOS', +'system info ps submenu' => 'Process status', 'system log viewer' => 'System Log Viewer', 'system logs' => 'System Logs', 'system status information' => 'System Status Information', Modified: ipcop/trunk/src/misc-progs/Makefile =================================================================== --- ipcop/trunk/src/misc-progs/Makefile 2007-10-29 09:24:01 UTC (rev 591) +++ ipcop/trunk/src/misc-progs/Makefile 2007-10-29 11:24:37 UTC (rev 592) @@ -10,7 +10,7 @@ ipcopbkcfg ipcoprscfg installpackage installfcdsl ipsecctrl \ setaliases ipcopbackup restartshaping restartntpd \ restartwireless setdate rebuildhosts snortrules \ - restartsyslogd logwatch settimenow + restartsyslogd logwatch settimenow sysinfo all : libsmooth.o $(PROGS) $(SUID_PROGS) @@ -88,3 +88,6 @@ snortrules: snortrules.c setuid.o $(COMPILE) snortrules.c setuid.o -o $@ + +sysinfo: sysinfo.c setuid.o + $(COMPILE) sysinfo.c setuid.o -o $@ Added: ipcop/trunk/src/misc-progs/sysinfo.c =================================================================== --- ipcop/trunk/src/misc-progs/sysinfo.c (rev 0) +++ ipcop/trunk/src/misc-progs/sysinfo.c 2007-10-29 11:24:37 UTC (rev 592) @@ -0,0 +1,51 @@ +/* This file is part of the SysInfo GUI Addon + * + * This program is distributed under the terms of the GNU General Public + * Licence. See the file COPYING for details. + * + * Copyright (C) 2006-05-27 weizen_42 at ipcop-forum dot de + * + * $Id$ + * + */ + +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/types.h> +#include <fcntl.h> +#include "setuid.h" +#define BUFFER_SIZE 1024 + +char command[BUFFER_SIZE]; + +int main(int argc, char *argv[]) +{ +if (!(initsetuid())) + exit(1); + + if ( argc <= 1 ) + { + exit(2); + } + if ( !strcmp(argv[1], "bios") ) + { + safe_system("/usr/bin/biosdecode"); + } + else if ( !strcmp(argv[1], "hdd") ) + { + safe_system("/sbin/hdparm -I /dev/harddisk"); + } + else if ( !strcmp(argv[1], "nic") && (argc == 3) ) + { + snprintf(command, BUFFER_SIZE-1, "/usr/sbin/lspci -nvvvs %s", argv[2]); + safe_system(command); + } + else if ( !strcmp(argv[1], "link") && (argc == 3) ) + { + snprintf(command, BUFFER_SIZE-1, "/usr/sbin/ethtool %s", argv[2]); + safe_system(command); + } +return(0); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |