Project

General

Profile

« Previous | Next » 

Revision 2159494f

Added by Ermal LUÇI over 12 years ago

Sprinkle some unset to reduce footprint

View differences:

etc/inc/rrd.inc
57 57
	$rrdreturn = "";
58 58
	if (file_exists("{$g['cf_conf_path']}/rrd.tgz")) {
59 59
		foreach (glob("{$rrddbpath}/*.xml") as $xml_file) {
60
			unlink($xml_file);
60
			@unlink($xml_file);
61 61
		}
62
		exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn);
62
		$_gb = exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/rrd.tgz 2>&1", $rrdrestore, $rrdreturn);
63 63
		$rrdrestore = implode(" ", $rrdrestore);
64 64
		if($rrdreturn != 0) {
65 65
			log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n");
66 66
		}
67
		unset($rrdrestore);
67 68
		foreach (glob("{$rrddbpath}/*.xml") as $xml_file) {
68 69
			$rrd_file = preg_replace('/\.xml$/', ".rrd", $xml_file);
69 70
			if (file_exists("{$rrd_file}")) {
70
				unlink($rrd_file);
71
				@unlink($rrd_file);
71 72
			}
72 73
			$output = array();
73 74
			$status = null;
74
			exec("$rrdtool restore -f '{$xml_file}' '{$rrd_file}'", $output, $status);
75
			$_gb = exec("$rrdtool restore -f '{$xml_file}' '{$rrd_file}'", $output, $status);
75 76
			if ($status) {
76 77
				log_error("rrdtool restore -f '{$xml_file}' '{$rrd_file}' failed returning {$status}.");
77 78
				continue;
78 79
			}
79
			unlink($xml_file);
80
			unset($output);
81
			@unlink($xml_file);
80 82
		}
81 83
		/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
82 84
		if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
......
90 92
function create_new_rrd($rrdcreatecmd) {
91 93
	$rrdcreateoutput = array();
92 94
	$rrdcreatereturn = 0;
93
	exec("$rrdcreatecmd 2>&1", $rrdcreateoutput, $rrdcreatereturn);
95
	$_gb = exec("$rrdcreatecmd 2>&1", $rrdcreateoutput, $rrdcreatereturn);
94 96
	if ($rrdcreatereturn <> 0) {
95 97
		$rrdcreateoutput = implode(" ", $rrdcreateoutput);
96 98
		log_error(sprintf(gettext('RRD create failed exited with %1$s, the error is: %2$s'), $rrdcreatereturn, $rrdcreateoutput));
97 99
	}
100
	unset($rrdcreateoutput);
98 101
	return $rrdcreatereturn;
99 102
}
100 103

  
101 104
function migrate_rrd_format($rrdoldxml, $rrdnewxml) {
102 105
	if(!file_exists("/tmp/rrd_notice_sent.txt")) {
103
		exec("echo 'Converting RRD configuration to new format.  This might take a bit...' | wall");
104
		touch("/tmp/rrd_notice_sent.txt");
106
		$_gb = exec("echo 'Converting RRD configuration to new format.  This might take a bit...' | wall");
107
		@touch("/tmp/rrd_notice_sent.txt");
105 108
	}
106 109
	$numrraold = count($rrdoldxml['rra']);
107
	$numdsold = count($rrdoldxml['ds']);
108 110
	$numrranew = count($rrdnewxml['rra']);
111
	$numdsold = count($rrdoldxml['ds']);
109 112
	$numdsnew = count($rrdnewxml['ds']);
110 113
	log_error(sprintf(gettext('Import RRD has %1$s DS values and %2$s RRA databases, new format RRD has %3$s DS values and %4$s RRA databases'), $numdsold, $numrraold, $numdsnew ,$numrranew));
111 114

  

Also available in: Unified diff