die(default_die()); } $include_path = dirname(__FILE__) . '/' . $include_path . '/global.php'; if (!file_exists($include_path)) { die("File " . $include_path . "/global.php not found (check include_path in freeside export config)"); } include $include_path; include_once $config["base_path"] . "/lib/api_device.php"; include_once $config["base_path"] . "/lib/api_automation_tools.php"; include_once $config["base_path"] . "/lib/api_data_source.php"; include_once $config["base_path"] . "/lib/api_graph.php"; include_once $config["base_path"] . "/lib/functions.php"; /* Now take an action */ switch ($action) { case "get-graphs": displayHostGraphs(host_id($ip), TRUE); break; case "drop-device": $host_id = host_id($ip); if ($delete_graphs) { // code copied & pasted from version 0.8.8a // cacti/site/lib/host.php and cacti/site/graphs.php // unfortunately no api function for this yet $graphs = db_fetch_assoc("select\n\t\t\tgraph_local.id as local_graph_id\n\t\t\tfrom graph_local\n\t\t\twhere graph_local.host_id=" . $host_id); if (sizeof($graphs) > 0) { foreach ($graphs as $graph) { $data_sources = array_rekey(db_fetch_assoc("SELECT data_template_data.local_data_id\n\t\t\t\t\tFROM (data_template_rrd, data_template_data, graph_templates_item)\n\t\t\t\t\tWHERE graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\tAND data_template_rrd.local_data_id=data_template_data.local_data_id\n\t\t\t\t\tAND graph_templates_item.local_graph_id=" . $graph["local_graph_id"] . "\n\t\t\t\t\tAND data_template_data.local_data_id > 0"), "local_data_id", "local_data_id"); if (sizeof($data_sources)) { api_data_source_remove_multi($data_sources); } api_graph_remove($graph["local_graph_id"]);
} if ($displayHosts) { $hosts = getHosts(); displayHosts($hosts, $quietMode); exit(1); } if ($displayGraphs) { if (!isset($hostId) || ($hostId === 0) || (!db_fetch_cell("SELECT id FROM host WHERE id=$hostId"))) { echo "ERROR: You must supply a valid host_id before you can list its graphs\n"; echo "Try --list-hosts\n"; display_help(); exit(1); } else { displayHostGraphs($hostId, $quietMode); exit(1); } } if ($displayGraphTemplates) { $graphTemplates = getGraphTemplates(); displayGraphTemplates($graphTemplates, $quietMode); exit(1); } /* verify, that a valid userid is provided */ $userIds = array(); if (isset($userId) && $userId > 0) { /* verify existing user id */