Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -5,42 +5,40 @@
*
* This file is part of Observium.
*
* @package observium
* @subpackage scripts
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @package observium
* @subpackage scripts
* @copyright (C) Adam Armstrong
*
*/
chdir(dirname($argv[0]).'/..');
chdir(dirname($argv[0]) . '/..');
$options = getopt("dh:");
include_once("includes/sql-config.inc.php");
include_once("includes/observium.inc.php");
if (empty($options['h']))
{
print "Usage: scripts/rename-port-rrdfile.php -h <device_id|hostname>\n\n";
exit(1);
if (empty($options['h'])) {
print "Usage: scripts/rename-port-rrdfile.php -h <device_id|hostname>\n\n";
exit(1);
}
if (is_numeric($options['h']))
{
$where = "`device_id` = ?";
if (is_numeric($options['h'])) {
$where = "`device_id` = ?";
} else {
$where = "`hostname` = ?";
$where = "`hostname` = ?";
}
$device = dbFetchRow("SELECT * FROM devices WHERE " . $where, array($options['h']));
$device = dbFetchRow("SELECT * FROM devices WHERE " . $where, [$options['h']]);
$ports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ?", array($device['device_id']));
$ports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ?", [$device['device_id']]);
foreach ($ports as $port) {
$old_rrdfile = trim($config['rrd_dir'])."/".trim($device['hostname'])."/port-".$port['ifIndex'].".rrd";
$new_rrdfile = get_port_rrdfilename($device, $port);
$old_rrdfile = trim($config['rrd_dir']) . "/" . trim($device['hostname']) . "/port-" . $port['ifIndex'] . ".rrd";
$new_rrdfile = get_port_rrdfilename($device, $port);
printf("%s -> %s\n", $old_rrdfile, $new_rrdfile);
printf("%s -> %s\n", $old_rrdfile, $new_rrdfile);
rename($old_rrdfile, $new_rrdfile);
rename($old_rrdfile, $new_rrdfile);
}
// EOF