New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create more than one graph with add_graphs.php from one template #2202
Comments
I think that is related to issue #2201 |
So, on a CG graph, the only check performed is the following: $existsAlready = db_fetch_cell_prepared('SELECT id
FROM graph_local
WHERE graph_template_id = ?
AND host_id = ?', array($template_id, $host_id)); So, if you have already used the graph template on that host, it prevents you from using it again. You can use the --force option to bypass this on a 'cg' add, though I do wonder if we should be patching it to check the multiple column of the template using something like: diff --git a/cli/add_graphs.php b/cli/add_graphs.php
index 9a16891b..c966a577 100644
--- a/cli/add_graphs.php
+++ b/cli/add_graphs.php
@@ -550,10 +550,13 @@ if (cacti_sizeof($parms)) {
$returnArray = array();
if ($graph_type == 'cg') {
- $existsAlready = db_fetch_cell_prepared('SELECT id
- FROM graph_local
+ $existsAlready = db_fetch_cell_prepared('SELECT gl.id
+ FROM graph_local gl
+ INNER JOIN graph_templates gt on gt.id = gl.graph_template_id
WHERE graph_template_id = ?
- AND host_id = ?', array($template_id, $host_id));
+ AND host_id = ?
+ AND multiple = \'\'',
+ array($template_id, $host_id));
if ((isset($existsAlready)) &&
($existsAlready > 0) &&
@@ -646,12 +649,14 @@ if (cacti_sizeof($parms)) {
foreach ($snmp_indexes as $snmp_index) {
$snmp_query_array['snmp_index'] = $snmp_index['snmp_index'];
- $existsAlready = db_fetch_cell_prepared('SELECT id
- FROM graph_local
+ $existsAlready = db_fetch_cell_prepared('SELECT gl.id
+ FROM graph_local gl
+ INNER JOIN graph_templates on gt.id = gl.graph_template_id
WHERE graph_template_id = ?
AND host_id = ?
AND snmp_query_id = ?
- AND snmp_index = ?',
+ AND snmp_index = ?
+ AND multiple = \'\'',
array($template_id, $host_id, $dsGraph['snmpQueryId'], $snmp_query_array['snmp_index']));
if (isset($existsAlready) && $existsAlready > 0) { |
Ok, thats fine for me. |
I have now made the above change to the 1.2 dev code. |
Hi,
i'm using cacti 1.1.38
i create a graph from commandline with add_graps.php:
php add_graphs.php --graph-type=cg --graph-template-id=138 --host-id=14 --graph-title="A/T WLS JMS Queue: JMS_EILOG" --input-fields="117:queuename=JMS_EILOG"
when i try to create a second graph from the same template ( multiple instances is set to true) it fails with this error on commandline:
in the webinterface i can create hundreds of graphs on the same host of this template with different settings for input field "queuename"
The text was updated successfully, but these errors were encountered: