[freeside-commits] branch FREESIDE_4_BRANCH updated. 1658a54e6008907666cc57c5d957fcd208a74a85
Jonathan Prykop
jonathan at 420.am
Tue Nov 24 12:39:39 PST 2015
The branch, FREESIDE_4_BRANCH has been updated
via 1658a54e6008907666cc57c5d957fcd208a74a85 (commit)
via 60cad35f8b6bebefd8c9d78a83d70e0d5ddd68bf (commit)
from 50c42300d50c01f61e6bf9ab74e72b97a6128ec5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1658a54e6008907666cc57c5d957fcd208a74a85
Merge: 60cad35 50c4230
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Tue Nov 24 14:39:18 2015 -0600
Merge branch 'FREESIDE_4_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_4_BRANCH
commit 60cad35f8b6bebefd8c9d78a83d70e0d5ddd68bf
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Tue Nov 24 02:32:41 2015 -0600
RT#38989: Incorrect paths when cacti is installed from source
diff --git a/FS/FS/part_export/cacti.pm b/FS/FS/part_export/cacti.pm
index 7de9794..2e1177f 100644
--- a/FS/FS/part_export/cacti.pm
+++ b/FS/FS/part_export/cacti.pm
@@ -53,6 +53,8 @@ tie my %options, 'Tie::IxHash',
'delete_graphs' => { label => 'Delete associated graphs and data sources when unprovisioning',
type => 'checkbox',
},
+ 'include_path' => { label => 'Path to cacti include dir (relative to script_path)',
+ default => '../site/include/' },
'cacti_graph_template_id' => {
'label' => 'Graph Template',
'type' => 'custom',
@@ -191,6 +193,7 @@ sub _delete_queue {
'hostname' => $svc_broadband->ip_addr,
'script_path' => $self->option('script_path'),
'delete_graphs' => $self->option('delete_graphs'),
+ 'include_path' => $self->option('include_path'),
);
return ($queue,$error);
}
@@ -249,6 +252,8 @@ sub ssh_insert {
. trailslash($opt{'script_path'})
. q(freeside_cacti.php --get-graph-templates --host-template=)
. $opt{'template_id'};
+ $cmd .= q( --include-path=') . $self->option('include_path') . q(')
+ if $self->option('include_path');
my $ginfo = { map { $_ ? ($_ => undef) : () } split(/\n/,ssh_cmd(%opt, 'command' => $cmd)) };
# Add extra config info
@@ -341,6 +346,8 @@ sub ssh_delete {
. q(');
$cmd .= q( --delete-graphs)
if $opt{'delete_graphs'};
+ $cmd .= q( --include-path=') . $opt{'include_path'} . q(')
+ if $opt{'include_path'};
my $response = ssh_cmd(%opt, 'command' => $cmd);
die "Error removing from cacti: " . $response
if $response;
@@ -417,6 +424,8 @@ sub process_graphs {
. q(freeside_cacti.php --get-graphs --ip=')
. $svc->ip_addr
. q(');
+ $cmd .= q( --include-path=') . $self->option('include_path') . q(')
+ if $self->option('include_path');
my @graphs = map { [ split(/\t/,$_) ] }
split(/\n/, ssh_cmd(
'host' => $self->machine,
@@ -498,7 +507,7 @@ sub process_graphs {
}
unlink($thumbfile);
} else {
- $svchtml .= qq(<P STYLE="color: #FF0000">File $thumbfile does not exist, skipping</P>);
+ $svchtml .= qq(<P STYLE="color: #FF0000">Error loading graph: $$graph[0]</P>);
}
$job->update_statustext(49 + int($i / @graphs) * 50);
}
diff --git a/bin/freeside_cacti.php b/bin/freeside_cacti.php
index 9f8e4dd..be9ea4e 100755
--- a/bin/freeside_cacti.php
+++ b/bin/freeside_cacti.php
@@ -31,22 +31,11 @@ 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 and get-graphs 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 = '';
+$include_path = "../site/include/";
$delete_graphs = FALSE;
$parms = $_SERVER["argv"];
array_shift($parms);
@@ -77,6 +66,9 @@ if (sizeof($parms)) {
case "--delete-graphs":
$delete_graphs = TRUE;
break;
+ case "--include-path":
+ $include_path = trim($value);
+ break;
case "--version":
case "-V":
case "-H":
@@ -90,6 +82,17 @@ 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":
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_export/cacti.pm | 11 ++++++++++-
bin/freeside_cacti.php | 27 +++++++++++++++------------
2 files changed, 25 insertions(+), 13 deletions(-)
More information about the freeside-commits
mailing list