<?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$ */ /* ========================================================================== */ /* authng.xml part of pfSense (http://www.pfSense.com) Copyright (C) 2007 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>Describe your package here</description> <requirements>Describe your package requirements here</requirements> <faq>Currently there are no FAQ items provided.</faq> <name>pfstat</name> <version>1.7</version> <title>Services: PFStat Settings</title> <!-- Menu is where this packages menu will appear --> <menu> <name>PFStat Settings</name> <tooltiptext>pfstat is a small utility that collects packet filter statistics and produces graphs.</tooltiptext> <section>Services</section> <configfile>pfstat.xml</configfile> </menu> <menu> <name>PFStat Graphs</name> <tooltiptext>pfstat is a small utility that collects packet filter statistics and produces graphs.</tooltiptext> <section>Status</section> <url>/pfstat.php</url> </menu> <modify_system> <modifyitem> <modifyfilename>/etc/crontab</modifyfilename> <textneeded> */5 * * * * root nice -n 20 /usr/local/bin/pfstat -q >> /var/log/pfstat </textneeded> </modifyitem> <modifyitem> <modifyfilename>/etc/crontab</modifyfilename> <textneeded> */10 * * * * root nice -n 20 /usr/local/bin/pfstat -c /usr/local/etc/pfstat.conf -d /var/log/pfstat </textneeded> </modifyitem> <modifyitem> <modifyfilename>/etc/crontab</modifyfilename> <textneeded> 1 1 * * 1 root nice -n 20 tail -n 50000 /var/log/pfstat >/tmp/pfstat && mv /tmp/pfstat /var/log/pfstat </textneeded> </modifyitem> </modify_system> <!-- configpath gets expanded out automatically and config items will be stored in that location --> <configpath>['installedpackages']['pfstat']['config']</configpath> <adddeleteeditpagefields> <columnitem> <fielddescr>Graph Name</fielddescr> <fieldname>graphname</fieldname> </columnitem> <columnitem> <fielddescr>Description</fielddescr> <fieldname>description</fieldname> </columnitem> </adddeleteeditpagefields> <additional_files_needed> <prefix>/usr/local/www/</prefix> <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/pfstat.php</item> </additional_files_needed> <!-- modify system will modify a file and make sure the text needed to run the package is in place. The following example edits /etc/crontab and adds the code necessart to invoke the pfstat command every 5 minutes. --> <!-- adddeleteeditpagefields items will appear on the first page where you can add / delete or edit items. An example of this would be the nat page where you add new nat redirects --> <!-- fields gets invoked when the user adds or edits a item. the following items will be parsed and rendered for the user as a gui with input, and selectboxes. --> <fields> <field> <fielddescr>Graph Name</fielddescr> <fieldname>graphname</fieldname> <description>Enter the name of the graph here</description> <type>input</type> </field> <field> <fielddescr>Graph Description</fielddescr> <fieldname>description</fieldname> <description>Enter the description of the graph here</description> <type>input</type> </field> <field> <fielddescr>Image Name</fielddescr> <fieldname>imagename</fieldname> <description>Enter the filename for this image. Must end in .jpg. ex. filename.jpg</description> <type>input</type> </field> <field> <fielddescr>Graph Size Width</fielddescr> <fieldname>graphsizewidth</fieldname> <description>Graph width in pixels. Recommend 960 for large images, 320 for small images.</description> <type>input</type> </field> <field> <fielddescr>Graph Size Height</fielddescr> <fieldname>graphsizeheight</fieldname> <description>Graph height in pixels. Recommend 300 for large images, 200 for small images.</description> <type>input</type> </field> <field> <fielddescr>Update interval</fielddescr> <fieldname>from</fieldname> <description></description> <type>input</type> <size>1</size> <value>1</value> <combinefieldsbegin>true</combinefieldsbegin> </field> <field> <fielddescr>Update interval duration</fielddescr> <fieldname>fromclassification</fieldname> <description></description> <type>select</type> <options> <option><name>Minutes</name><value>minutes</value></option> <option><name>Hours</name><value>hours</value></option> <option><name>Days</name><value>days</value></option> <option><name>Weeks</name><value>weeks</value></option> <option><name>Months</name><value>months</value></option> </options> <combinefieldsend>true</combinefieldsend> <dontdisplayname>true</dontdisplayname> <dontcombinecells>true</dontcombinecells> </field> <field> <fielddescr>none</fielddescr> <fieldname>none</fieldname> <type>rowhelper</type> <rowhelper> <rowhelperfield> <fielddescr>Location</fielddescr> <fieldname>location</fieldname> <description>Location of graph</description> <type>select</type> <options> <option><name>Left</name><value>left</value></option> <option><name>Right</name><value>right</value></option> </options> </rowhelperfield> <rowhelperfield> <fielddescr>Graph Source</fielddescr> <fieldname>counters</fieldname> <description></description> <type>select</type> <options> <option><name>Bytes in (IPv4)</name><value>bytes_v4_in</value></option> <option><name>Bytes out (IPv4)</name><value>bytes_v4_out</value></option> <option><name>Bytes in (IPv6)</name><value>bytes_v6_in</value></option> <option><name>Bytes out (IPv6)</name><value>bytes_v6_out</value></option> <option><name>Packets in passed (IPv4)</name><value>packets_v4_in_pass</value></option> <option><name>Packets in dropped (IPv4)</name><value>packets_v4_in_drop</value></option> <option><name>Packets out passed (IPv4)</name><value>packets_v4_out_pass</value></option> <option><name>Packets out dropped (IPv4)</name><value>packets_v4_out_drop</value></option> <option><name>Packets in passed (IPv6)</name><value>packets_v6_in_pass</value></option> <option><name>Packets in dropped (IPv6)</name><value>packets_v6_in_drop</value></option> <option><name>Packets out passed (IPv6)</name><value>packets_v6_out_pass</value></option> <option><name>Packets out dropped (IPv6)</name><value>packets_v6_out_drop</value></option> <option><name>State table entries</name><value>states_entries</value></option> <option><name>State searches</name><value>states_searches</value></option> <option><name>State Table Insertions</name><value>states_inserts</value></option> <option><name>State Table Removals</name><value>states_removals</value></option> <option><name>Match Counter</name><value>counters_match</value></option> <option><name>Bad Offset Counter</name><value>counters_badoffset</value></option> <option><name>Fragment Counter</name><value>counters_fragment</value></option> <option><name>Short Counter</name><value>counters_short</value></option> <option><name>Normalize Counter</name><value>counters_normalize</value></option> <option><name>Memory Counter</name><value>counters_memory</value></option> </options> </rowhelperfield> <rowhelperfield> <fielddescr>Color</fielddescr> <fieldname>color</fieldname> <description>Color of graph</description> <type>select</type> <options> <option><name>Light Hard Azure</name><value>51 153 255</value></option> <option><name>Light Faded Blue</name><value>102 102 255</value></option> <option><name>Blue</name><value>0 0 255</value></option> <option><name>Dark Dull Red</name><value>153 51 51</value></option> <option><name>Pale Weak Red</name><value>255 204 204</value></option> <option><name>Red</name><value>255 204 204</value></option> <option><name>Pale Weak Red</name><value>255 0 0</value></option> <option><name>Light Hard Pink</name><value>255 51 153</value></option> <option><name>Dark Dull Pink</name><value>153 51 102</value></option> <option><name>Light Faded Red</name><value>255 102 102</value></option> <option><name>Pale Weak Green</name><value>204 255 204</value></option> <option><name>Green</name><value>0 255 0</value></option> <option><name>Pale Weak Yellow</name><value>255 255 204</value></option> <option><name>Yellow</name><value>125 125 0</value></option> <option><name>Purple</name><value>72 00 190</value></option> <option><name>Pale Weak Magenta</name><value>255 204 255</value></option> <option><name>Pale Weak Cyan</name><value>204 255 255</value></option> <option><name>Cyan</name><value>00 120 120</value></option> <option><name>Dark Dull Cyan</name><value>51 153 153</value></option> <option><name>Orange</name><value>255 255 0</value></option> <option><name>Dark Dull Orange</name><value>153 102 51</value></option> <option><name>Pale Dull Orange</name><value>255 204 153</value></option> <option><name>Grey</name><value>125 125 125</value></option> <option><name>Pale Gray</name><value>204 204 204</value></option> <option><name>Black</name><value>0 0 0</value></option> </options> </rowhelperfield> <rowhelperfield> <fielddescr>Appearance</fielddescr> <fieldname>appearance</fieldname> <description>Appearance type</description> <type>select</type> <options> <option><name>Filled</name><value>filled</value></option> <option><name>Unfilled</name><value></value></option> </options> </rowhelperfield> </rowhelper> </field> </fields> <custom_php_global_functions> function sync_package_pfstat() { conf_mount_rw(); config_lock(); global $config; $fout = fopen("/usr/local/etc/pfstat.conf","w"); if($config['installedpackages']['pfstat']['config'] != "") { foreach($config['installedpackages']['pfstat']['config'] as $rowhelper) { $leftgraphtext = ""; $rightgraphtext = ""; $isfirstleft = 0; $isfirstright = 0; $fromclassification = $rowhelper['fromclassification']; $imagename = $rowhelper['imagename']; $pos = strrpos($imagename, ".jpg"); if ($pos === false) { $imagename .= ".jpg"; } $from = $rowhelper['from']; $graphsizewidth = $rowhelper['graphsizewidth']; $graphsizeheight = $rowhelper['graphsizeheight']; foreach($rowhelper['row'] as $row) { if($row['location'] == "left") { if($isfirstleft == 1) $leftgraphtext .= ",\n"; $leftgraphtext .= "graph " . $row['counters'] . " label \"" . $row['counters'] . "\" color " . $row['color'] . " " . $row['appearance']; $isfirstleft = 1; } else { if($isfirstright == 1) $rightgraphtext .= ",\n"; $rightgraphtext .= "graph " . $row['counters'] . " label \"" . $row['counters'] . "\" color " . $row['color'] . " " . $row['appearance']; $isfirstright = 1; } } fwrite($fout, "image \"/usr/local/www/pfstat/" . $imagename ."\" { \n"); if($from == "") $from = "30"; fwrite($fout, "from " . $from . " " . $fromclassification . " to now \n"); fwrite($fout, "width " . $graphsizewidth . " height " . $graphsizeheight . " \n"); if($leftgraphtext != "") { fwrite($fout, " left \n"); fwrite($fout, " " . $leftgraphtext . "\n"); } if($rightgraphtext != "") { fwrite($fout, " right \n"); fwrite($fout, " " . $rightgraphtext . "\n"); } fwrite($fout, "}\n\n"); } } fclose($fout); conf_mount_ro(); config_unlock(); } </custom_php_global_functions> <custom_php_command_before_form> sync_package_pfstat(); </custom_php_command_before_form> <custom_php_resync_config_command> sync_package_pfstat(); </custom_php_resync_config_command> <custom_php_install_command> make_dirs("/usr/local/www/pfstat"); system("/usr/bin/killall cron 2>/dev/null"); system("/usr/sbin/cron 2>/dev/null"); </custom_php_install_command> <custom_php_deinstall_command> unlink_if_exists("/usr/local/etc/pfstat"); rmdir_recursive("/usr/local/www/pfstat"); </custom_php_deinstall_command> </packagegui>