Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2015-11-17 05:14:41 -08:00
#!/usr/bin/env php
<?php
$init_modules = [];
require realpath(__DIR__ . '/..') . '/includes/init.php';
2015-11-17 05:14:41 -08:00
$options = getopt('h:p:');
2021-03-28 17:25:30 -05:00
$hosts = str_replace('*', '%', $options['h']);
$ports = str_replace('*', '%', $options['p']);
2015-11-17 05:14:41 -08:00
if (empty($hosts) && empty($ports)) {
2017-02-07 00:49:16 +00:00
echo "-h <device hostname wildcard> Device(s) to match (all is a valid arg)\n";
echo "-p <ifName widcard> Port(s) to match using ifName (all is a valid arg)\n";
2015-11-17 05:14:41 -08:00
echo "\n";
2017-02-07 00:49:16 +00:00
exit;
}
if ($hosts == 'all') {
$hosts = '';
}
if ($ports == 'all') {
$ports = '';
2015-11-17 05:14:41 -08:00
}
foreach (dbFetchRows('SELECT `device_id`,`hostname` FROM `devices` WHERE `hostname` LIKE ?', ['%' . $hosts . '%']) as $device) {
echo 'Found hostname ' . $device['hostname'] . ".......\n";
2016-06-30 10:09:16 -07:00
foreach (dbFetchRows('SELECT `port_id`,`ifIndex`,`ifName`,`ifSpeed` FROM `ports` WHERE `ifName` LIKE ? AND `device_id` = ?', ['%' . $ports . '%', $device['device_id']]) as $port) {
2015-11-17 05:14:41 -08:00
echo 'Tuning port ' . $port['ifName'] . ".......\n";
2016-08-28 17:32:55 -05:00
$rrdfile = get_port_rrdfile_path($device['hostname'], $port['port_id']);
Rrd::tune('port', $rrdfile, $port['ifSpeed']);
2015-11-17 05:14:41 -08:00
}
}
Rrd::close();