aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/vnstat2/vnstat2.inc56
-rw-r--r--config/vnstat2/vnstat2.xml60
-rw-r--r--config/vnstat2/vnstati.xml64
3 files changed, 178 insertions, 2 deletions
diff --git a/config/vnstat2/vnstat2.inc b/config/vnstat2/vnstat2.inc
index 75c4f9db..26e9acfd 100644
--- a/config/vnstat2/vnstat2.inc
+++ b/config/vnstat2/vnstat2.inc
@@ -24,6 +24,62 @@ function vnstat_install_deinstall() {
configure_cron();
conf_mount_ro();
}
+function change_vnstat_conf(){
+ conf_mount_rw();
+ global $config;
+ $monthrotate = $_POST['monthrotate'];
+
+// ************ Write new vnstat.conf *****************
+
+ $vnstat_conf_file = <<<EOF
+# vnStat 1.10 config file
+##
+
+# location of the database directory
+# DatabaseDir "/usr/local/pkg/vnstat"
+
+# on which day should months change
+MonthRotate $monthrotate
+
+# vnstati
+##
+
+# image colors
+CBackground "F0F0F0"
+CEdge "AEAEAE"
+CHeader "990000"
+CHeaderTitle "F0F0F0"
+CHeaderDate "FFFFFF"
+CText "000000"
+CLine "B0B0B0"
+CLineL "-"
+CRx "666666"
+CTx "990000"
+CRxD "-"
+CTxD "-"
+EOF;
+
+ $hf2 = fopen("/usr/local/etc/vnstat.conf","w");
+ if(!$hf2) {
+ log_error("could not open /usr/local/etc/vnstat.conf for writing");
+ exit;
+ }
+ fwrite($hf2, $vnstat_conf_file);
+ fclose($hf2);
+ conf_mount_ro();
+}
+
+function create_vnstati_image() {
+ conf_mount_rw();
+ global $config;
+ exec("[ ! -d dir ] && mkdir /usr/local/www/vnstati");
+ $iface = $_POST['vnstat_interface'];
+ $iface2 = $_POST['output_type'];
+ $ifaces_final = convert_friendly_interface_to_real_interface_name($iface);
+// exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -". $iface2 ." -o /usr/local/www/vnstati/". $ifaces_final ."-". $iface2 .".png");
+ exec("/usr/local/bin/vnstati -i ". $ifaces_final ." -". $iface2 ." -o /usr/local/www/vnstati/newpicture.png");
+ conf_mount_ro();
+}
function vnstat_install_config() {
global $config;
diff --git a/config/vnstat2/vnstat2.xml b/config/vnstat2/vnstat2.xml
index 2e86c989..27e25ca3 100644
--- a/config/vnstat2/vnstat2.xml
+++ b/config/vnstat2/vnstat2.xml
@@ -8,15 +8,30 @@
<faq>Currently there are no FAQ items provided.</faq>
<name>vnstat2</name>
<version>1.0</version>
- <title>vnstat2</title>
+ <title>Vnstat2</title>
<aftersaveredirect>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</aftersaveredirect>
<include_file>/usr/local/pkg/vnstat2.inc</include_file>
<menu>
<name>vnstat2</name>
<tooltiptext></tooltiptext>
<section>Status</section>
- <url>/vnstat2</url>
+ <url>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</url>
</menu>
+ <tabs>
+ <tab>
+ <text>Config</text>
+ <url>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Vnstati</text>
+ <url>/pkg_edit.php?xml=vnstati.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Access vnstat php frontend</text>
+ <url>/vnstat2</url>
+ </tab>
+ </tabs>
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0644</chmod>
@@ -32,6 +47,47 @@
<chmod>0644</chmod>
<item>http://www.pfsense.com/packages/config/vnstat2/bin/vnstat.conf</item>
</additional_files_needed>
+ <fields>
+ <field>
+ <description>Change rotate day of the month (by default set to 1)</description>
+ <fielddescr>MonthRotate</fielddescr>
+ <fieldname>monthrotate</fieldname>
+ <type>select</type>
+ <size>3</size>
+ <default_value>1</default_value>
+ <options>
+ <option><name>1</name><value>1</value></option>
+ <option><name>2</name><value>2</value></option>
+ <option><name>3</name><value>3</value></option>
+ <option><name>4</name><value>4</value></option>
+ <option><name>5</name><value>5</value></option>
+ <option><name>6</name><value>6</value></option>
+ <option><name>7</name><value>7</value></option>
+ <option><name>8</name><value>8</value></option>
+ <option><name>9</name><value>9</value></option>
+ <option><name>10</name><value>10</value></option>
+ <option><name>11</name><value>11</value></option>
+ <option><name>12</name><value>12</value></option>
+ <option><name>13</name><value>13</value></option>
+ <option><name>14</name><value>14</value></option>
+ <option><name>15</name><value>15</value></option>
+ <option><name>16</name><value>16</value></option>
+ <option><name>17</name><value>17</value></option>
+ <option><name>18</name><value>18</value></option>
+ <option><name>19</name><value>19</value></option>
+ <option><name>20</name><value>20</value></option>
+ <option><name>21</name><value>21</value></option>
+ <option><name>22</name><value>22</value></option>
+ <option><name>23</name><value>23</value></option>
+ <option><name>24</name><value>24</value></option>
+ <option><name>25</name><value>25</value></option>
+ <option><name>26</name><value>26</value></option>
+ <option><name>27</name><value>27</value></option>
+ <option><name>28</name><value>28</value></option>
+ </options>
+ </field>
+ </fields>
+ <custom_add_php_command>change_vnstat_conf();</custom_add_php_command>
<custom_php_resync_config_command></custom_php_resync_config_command>
<custom_php_install_command>vnstat_install_config();</custom_php_install_command>
<custom_php_deinstall_command>vnstat_install_deinstall();</custom_php_deinstall_command>
diff --git a/config/vnstat2/vnstati.xml b/config/vnstat2/vnstati.xml
new file mode 100644
index 00000000..6e779fe6
--- /dev/null
+++ b/config/vnstat2/vnstati.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright></copyright>
+ <description>Describe your package here</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>vnstat2</name>
+ <version>1.0</version>
+ <title>Vnstat2</title>
+ <aftersaveredirect>/vnstati/newpicture.png</aftersaveredirect>
+ <include_file>/usr/local/pkg/vnstat2.inc</include_file>
+ <menu>
+ <name>vnstat2</name>
+ <tooltiptext></tooltiptext>
+ <section>Status</section>
+ <url>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</url>
+ </menu>
+ <tabs>
+ <tab>
+ <text>Config</text>
+ <url>/pkg_edit.php?xml=vnstat2.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Vnstati</text>
+ <url>/pkg_edit.php?xml=vnstati.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Access vnstat php frontend</text>
+ <url>/vnstat2</url>
+ </tab>
+ </tabs>
+ <fields>
+ <field>
+ <fielddescr>Interface</fielddescr>
+ <fieldname>vnstat_interface</fieldname>
+ <description>Select interface</description>
+ <type>interfaces_selection</type>
+ </field>
+ <field>
+ <description>Select output type</description>
+ <fielddescr>Output Type</fielddescr>
+ <fieldname>output_type</fieldname>
+ <type>select</type>
+ <size>7</size>
+ <options>
+ <option><name>Output traffic for the last 24 hours</name><value>h</value></option>
+ <option><name>Output traffic for days</name><value>d</value></option>
+ <option><name>Output traffic for months</name><value>m</value></option>
+ <option><name>Output traffic summary</name><value>s</value></option>
+ <option><name>Output traffic summary including hourly data using a vertical layout</name><value>vs</value></option>
+ <option><name>Output traffic summary including hourly data using a horizontal layout</name><value>hs</value></option>
+ <option><name>Output all time top10 traffic days</name><value>t</value></option>
+ </options>
+ </field>
+ </fields>
+ <custom_php_global_functions></custom_php_global_functions>
+ <custom_add_php_command>create_vnstati_image();</custom_add_php_command>
+ <custom_php_resync_config_command></custom_php_resync_config_command>
+ <custom_php_install_command>vnstat_install_config();</custom_php_install_command>
+ <custom_php_deinstall_command>vnstat_install_deinstall();</custom_php_deinstall_command>
+</packagegui>