aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jim@pingle.org>2010-02-03 21:27:55 -0500
committerjim-p <jim@pingle.org>2010-02-03 21:28:58 -0500
commiteb76bc428d6730539e12ef9f90e59e3fc0fbd437 (patch)
treec678526230284eac46f90074daac9ad9a29b899c
parent0e11a661afbff3fb8f61028032ca48b6c7800604 (diff)
downloadpfsense-packages-eb76bc428d6730539e12ef9f90e59e3fc0fbd437.tar.gz
pfsense-packages-eb76bc428d6730539e12ef9f90e59e3fc0fbd437.tar.bz2
pfsense-packages-eb76bc428d6730539e12ef9f90e59e3fc0fbd437.zip
New states summary page/package. Pretty basic to start with.
-rw-r--r--config/states-summary/diag_states_summary.php81
-rw-r--r--config/states-summary/states-summary.xml70
-rwxr-xr-xpkg_config.7.xml11
3 files changed, 162 insertions, 0 deletions
diff --git a/config/states-summary/diag_states_summary.php b/config/states-summary/diag_states_summary.php
new file mode 100644
index 00000000..427888dc
--- /dev/null
+++ b/config/states-summary/diag_states_summary.php
@@ -0,0 +1,81 @@
+<?php
+
+exec("/sbin/pfctl -s state", $states);
+
+$srcipinfo = array();
+
+$row = 0;
+if(count($states) > 0) {
+ foreach($states as $line) {
+ $line_split = preg_split("/\s+/", $line);
+ $type = array_shift($line_split);
+ $proto = array_shift($line_split);
+ $state = array_pop($line_split);
+ $info = implode(" ", $line_split);
+
+ /* break up info and extract $srcip and $dstip */
+ $ends = preg_split("/\<?-\>?/", $info);
+ $parts = split(":", $ends[0]);
+ $srcip = trim($parts[0]);
+ $srcport = trim($parts[1]);
+
+ $parts = split(":", $ends[count($ends) - 1]);
+ $dstip = trim($parts[0]);
+ $dstport = trim($parts[1]);
+
+ $srcipinfo[$srcip]['seen']++;
+ $srcipinfo[$srcip]['protos'][$proto]['seen']++;
+ if (!empty($srcport)) {
+ $srcipinfo[$srcip]['protos'][$proto]['srcports'][$srcport]++;
+ }
+ if (!empty($dstport)) {
+ $srcipinfo[$srcip]['protos'][$proto]['dstports'][$dstport]++;
+ }
+ }
+}
+
+function sort_by_ip($a, $b) {
+ return sprintf("%u", ip2long($a)) < sprintf("%u", ip2long($b)) ? -1 : 1;
+}
+
+$pgtitle = "Diagnostics: State Table Summary";
+require_once("guiconfig.inc");
+include("head.inc");
+include("fbegin.inc");
+?>
+<p class="pgtitle"><?=$pgtitle?></font></p>
+
+<table align="center" width="80%">
+ <tr>
+ <th>IP</th>
+ <th># States</th>
+ <th>Proto</th>
+ <th># States</th>
+ <th>Src Ports</th>
+ <th>Dst Ports</th>
+ </tr>
+<?php uksort($srcipinfo, "sort_by_ip");
+ foreach($srcipinfo as $ip => $ipinfo) { ?>
+ <tr>
+ <td><?php echo $ip; ?></td>
+ <td align="center"><?php echo $ipinfo['seen']; ?></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ </tr>
+ <?php foreach($ipinfo['protos'] as $proto => $protoinfo) { ?>
+ <tr>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ <td><?php echo $proto; ?></td>
+ <td align="center"><?php echo $protoinfo['seen']; ?></td>
+ <td align="center"><?php echo count($protoinfo['srcports']); ?></td>
+ <td align="center"><?php echo count($protoinfo['dstports']); ?></td>
+ </tr>
+ <?php } ?>
+<?php } ?>
+
+</table>
+
+<?php include("fend.inc"); ?>
diff --git a/config/states-summary/states-summary.xml b/config/states-summary/states-summary.xml
new file mode 100644
index 00000000..1f4d7527
--- /dev/null
+++ b/config/states-summary/states-summary.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ states-summary.xml
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2010 to whom it may belong
+ All rights reserved.
+
+ Based on m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>States Summary Page</description>
+ <requirements>None</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>States Summary</name>
+ <version>1.0</version>
+ <title>Diagnostics: States Summart</title>
+ <menu>
+ <name>States Summary</name>
+ <tooltiptext></tooltiptext>
+ <section>Diagnostics</section>
+ <url>/diag_states_summary.php</url>
+ </menu>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/states-summary/diag_states_summary.php</item>
+ </additional_files_needed>
+ <custom_php_deinstall_command>
+ <![CDATA[
+ $version = file_get_contents("/etc/version");
+ if ($version[0] < 2) {
+ unlink_if_exists("/usr/local/www/diag_states_summary.php");
+ }
+ ]]>
+ </custom_php_deinstall_command>
+</packagegui> \ No newline at end of file
diff --git a/pkg_config.7.xml b/pkg_config.7.xml
index 850641fc..bf1871e7 100755
--- a/pkg_config.7.xml
+++ b/pkg_config.7.xml
@@ -962,5 +962,16 @@
<config_file>http://www.pfsense.org/packages/config/openvpn-status/openvpn-status.xml</config_file>
<configurationfile>openvpn-status.xml</configurationfile>
</package>
+ <package>
+ <name>States Summary</name>
+ <descr>States Summary Page</descr>
+ <category>System</category>
+ <version>0.1</version>
+ <status>Beta</status>
+ <maintainer>jimp@pfsense.org</maintainer>
+ <required_version>1.2.3</required_version>
+ <config_file>http://www.pfsense.org/packages/config/states-summary/states-summary.xml</config_file>
+ <configurationfile>states-summary.xml</configurationfile>
+ </package>
</packages>
</pfsensepkgs>