Ad Widget

Collapse

How to use graph linkage?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • liedekef
    Junior Member
    • May 2005
    • 10

    #1

    How to use graph linkage?

    I've created a link between a host and a template. For graphs this seems to result in the adding/deleting of graphs elements of the host when I add graph elements of the template to a graph.
    But this seems to fail: if I create a graph called "test" and add an item from the template to it, I get 2 errors:

    Error in query [select hostid,host,useip,ip,port_status from hosts where hostid=]
    ==> this error seems to be related to the select statement on line 137 in graph.inc.php (version 1.1alpha10): the hostid is empty because there's is no such graph related to the host.

    Second error:
    ERROR EXECUTING: insert into graphs (name,width,height,yaxistype,yaxismin,yaxismax) values ('test',900,200,0,0,0000,100.0000)
    ==> this error is related to line 142 of the same file: since the first query failed, a new graph is being added, but with the same name as the old graph! This of course fails ...

    I tried naming my graph "cpu {hostname}" but this fails also ...

    So any help or a quick howto is very much appreciated.

    Franky
  • liedekef
    Junior Member
    • May 2005
    • 10

    #2
    quick fix

    Ok, I fixed this by adding the following php code to graphs.php:

    in the while-loop of the function add_graph_item_to_templaes():

    (beneath the code for $result2, $row2 lines)
    $sql="select host from hosts where hostid=".$row["hostid"];
    $result3=DBselect($sql);
    $row3=DBfetch($result3);
    $graph["name"]=str_replace('{HOSTNAME}',$row3["host"],$graph["name"]);

    this results in the fact I can now define a graph called "cpu {HOSTNAME}" and when adding an item to it from a linked template, other graphs are created with the hostnames of the hosts linked to the template. Adding and deleting items work fine, updating not (but this is not as important to me)

    Alex, is there any chance this can be in the next cvs version?

    The linking doesn't seem to work for screens yet (no php code defined there for linking yet).

    Franky

    Comment

    Working...