aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/sarg/sarg.inc29
-rwxr-xr-xconfig/sarg/sarg_frame.php9
-rw-r--r--config/sarg/sarg_schedule.xml42
-rw-r--r--pkg_config.8.xml2
-rw-r--r--pkg_config.8.xml.amd642
5 files changed, 79 insertions, 5 deletions
diff --git a/config/sarg/sarg.inc b/config/sarg/sarg.inc
index 0927b164..2560fb76 100644
--- a/config/sarg/sarg.inc
+++ b/config/sarg/sarg.inc
@@ -88,13 +88,34 @@ function run_sarg($id=-1) {
if ($id >= 0 && is_array($config['installedpackages']['sargschedule']['config'])){
$args=$config['installedpackages']['sargschedule']['config'][$id]['args'];
$action=$config['installedpackages']['sargschedule']['config'][$id]['action'];
+ $gzip=$config['installedpackages']['sargschedule']['config'][$id]['gzip'];
+ $find=$config['installedpackages']['sargschedule']['config'][$id]['find'];
+ $gziplevel=$config['installedpackages']['sargschedule']['config'][$id]['gziplevel'];
}
else{
$args=$_POST['args'];
$action=$_POST['action'];
+ $gzip=$_POST['gzip'];
+ $find=$_POST['find'];
+ $gziplevel=$_POST['gziplevel'];
+ }
+ $find=(preg_match("/(\d+)/",$find,$find_matches) ? $find_matches[1] : "60");
+ log_error("Sarg: force refresh now with {$args} args, compress({$gzip}) and {$action} action after sarg finish.");
+ if ($gzip=="on"){
+ #remove old file if exists
+ unlink_if_exists("/root/sarg_run_{$id}.sh");
+ $gzip_script=<<<EOF
+#!/bin/sh
+for a in `/usr/bin/find /usr/local/sarg-reports -cmin -{$find} -type d -mindepth 1 -maxdepth 1`
+do
+echo \$a
+/usr/bin/find \$a -name "*html" | xargs gzip {$gziplevel}
+done
+
+EOF;
+ #create a new file to speedup find search
+ file_put_contents("/root/sarg_run_{$id}.sh",$gzip_script,LOCK_EX);
}
- log_error("Sarg: force refresh now with '".$args."' args and ".$action." action after sarg finish.");
-
mwexec($cmd. " ".$args);
#check if there is a script to run after file save
if (is_array($config['installedpackages']['sarg']))
@@ -127,6 +148,10 @@ function run_sarg($id=-1) {
}
break;
}
+ #check compress option
+ if ($gzip=="on")
+ mwexec_bg("/bin/sh /root/sarg_run_{$id}.sh");
+
#mount filesystem readonly
conf_mount_ro();
}
diff --git a/config/sarg/sarg_frame.php b/config/sarg/sarg_frame.php
index 13235b21..04fb7f30 100755
--- a/config/sarg/sarg_frame.php
+++ b/config/sarg/sarg_frame.php
@@ -40,9 +40,16 @@ else{
$url=($_REQUEST['file'] == ""?"index.html":$_REQUEST['file']);
$dir="/usr/local/sarg-reports";
$rand=rand(100000000000,999999999999);
+$report="";
if (file_exists("{$dir}/{$url}"))
- {
$report=file_get_contents("{$dir}/{$url}");
+else if (file_exists("{$dir}/{$url}.gz")) {
+ $data = gzfile("{$dir}/{$url}.gz");
+ $report = implode($data);
+ unset ($data);
+ }
+if ($report != "" )
+ {
$pattern[0]="/href=\W(\S+html)\W/";
$replace[0]="href=/sarg_frame.php?prevent=".$rand."&file=$prefix/$1";
$pattern[1]='/img src="\S+\W([a-zA-Z0-9.-]+.png)/';
diff --git a/config/sarg/sarg_schedule.xml b/config/sarg/sarg_schedule.xml
index 15527701..4a7309af 100644
--- a/config/sarg/sarg_schedule.xml
+++ b/config/sarg/sarg_schedule.xml
@@ -105,6 +105,10 @@
<fieldname>args</fieldname>
</columnitem>
<columnitem>
+ <fielddescr>Gzip</fielddescr>
+ <fieldname>gzip</fieldname>
+ </columnitem>
+ <columnitem>
<fielddescr>Post Action</fielddescr>
<fieldname>action</fieldname>
</columnitem>
@@ -164,6 +168,44 @@
</options>
<description>Choose an action after sarg finishes</description>
</field>
+ <field>
+ <type>listtopic</type>
+ <fieldname>temp</fieldname>
+ <name>Compress Options</name>
+ </field>
+ <field>
+ <fielddescr>Enable Compression</fielddescr>
+ <fieldname>gzip</fieldname>
+ <description><![CDATA[Enable this option to compress sarg report html files using gzip and reduce 4 times sarg reports data.]]></description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Compression level</fielddescr>
+ <fieldname>gziplevel</fieldname>
+ <type>select</type>
+ <options>
+ <option><name>Default gzip compression (Recommended)</name><value></value></option>
+ <option><name>1 (fast)</name><value>--fast</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 (best)</name><value>--best</value></option>
+ </options>
+ <description>Choose gzip compression level.</description>
+ </field>
+ <field>
+ <fielddescr>Find Limit</fielddescr>
+ <fieldname>find</fieldname>
+ <type>input</type>
+ <default_value>60</default_value>
+ <size>5</size>
+ <description><![CDATA[To speed up find process, restrict find search to report files created/changed n minutes ago.<br>
+ Default is to 60 minutes. If your reports take longer to be created, increase this value.]]></description>
+ </field>
</fields>
<custom_php_install_command>
sarg_php_install_command();
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 5c796620..2f7635d4 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -672,7 +672,7 @@
<depends_on_package>sarg-2.3.2_2.tbz</depends_on_package>
<depends_on_package>gd-2.0.35_7,1.tbz</depends_on_package>
<depends_on_package_pbi>sarg-2.3.2_5-i386.pbi</depends_on_package_pbi>
- <version>2.3.2 pkg v.0.5</version>
+ <version>2.3.2 pkg v.0.6</version>
<status>RC1</status>
<required_version>2.0</required_version>
<configurationfile>sarg.xml</configurationfile>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index 57ee2ca6..77d6546f 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -659,7 +659,7 @@
<depends_on_package>sarg-2.3.2_2.tbz</depends_on_package>
<depends_on_package>gd-2.0.35_7,1.tbz</depends_on_package>
<depends_on_package_pbi>sarg-2.3.2_5-amd64.pbi</depends_on_package_pbi>
- <version>2.3.2 pkg v.0.5</version>
+ <version>2.3.2 pkg v.0.6</version>
<status>RC1</status>
<required_version>2.0</required_version>
<configurationfile>sarg.xml</configurationfile>