summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-04-17 21:08:15 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-04-17 21:08:15 +0000
commit6613a0317bd3c37dd0e8e46d9a23e82b9881b296 (patch)
treee3fa3253f18d014c5e7c3e843668a2735cf0c9f2 /etc
parent83df670bdcd40db8c1180f7947e2957a2ed669f2 (diff)
downloadpfsense-6613a0317bd3c37dd0e8e46d9a23e82b9881b296.zip
pfsense-6613a0317bd3c37dd0e8e46d9a23e82b9881b296.tar.gz
MFC 11519
Restore RRD files from tgz on boot. If this works on the first attempt I'm a code monkey. MFC: Soon, needs testing.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc43
1 files changed, 27 insertions, 16 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index caafd06..aceac63 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -1831,6 +1831,7 @@ function enable_rrd_graphing()
$rrdtool = "/usr/local/bin/rrdtool";
$netstat = "/usr/bin/netstat";
$awk = "/usr/bin/awk";
+ $tar = "/usr/bin/tar";
$php = "/usr/local/bin/php";
$spamd_gather = "/usr/local/bin/spamd_gather_stats.php";
@@ -1858,18 +1859,28 @@ function enable_rrd_graphing()
/* create directory if needed */
safe_mkdir("$rrddbpath", 0755);
- /* if we are on livecd or embedded use a memoryfs. */
- /* 3MB is enough for everyone. *cough* */
- if($g['platform'] != "pfSense") {
- /* determine highest MD device */
- $mdnr = `mount |grep md | awk -F"md" '{print $2}'|tail -1 |cut -c 1`;
- $mdnr = $mdnr +1;
- system("/sbin/mdmfs -M -s 3m md$mdnr $rrddbpath");
- }
+ if($g['booting']) {
+ /* if we are on livecd or embedded use a memoryfs. */
+ /* 3MB is enough for everyone. *cough* */
+ if($g['platform'] != "pfSense") {
+ /* determine highest MD device */
+ $mdnr = `mount |grep md | awk -F"md" '{print $2}'|tail -1 |cut -c 1`;
+ $mdnr = $mdnr +1;
+ system("/sbin/mdmfs -M -s 3m md$mdnr $rrddbpath");
+ }
+ /* we now have something to write "on", restore the databases if we have them */
+ if(file_exists("{$g['cf_conf_path']}/rrd.tgz")) {
+ exec("cd /;/usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz", $rrdrestore, $rrdreturn);
+ if($rrdrestore != 0) {
+ log_error("RRD restore failed exited with $rrdreturn, the
+ error is: $rrdrestore[0]\n");
+ }
+ }
- /* create symlink if needed */
- if(!is_link("$rrdgraphpath")) {
- exec("ln -s $rrddbpath $rrdgraphpath");
+ /* create symlink if needed */
+ if(!is_link("$rrdgraphpath")) {
+ exec("ln -s $rrddbpath $rrdgraphpath");
+ }
}
/* db update script */
@@ -1929,7 +1940,7 @@ function enable_rrd_graphing()
$rrdcreatel = exec("$rrdcreate 2>&1", $rrdcreateoutput, $rrdcreatereturn);
if($rrdcreatereturn != 0) {
- log_error("RRD create failed exited with $graphcmdreturn, the
+ log_error("RRD create failed exited with $rrdcreatereturn, the
error is: $rrdcreateoutput[0]\n");
}
}
@@ -1958,7 +1969,7 @@ function enable_rrd_graphing()
$rrdcreatel = exec("$rrdcreate 2>&1", $rrdcreateoutput, $rrdcreatereturn);
if($rrdcreatereturn != 0) {
- log_error("RRD create failed exited with $graphcmdreturn, the
+ log_error("RRD create failed exited with $rrdcreatereturn, the
error is: $rrdcreateoutput[0]\n");
}
}
@@ -1995,7 +2006,7 @@ function enable_rrd_graphing()
$rrdcreatel = exec("$rrdcreate 2>&1", $rrdcreateoutput, $rrdcreatereturn);
if($rrdcreatereturn != 0) {
- log_error("RRD create failed exited with $graphcmdreturn, the
+ log_error("RRD create failed exited with $rrdcreatereturn, the
error is: $rrdcreateoutput[0]\n");
}
}
@@ -2039,7 +2050,7 @@ function enable_rrd_graphing()
$rrdcreatel = exec("$rrdcreate 2>&1", $rrdcreateoutput, $rrdcreatereturn);
if($rrdcreatereturn != 0) {
- log_error("RRD create failed exited with $graphcmdreturn, the
+ log_error("RRD create failed exited with $rrdcreatereturn, the
error is: $rrdcreateoutput[0]\n");
}
}
@@ -2094,7 +2105,7 @@ function enable_rrd_graphing()
$rrdcreatel = exec("$rrdcreate 2>&1", $rrdcreateoutput, $rrdcreatereturn);
if($rrdcreatereturn != 0) {
- log_error("RRD create failed exited with $graphcmdreturn, the
+ log_error("RRD create failed exited with $rrdcreatereturn, the
error is: $rrdcreateoutput[0]\n");
}
}
OpenPOWER on IntegriCloud