Download | Plain Text | Line Numbers
--- cacti.old/host.php 2012-04-23 04:00:14.000000000 +0200
+++ cacti/host.php 2012-08-28 18:29:25.000000000 +0200
@@ -41,7 +41,8 @@
3 => "Disable",
4 => "Change SNMP Options",
5 => "Clear Statistics",
- 6 => "Change Availability Options"
+ 6 => "Change Availability Options",
+ 7 => "Reapply Host Template"
);
$device_actions = api_plugin_hook_function('device_action_array', $device_actions);
@@ -249,6 +250,32 @@
push_out_host($selected_items[$i]);
}
+ }elseif ($_POST["drp_action"] == "7") { /* Reapply Host Template */
+ for ($i=0; $i<count($selected_items); $i++) {
+ /* ================= input validation ================= */
+ input_validate_input_number($selected_items[$i]);
+ /* ==================================================== */
+
+ $host_template_id = db_fetch_cell("select host_template_id from host where id=$selected_items[$i]");
+ $snmp_queries = db_fetch_assoc("select snmp_query_id from host_template_snmp_query where host_template_id=$host_template_id");
+
+ if (sizeof($snmp_queries) > 0) {
+ foreach ($snmp_queries as $snmp_query) {
+ db_execute("replace into host_snmp_query (host_id,snmp_query_id,reindex_method) values ($selected_items[$i]," . $snmp_query["snmp_query_id"] . "," . DATA_QUERY_AUTOINDEX_BACKWARDS_UPTIME . ")");
+
+ /* recache snmp data */
+ run_data_query($selected_items[$i], $snmp_query["snmp_query_id"]);
+ }
+ }
+
+ $graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id=$host_template_id");
+
+ if (sizeof($graph_templates) > 0) {
+ foreach ($graph_templates as $graph_template) {
+ db_execute("replace into host_graph (host_id,graph_template_id) values ($selected_items[$i]," . $graph_template["graph_template_id"] . ")");
+ }
+ }
+ }
}elseif ($_POST["drp_action"] == "1") { /* delete */
if (!isset($_POST["delete_type"])) { $_POST["delete_type"] = 2; }
@@ -440,6 +467,14 @@
<p><ul>" . $host_list . "</ul></p>
</td>
</tr>";
+ $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Clear Statistics on Device(s)'>";
+ }elseif ($_POST["drp_action"] == "7") { /* Reapply Host Template */
+ print " <tr>
+ <td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
+ <p>To reapply Host Template for the following devices, press the \"yes\" button below.</p>
+ <p><ul>" . $host_list . "</ul></p>
+ </td>
+ </tr>";
$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Clear Statistics on Device(s)'>";
}elseif ($_POST["drp_action"] == "1") { /* delete */
print " <tr>