From patchwork Fri Sep 29 16:50:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Fischer X-Patchwork-Id: 1430 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 2E12260C99 for ; Fri, 29 Sep 2017 08:50:23 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 2C7211A8C; Fri, 29 Sep 2017 08:50:21 +0200 (CEST) Received: from Devel.localdomain (p5DD83A95.dip0.t-ipconnect.de [93.216.58.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id AC03E1A8C for ; Fri, 29 Sep 2017 08:50:19 +0200 (CEST) From: Matthias Fischer To: development@lists.ipfire.org Subject: [PATCH] squid-graph 3.2: Proxy Graphs rebuilt (V2) Date: Fri, 29 Sep 2017 08:50:15 +0200 Message-Id: <20170929065015.1605-1-matthias.fischer@ipfire.org> X-Mailer: git-send-email 2.14.2 MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This is a rather old fellow. For details see: https://sourceforge.net/projects/squid-graph/ "Squid Graph is a free, simple, yet powerful Squid v2 native logfile analysis tool that generates reports with graphical representation of the proxy server's traffic, somewhat like the popular MRTG tool." I found by chance that the corresponding translation strings were still present, so I thought "Why not?". ;-) Here, it works without problems and 'squid 3.5.27'. The original 'sgraph.cgi' was slightly tuned - like in IPCop - and polished for better readability. If someone likes it, here it is - again... Best, Matthias Signed-off-by: Matthias Fischer --- config/menu/20-status.menu | 10 +++- config/rootfiles/common/squid-graph | 3 ++ config/rootfiles/common/web-user-interface | 1 + html/cgi-bin/sgraph.cgi | 72 ++++++++++++++++++++++++++ lfs/squid-graph | 81 ++++++++++++++++++++++++++++++ make.sh | 1 + src/scripts/makegraphs | 9 +++- 7 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 config/rootfiles/common/squid-graph create mode 100644 html/cgi-bin/sgraph.cgi create mode 100644 lfs/squid-graph diff --git a/config/menu/20-status.menu b/config/menu/20-status.menu index 2bcf0d5e8..dfc6dae9b 100644 --- a/config/menu/20-status.menu +++ b/config/menu/20-status.menu @@ -58,7 +58,15 @@ 'title' => "$Lang::tr{'hardware graphs'}", 'enabled' => 1, }; - $substatus->{'61.entropy'} = { + + $substatus->{'61.proxygraphs'} = { + 'caption' => "$Lang::tr{'ssproxy graphs'}", + 'uri' => '/cgi-bin/sgraph.cgi', + 'title' => "$Lang::tr{'ssproxy graphs'}", + 'enabled' => 1, + }; + + $substatus->{'62.entropy'} = { 'caption' => "$Lang::tr{'entropy'}", 'uri' => '/cgi-bin/entropy.cgi', 'title' => "$Lang::tr{'entropy graphs'}", diff --git a/config/rootfiles/common/squid-graph b/config/rootfiles/common/squid-graph new file mode 100644 index 000000000..0b558d87a --- /dev/null +++ b/config/rootfiles/common/squid-graph @@ -0,0 +1,3 @@ +srv/web/ipfire/html/sgraph +srv/web/ipfire/html/sgraph/logo.png +usr/bin/squid-graph diff --git a/config/rootfiles/common/web-user-interface b/config/rootfiles/common/web-user-interface index f204f1657..b14efb402 100644 --- a/config/rootfiles/common/web-user-interface +++ b/config/rootfiles/common/web-user-interface @@ -72,6 +72,7 @@ srv/web/ipfire/cgi-bin/routing.cgi #srv/web/ipfire/cgi-bin/samba.cgi #srv/web/ipfire/cgi-bin/sambahlp.cgi srv/web/ipfire/cgi-bin/services.cgi +srv/web/ipfire/cgi-bin/sgraph.cgi srv/web/ipfire/cgi-bin/shutdown.cgi srv/web/ipfire/cgi-bin/speed.cgi srv/web/ipfire/cgi-bin/system.cgi diff --git a/html/cgi-bin/sgraph.cgi b/html/cgi-bin/sgraph.cgi new file mode 100644 index 000000000..dea4c068a --- /dev/null +++ b/html/cgi-bin/sgraph.cgi @@ -0,0 +1,72 @@ +#!/usr/bin/perl +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2016 IPFire Team # +# # +# 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 @graphs = (); + +&Header::showhttpheaders(); + +my $dir = "/srv/web/ipfire/html/sgraph"; +my $sgraphdir = "/srv/web/ipfire/html/sgraph"; + +&Header::openpage($Lang::tr{'ssproxy graphs'}, 1, ''); + +&Header::openbigbox('100%', 'left'); + +&Header::openbox('100%', 'left', $Lang::tr{'proxy access graphs'} . ":" ); + +if (open(IPACHTML, "$sgraphdir/index.html")) +{ + my $skip = 1; + while () + { + $skip = 1 if /^
$/; + if ($skip) + { + $skip = 0 if /

/; + next; + } + s/]+)>/Graph/; + s/
/
/g; + s/
/
/g; + s/<([^>]*)>/\L<$1>\E/g; + s/(size|align|border|color)=([^'"> ]+)/$1='$2'/g; + print; + } + close(IPACHTML); +} +else { + print $Lang::tr{'no information available'}; } + +&Header::closebox(); + +&Header::closebigbox(); + +&Header::closepage(); diff --git a/lfs/squid-graph b/lfs/squid-graph new file mode 100644 index 000000000..e94c0c130 --- /dev/null +++ b/lfs/squid-graph @@ -0,0 +1,81 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2015 IPFire Team # +# # +# 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 . # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 3.2 + +THISAPP = squid-graph-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = 89ac122a99dc2db67efbdcd2467b9939 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) + + cp -f $(DIR_SRC)/squid-graph/squid-graph /usr/bin/squid-graph + chmod 755 /usr/bin/squid-graph + + -mkdir -p /srv/web/ipfire/html/sgraph + cp -f $(DIR_SRC)/squid-graph/logo.png /srv/web/ipfire/html/sgraph + + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/make.sh b/make.sh index 815b25aca..eac4b229f 100755 --- a/make.sh +++ b/make.sh @@ -638,6 +638,7 @@ buildipfire() { lfsmake2 snort lfsmake2 oinkmaster lfsmake2 squid + lfsmake2 squid-graph lfsmake2 squidguard lfsmake2 calamaris lfsmake2 tcpdump diff --git a/src/scripts/makegraphs b/src/scripts/makegraphs index 0b56b9325..0191ef70b 100644 --- a/src/scripts/makegraphs +++ b/src/scripts/makegraphs @@ -79,7 +79,7 @@ sub updatehdddata{ print "Error in RRD::create for hdd-".$array[$#array].": $ERROR\n" if $ERROR; } - # Temperaturlesen w�rde die Platte aufwecken!!! + # Temperaturlesen würde die Platte aufwecken!!! if (!$standby){ $temp = 0; my $smart_output = ''; @@ -134,3 +134,10 @@ foreach (@disks){ updatehdddata($disk); } + +### +### Squid Graphs +### +if ( -e "/var/log/squid/access.log" ) { + system ("/usr/bin/squid-graph --no-console-log --tcp-only --output-dir=/srv/web/ipfire/html/sgraph < /var/log/squid/access.log >/dev/null 2>&1"); +}