X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Ffreeside_cacti.php;h=be9ea4e1abf840f4cf7e2133fa6f7ee0bb6d6889;hp=22fb0f0f40c3ef742d1fce4ce13355865d815f50;hb=1f2021c9b76da7cc59e2a981fbac6b24312876d2;hpb=5f4099e52bd894d644c676ea75e1b0cb588393c8 diff --git a/bin/freeside_cacti.php b/bin/freeside_cacti.php index 22fb0f0f4..be9ea4e1a 100755 --- a/bin/freeside_cacti.php +++ b/bin/freeside_cacti.php @@ -31,32 +31,21 @@ if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($ /* We are not talking to the browser */ $no_http_headers = true; -/* -Currently, only drop-device is actually being used by Freeside integration, -but keeping commented out code for potential future development. -*/ - -include(dirname(__FILE__)."/../site/include/global.php"); -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"); -*/ - /* process calling arguments */ $action = ''; $ip = ''; $host_template = ''; -// $delete_graphs = FALSE; +$include_path = "../site/include/"; +$delete_graphs = FALSE; $parms = $_SERVER["argv"]; array_shift($parms); if (sizeof($parms)) { foreach($parms as $parameter) { @list($arg, $value) = @explode("=", $parameter); switch ($arg) { + case "--get-graphs": + $action = 'get-graphs'; + break; case "--drop-device": $action = 'drop-device'; break; @@ -64,21 +53,22 @@ if (sizeof($parms)) { case "--get-device": $action = 'get-device'; break; +*/ case "--get-graph-templates": $action = 'get-graph-templates'; break; -*/ case "--ip": $ip = trim($value); break; case "--host-template": $host_template = trim($value); break; -/* case "--delete-graphs": $delete_graphs = TRUE; break; -*/ + case "--include-path": + $include_path = trim($value); + break; case "--version": case "-V": case "-H": @@ -92,11 +82,24 @@ if (sizeof($parms)) { 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 @@ -120,7 +123,6 @@ case "drop-device": } } } -*/ api_device_remove($host_id); if (host_id($ip,1)) { die("Failed to remove hostname $ip"); @@ -130,6 +132,7 @@ case "drop-device": case "get-device": echo host_id($ip); exit(0); +*/ case "get-graph-templates": if (!$host_template) { die("No host template specified"); @@ -142,7 +145,6 @@ case "get-graph-templates": exit(0); } die("No graph templates associated with this host template"); -*/ default: die("Specified action not found, contact a developer"); }