#!/usr/bin/php -q 0)) { print "ERROR: Graph Template is already associated for host: ($host_id: $host_name) - graph-template: ($graph_template_id: $graph_template_name)\n"; exit(1); } else { db_execute("replace into host_graph (host_id,graph_template_id) values (" . $host_id . "," . $graph_template_id . ")"); automation_hook_graph_template($host_id, $graph_template_id); api_plugin_hook_function('add_graph_template_to_host', array("host_id" => $host_id, "graph_template_id" => $graph_template_id)); } if (is_error_message()) { print "ERROR: Failed to add this graph template for host: ($host_id: $host_name) - graph-template: ($graph_template_id: $graph_template_name)\n"; exit(1); } else { print "Success: Graph Template associated for host: ($host_id: $host_name) - graph-template: ($graph_template_id: $graph_template_name)\n"; exit(0); } } else { display_help(); exit(0); } /* display_version - displays version information */ function display_version() { $version = get_cacti_cli_version(); print "Cacti Add Graph Template Utility, Version $version, " . COPYRIGHT_YEARS . "\n"; } function display_help() { display_version(); print "\nusage: add_graph_template.php --host-id=[ID] --graph-template-id=[ID]\n"; print " [--quiet]\n\n"; print "Required:\n"; print " --host-id the numerical ID of the host\n"; print " --graph-template-id the numerical ID of the graph template to be added\n\n"; print "List Options:\n"; print " --list-hosts\n"; print " --list-graph-templates\n"; print " --quiet - batch mode value return\n\n"; }