diff options
author | smos <seth.mos@dds.nl> | 2011-10-18 10:38:50 +0200 |
---|---|---|
committer | smos <seth.mos@dds.nl> | 2011-10-18 10:41:02 +0200 |
commit | 1e3c94ddac61d1a1063c162bbcaac4f308a8b474 (patch) | |
tree | c98c56a5369355755e3d03e5589c0d77108aefb6 /etc/inc | |
parent | ebcd13cac1f5d83f7352016c9bc750adfd6e21fa (diff) | |
download | pfsense-1e3c94ddac61d1a1063c162bbcaac4f308a8b474.zip pfsense-1e3c94ddac61d1a1063c162bbcaac4f308a8b474.tar.gz |
Modify code to remove memory usage to prevent a Out of Memory condition when upgrading the RRD database on a 128MB system.
Ticket #1758
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/upgrade_config.inc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index d42f92e..a6af29e 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -1936,10 +1936,12 @@ function upgrade_054_to_055() { $rrddbpath = "/var/db/rrd/"; $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool"; + if ($g['platform'] != "pfSense") { /* restore the databases, if we have one */ if (file_exists("{$g['cf_conf_path']}/rrd.tgz")) { - exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn); $rrdrestore = implode(" ", $rrdrestore); + exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn); + $rrdrestore = implode(" ", $rrdrestore); if($rrdreturn <> 0) { log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n"); } @@ -1979,8 +1981,7 @@ function upgrade_054_to_055() { mwexec("$rrdtool tune {$rrddbpath}{$database} -r roundtrip:delay 2>&1"); dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}"); - $rrdoldxml = file_get_contents("{$g['tmp_path']}/{$xmldump}"); - $rrdold = xml2array($rrdoldxml, 1, "tag"); + $rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag"); $rrdold = $rrdold['rrd']; $i = 0; @@ -1994,10 +1995,11 @@ function upgrade_054_to_055() { $i++; } - $rrdxml = dump_xml_config_raw($rrdold, "rrd"); - file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", $rrdxml); + file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw($rrdold, "rrd")); mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1"); - + + unset($rrdold); + unset($rrdxmlarray); } /* let apinger recreate required files */ setup_gateways_monitor(); @@ -2036,12 +2038,10 @@ function upgrade_054_to_055() { /* create temporary xml from new RRD */ dump_rrd_to_xml("{$g['tmp_path']}/{$databasetmp}", "{$g['tmp_path']}/{$xmldumptmp}"); - $rrdoldxml = file_get_contents("{$g['tmp_path']}/{$xmldump}"); - $rrdold = xml2array($rrdoldxml, 1, "tag"); + $rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag"); $rrdold = $rrdold['rrd']; - $rrdnewxml = file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"); - $rrdnew = xml2array($rrdnewxml, 1, "tag"); + $rrdnew = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"), 1, "tag"); $rrdnew = $rrdnew['rrd']; /* remove any MAX RRA's. Not needed for traffic. */ @@ -2054,9 +2054,11 @@ function upgrade_054_to_055() { } $rrdxmlarray = migrate_rrd_format($rrdold, $rrdnew); - $rrdxml = dump_xml_config_raw($rrdxmlarray, "rrd"); - file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", $rrdxml); + file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw($rrdxmlarray, "rrd")); mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1"); + unset($rrdold); + unset($rrdnew); + unset($rrdxmlarray); } enable_rrd_graphing(); |