Small Patch for host_update_template.php

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

Post Reply
henkwiedig
Posts: 8
Joined: Thu Aug 06, 2009 1:32 pm
Location: Germany

Small Patch for host_update_template.php

Post by henkwiedig »

Code: Select all

--- cli/host_update_template.php_orig   2010-01-21 11:49:19.000000000 +0100
+++ cli/host_update_template.php        2010-01-21 11:49:49.000000000 +0100
@@ -51,6 +51,7 @@
 $debug    = FALSE;
 $template = "";
 $hostid   = "";
+$change = FALSE;

 foreach($parms as $parameter) {
        @list($arg, $value) = @explode("=", $parameter);
@@ -65,6 +66,9 @@
        case "--list-host-templates":
                displayHostTemplates(getHostTemplates());
                exit(0);
+       case "-c":
+               $change = TRUE;
+               break;
        case "-d":
                $debug = TRUE;
                break;
@@ -109,6 +113,11 @@

 /* verify that the host template is accurate */
 if (db_fetch_cell("SELECT id FROM host_template WHERE id=$template") > 0) {
+
+       if ($change) {
+               print "Changing host template for host ".$host_id." to ".$template."\n";
+               db_execute("update host set host_template_id='$template' where id = '$host_id'");
+       }
        $hosts = db_fetch_assoc("SELECT * FROM host $sql_where");

        if (sizeof($hosts)) {
@@ -150,10 +159,11 @@
 /*     display_help - displays the usage of the function */
 function display_help () {
 print "Cacti Retemplate Host Script 1.0, Copyright 2004-2009 - The Cacti Group\n";
-       print "usage: host_update_template.php -host-id=[host-id|All] [--host-template=[ID]] [-d] [-h] [--help] [-v] [--version]\n\n";
+       print "usage: host_update_template.php --host-id=[host-id|All] [--host-template=[ID]] [-c] [-d] [-h] [--help] [-v] [--version]\n\n";
        print "--host-id=host_id  - The host_id to have templates reapplied 'all' to do all hosts\n";
        print "--host-template=ID - Which Host Template to Refresh\n\n";
        print "Optional:\n";
+       print "-c            - As well change the Host Template\n";
        print "-d            - Display verbose output during execution\n";
        print "-v --version  - Display this help message\n";
        print "-h --help     - Display this help message\n";
Graphing a whole lot of Siebel stuff !
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Please submit your patch to the bug system: http://www.cacti.net/bugs.php
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I'm quite sure, that the new cli already copes with that; I've almost rewritten the whole stuff. Nevertheless, a feature request via mantis is fine.
R.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

The new cli script is called device_template_update.php and will be available with Cacti 088.
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest