Revision 1e3c94dd
Added by Seth Mos almost 14 years ago
etc/inc/upgrade_config.inc | ||
---|---|---|
1936 | 1936 |
|
1937 | 1937 |
$rrddbpath = "/var/db/rrd/"; |
1938 | 1938 |
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool"; |
1939 |
|
|
1939 | 1940 |
if ($g['platform'] != "pfSense") { |
1940 | 1941 |
/* restore the databases, if we have one */ |
1941 | 1942 |
if (file_exists("{$g['cf_conf_path']}/rrd.tgz")) { |
1942 |
exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn); $rrdrestore = implode(" ", $rrdrestore); |
|
1943 |
exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn); |
|
1944 |
$rrdrestore = implode(" ", $rrdrestore); |
|
1943 | 1945 |
if($rrdreturn <> 0) { |
1944 | 1946 |
log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n"); |
1945 | 1947 |
} |
... | ... | |
1979 | 1981 |
mwexec("$rrdtool tune {$rrddbpath}{$database} -r roundtrip:delay 2>&1"); |
1980 | 1982 |
|
1981 | 1983 |
dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}"); |
1982 |
$rrdoldxml = file_get_contents("{$g['tmp_path']}/{$xmldump}"); |
|
1983 |
$rrdold = xml2array($rrdoldxml, 1, "tag"); |
|
1984 |
$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag"); |
|
1984 | 1985 |
$rrdold = $rrdold['rrd']; |
1985 | 1986 |
|
1986 | 1987 |
$i = 0; |
... | ... | |
1994 | 1995 |
$i++; |
1995 | 1996 |
} |
1996 | 1997 |
|
1997 |
$rrdxml = dump_xml_config_raw($rrdold, "rrd"); |
|
1998 |
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", $rrdxml); |
|
1998 |
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw($rrdold, "rrd")); |
|
1999 | 1999 |
mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1"); |
2000 |
|
|
2000 |
|
|
2001 |
unset($rrdold); |
|
2002 |
unset($rrdxmlarray); |
|
2001 | 2003 |
} |
2002 | 2004 |
/* let apinger recreate required files */ |
2003 | 2005 |
setup_gateways_monitor(); |
... | ... | |
2036 | 2038 |
/* create temporary xml from new RRD */ |
2037 | 2039 |
dump_rrd_to_xml("{$g['tmp_path']}/{$databasetmp}", "{$g['tmp_path']}/{$xmldumptmp}"); |
2038 | 2040 |
|
2039 |
$rrdoldxml = file_get_contents("{$g['tmp_path']}/{$xmldump}"); |
|
2040 |
$rrdold = xml2array($rrdoldxml, 1, "tag"); |
|
2041 |
$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag"); |
|
2041 | 2042 |
$rrdold = $rrdold['rrd']; |
2042 | 2043 |
|
2043 |
$rrdnewxml = file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"); |
|
2044 |
$rrdnew = xml2array($rrdnewxml, 1, "tag"); |
|
2044 |
$rrdnew = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"), 1, "tag"); |
|
2045 | 2045 |
$rrdnew = $rrdnew['rrd']; |
2046 | 2046 |
|
2047 | 2047 |
/* remove any MAX RRA's. Not needed for traffic. */ |
... | ... | |
2054 | 2054 |
} |
2055 | 2055 |
|
2056 | 2056 |
$rrdxmlarray = migrate_rrd_format($rrdold, $rrdnew); |
2057 |
$rrdxml = dump_xml_config_raw($rrdxmlarray, "rrd"); |
|
2058 |
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", $rrdxml); |
|
2057 |
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw($rrdxmlarray, "rrd")); |
|
2059 | 2058 |
mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1"); |
2059 |
unset($rrdold); |
|
2060 |
unset($rrdnew); |
|
2061 |
unset($rrdxmlarray); |
|
2060 | 2062 |
|
2061 | 2063 |
} |
2062 | 2064 |
enable_rrd_graphing(); |
Also available in: Unified diff
Modify code to remove memory usage to prevent a Out of Memory condition when upgrading the RRD database on a 128MB system.
Ticket #1758