Example #1
0
function graph_export() {
	/* take time to log performance data */
	list($micro,$seconds) = split(" ", microtime());
	$start = $seconds + $micro;

	if (read_config_option("export_timing") != "disabled") {
		if (!file_exists(read_config_option("path_html_export"))) {
			export_fatal(_("Export path does not exist!"));
		}

		switch (read_config_option("export_timing")) {
			case "classic":
				if (read_config_option("path_html_export_ctr") >= read_config_option("path_html_export_skip")) {
					db_execute("update settings set value='1' where name='path_html_export_ctr'");
					$total_graphs_created = config_graph_export();
					config_export_stats($start, $total_graphs_created);
				}elseif (read_config_option("path_html_export_ctr") == "") {
					db_execute("delete from settings where name='path_html_export_ctr' or name='path_html_export_skip'");
					db_execute("insert into settings (name,value) values ('path_html_export_ctr','1')");
					db_execute("insert into settings (name,value) values ('path_html_export_skip','1')");
				}else{
					db_execute("update settings set value='" . (read_config_option("path_html_export_ctr") + 1) . "' where name='path_html_export_ctr'");
				}
				break;
			case "export_hourly":
				$export_minute = read_config_option('export_hourly');
				if (empty($export_minute)) {
					db_execute("insert into settings (name,value) values ('export_hourly','0')");
				}elseif (floor((date('i') / 5)) == floor((read_config_option('export_hourly') / 5))) {
					$total_graphs_created = config_graph_export();
					config_export_stats($start, $total_graphs_created);
				}
				break;
			case "export_daily":
				if (strstr(read_config_option('export_daily'), ':')) {
					$export_daily_time = explode(':', read_config_option('export_daily'));
					if (date('G') == $export_daily_time[0]) {
						if (floor((date('i') / 5)) == floor(($export_daily_time[1] / 5))) {
							$total_graphs_created = config_graph_export();
							config_export_stats($start, $total_graphs_created);
						}
					}
				}else{
					db_execute("insert into settings (name,value) values ('export_daily','00:00')");
				}
				break;
			default:
				export_log(_("Export timing not specified. Updated config to disable exporting."));
				db_execute("insert into settings (name,value) values ('export_timing','disabled')");
		}
	}
}
Example #2
0
function graph_export()
{
    /* take time to log performance data */
    list($micro, $seconds) = split(" ", microtime());
    $start = $seconds + $micro;
    if (read_config_option("export_timing") != "disabled") {
        switch (read_config_option("export_timing")) {
            case "classic":
                if (read_config_option("path_html_export_ctr") >= read_config_option("path_html_export_skip")) {
                    db_execute("UPDATE settings SET value='1' WHERE name='path_html_export_ctr'");
                    $total_graphs_created = config_graph_export();
                    config_export_stats($start, $total_graphs_created);
                } elseif (read_config_option("path_html_export_ctr") == "") {
                    db_execute("DELETE FROM settings WHERE name='path_html_export_ctr' OR name='path_html_export_skip'");
                    db_execute("REPLACE INTO settings (name,value) VALUES ('path_html_export_ctr','1')");
                    db_execute("REPLACE INTO settings (name,value) VALUES ('path_html_export_skip','1')");
                } else {
                    db_execute("update settings set value='" . (read_config_option("path_html_export_ctr") + 1) . "' where name='path_html_export_ctr'");
                }
                break;
            case "export_hourly":
                $export_minute = read_config_option('export_hourly');
                $poller_minute = read_config_option('poller_interval') / 60;
                if (empty($export_minute)) {
                    db_execute("REPLACE INTO settings (name,value) VALUES ('export_hourly','0')");
                } elseif (floor(date('i') / $poller_minute) == floor(read_config_option('export_hourly') / $poller_minute)) {
                    $total_graphs_created = config_graph_export();
                    config_export_stats($start, $total_graphs_created);
                }
                break;
            case "export_daily":
                if (strstr(read_config_option('export_daily'), ':')) {
                    $export_daily_time = explode(':', read_config_option('export_daily'));
                    $poller_minute = read_config_option('poller_interval') / 60;
                    if (date('G') == $export_daily_time[0]) {
                        if (floor(date('i') / $poller_minute) == floor($export_daily_time[1] / $poller_minute)) {
                            $total_graphs_created = config_graph_export();
                            config_export_stats($start, $total_graphs_created);
                        }
                    }
                } else {
                    db_execute("REPLACE INTO settings (name,value) VALUES ('export_daily','00:00')");
                }
                break;
            default:
                export_log("Export timing not specified. Updated config to disable exporting.");
                db_execute("REPLACE INTO settings (name,value) VALUES ('export_timing','disabled')");
        }
    }
}