More updates to tune rrdfiles

This commit is contained in:
laf
2015-11-17 05:14:41 -08:00
parent 01435cc4d8
commit 253b27d403
7 changed files with 87 additions and 30 deletions

34
scripts/tune_port.php Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env php
<?php
require 'includes/defaults.inc.php';
require 'config.php';
require 'includes/definitions.inc.php';
require 'includes/functions.php';
$options = getopt('h:p:');
$hosts = $options['h'];
$ports = $options['p'];
if (empty($hosts) && empty($ports)) {
echo "-h <device hostname wildcard> Device(s) to match\n";
echo "-p <ifName widcard> Port(s) to match using ifName\n";
echo "\n";
}
echo "TEST $hosts and $ports\n";
$debug=1;
foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` WHERE `hostname` LIKE ?", array('%'.$hosts.'%')) as $device) {
echo "Found hostname " . $device['hostname'].".......\n";
foreach (dbFetchRows("SELECT `ifIndex`,`ifName`,`ifSpeed` FROM `ports` WHERE `ifName` LIKE ? AND `device_id` = ?", array('%'.$ports.'%',$device['device_id'])) as $port) {
echo "Tuning port " . $port['ifName'].".......\n";
$host_rrd = $config['rrd_dir'].'/'.$device['hostname'];
$rrdfile = $host_rrd.'/port-'.safename($port['ifIndex'].'.rrd');
rrdtool_tune('port',$rrdfile,$port['ifSpeed']);
}
}