<?xml version="1.0" encoding="utf-8" ?> <packagegui> <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> <url>/pfstat.php</url> <section>Status</section> </menu> <additional_files_needed> <item>http://www.pfsense.com/packages/config/pfstat.tgz</item> </additional_files_needed> <!-- configpath gets expanded out automatically and config items will be stored in that location --> <configpath>['installedpackages']['pfstat']['config']</configpath> <!-- 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. --> <modify_system> <item> <modifyfilename>/etc/crontab</modifyfilename> <textneeded> */5 * * * * root nice -n 20 /usr/local/bin/pfstat -q >> /var/log/pfstat </textneeded> </item> <item> <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> </item> <item> <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> </item> </modify_system> <!-- 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 --> <adddeleteeditpagefields> <columnitem> <fielddescr>Graph Name</fielddescr> <fieldname>graphname</fieldname> </columnitem> <columnitem> <fielddescr>Description</fielddescr> <fieldname>description</fieldname> </columnitem> </adddeleteeditpagefields> <!-- 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> <combinefieldsend>true</combinefieldsend> <dontdisplayname>true</dontdisplayname> <dontcombinecells>true</dontcombinecells> <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> </field> <field> <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><value>bytes_v4_in</value><name>Bytes in (IPv4)</name></option> <option><value>bytes_v4_out</value><name>Bytes out (IPv4)</name></option> <option><value>bytes_v6_in</value><name>Bytes in (IPv6)</name></option> <option><value>bytes_v6_out</value><name>Bytes out (IPv6)</name></option> <option><value>packets_v4_in_pass</value><name>Packets in passed (IPv4)</name></option> <option><value>packets_v4_in_drop</value><name>Packets in dropped (IPv4)</name></option> <option><value>packets_v4_out_pass</value><name>Packets out passed (IPv4)</name></option> <option><value>packets_v4_out_drop</value><name>Packets out dropped (IPv4)</name></option> <option><value>packets_v6_in_pass</value><name>Packets in passed (IPv6)</name></option> <option><value>packets_v6_in_drop</value><name>Packets in dropped (IPv6)</name></option> <option><value>packets_v6_out_pass</value><name>Packets out passed (IPv6)</name></option> <option><value>packets_v6_out_drop</value><name>Packets out dropped (IPv6)</name></option> <option><value>states_entries</value><name>State table entries</name></option> <option><value>states_searches</value><name>State searches</name></option> <option><value>states_inserts</value><name>State Table Insertions</name></option> <option><value>states_removals</value><name>State Table Removals</name></option> <option><value>counters_match</value><name>Match Counter</name></option> <option><value>counters_badoffset</value><name>Bad Offset Counter</name></option> <option><value>counters_fragment</value><name>Fragment Counter</name></option> <option><value>counters_short</value><name>Short Counter</name></option> <option><value>counters_normalize</value><name>Normalize Counter</name></option> <option><value>counters_memory</value><name>Memory Counter</name></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_command_before_form> 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(); } sync_package_pfstat(); </custom_php_command_before_form> <custom_add_php_command_late> </custom_add_php_command_late> <custom_php_resync_config_command> sync_package_pfstat(); </custom_php_resync_config_command> <custom_php_install_command> system("mkdir -p /usr/local/www/pfstat 2>/dev/null"); system("/usr/bin/killall cron 2>/dev/null"); system("/usr/sbin/cron 2>/dev/null"); </custom_php_install_command> <custom_php_deinstall_command> system("rm /usr/local/etc/pfstat 2>/dev/null"); system("rm -rf /usr/local/www/pfstat* 2>/dev/null"); </custom_php_deinstall_command> <!-- <custom_php_install_command> </custom_php_install_command> --> </packagegui>