Associate a Graph Template to an existing Host

It is recommended to maintain graph template associations by maintaining host templates. Each time, a graph template is added to a host template, it will automatically associated with all hosts related to that very host template.

Nevertheless, it is sometimes suitable to manually associate a certain graph template with a single host only without changing any host template. This is, where the script add_graph_template.php comes in. First, let's have a look at the whole list of features it provides. Calling the script with the parameter --help yields

shell>php -q add_graph_template.php --help

Add Graph Template Script 1.0, Copyright 2004-2013 - The Cacti Group

A simple command line utility to associate a graph template with a host in Cacti

usage: add_graph_template.php --host-id=[ID] --graph-template-id=[ID]
    [--quiet]

Required:
    --host-id             the numerical ID of the host
    --graph_template-id   the numerical ID of the graph template to be added

List Options:
    --list-hosts
    --list-graph-templates
    --quiet - batch mode value return

Let's first stick to the listing options

List all Hosts

shell>php -q add_graph_template.php --list-hosts

Known Hosts: (id, hostname, template, description)
1       127.0.0.1       8       Localhost
11      router          3       router.mydomain.com

List all Graph Template

shell>php -q add_graph_template.php --list-graph-templates

Known Graph Templates:(id, name)
2       Interface - Traffic (bits/sec)
3       ucd/net - Available Disk Space
4       ucd/net - CPU Usage
5       Karlnet - Wireless Levels
6       Karlnet - Wireless Transmissions
7       Unix - Ping Latency
8       Unix - Processes
9       Unix - Load Average
10      Unix - Logged in Users
11      ucd/net - Load Average
...

Add a Graph Template

shell>php -q add_graph_template.php --host-id=11 --graph-template-id=7

Success: Graph Template associated for host: (11: router) - graph-template: (7: Unix - Ping Latency)