Skip to content

Commit

Permalink
Fix cli scripts (Cacti#5729)
Browse files Browse the repository at this point in the history
* fix php8 issue - int vs. string compare
fix incorrect variable

* incorrect variable name
  • Loading branch information
xmacan authored and TheWitness committed Apr 15, 2024
1 parent b101413 commit a6accb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/add_device.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
$ip = '';
$poller_id = $config['poller_id'];
$site_id = read_config_option('default_site');
$template_id = read_config_option('default_template');
$template_id = (int) read_config_option('default_template');
$community = read_config_option('snmp_community');
$snmp_ver = read_config_option('snmp_version');
$disable = 0;
Expand Down
9 changes: 7 additions & 2 deletions cli/change_device.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

break;
case '--template':
$overrides['template_id'] = $value;
$overrides['host_template_id'] = $value;

break;
case '--community':
Expand Down Expand Up @@ -321,6 +321,11 @@
/* merge overridden parameters onto host */
$host = array_merge($host, $overrides);

/* exception for IP */
if (isset($overrides['ip'])) {
$host['hostname'] = $overrides['ip'];
}

/* process the various lists into validation arrays */
$host_templates = getHostTemplates();
$hosts = getHostsByDescription();
Expand Down Expand Up @@ -399,7 +404,7 @@
print "Changing device-id: $device_id to {$host['description']} ({$host['hostname']}) as \"{$host_templates[$host['host_template_id']]}\" using SNMP v{$host['snmp_version']} with community \"{$host['snmp_community']}\"\n";
}

$host_id = api_device_save($device_id, $host['host_template_id'], $host['description'], $host['ip'],
$host_id = api_device_save($device_id, $host['host_template_id'], $host['description'], $host['hostname'],
$host['snmp_community'], $host['snmp_version'], $host['snmp_username'], $host['snmp_password'],
$host['snmp_port'], $host['snmp_timeout'], $host['disabled'], $host['availability_method'], $host['ping_method'],
$host['ping_port'], $host['ping_timeout'], $host['ping_retries'], $host['notes'],
Expand Down

0 comments on commit a6accb3

Please sign in to comment.