2015-11-17 05:14:41 -08:00
#!/usr/bin/env php
< ? php
2016-09-14 10:53:04 -05:00
chdir ( realpath ( __DIR__ . '/..' )); // cwd to the parent directory of this script
2015-11-17 05:14:41 -08:00
require 'includes/defaults.inc.php' ;
require 'config.php' ;
require 'includes/definitions.inc.php' ;
require 'includes/functions.php' ;
2016-09-05 07:26:38 +10:00
rrdtool_initialize ();
2015-11-17 05:14:41 -08:00
$options = getopt ( 'h:p:' );
2015-11-18 21:52:32 +00:00
$hosts = str_replace ( '*' , '%' , mres ( $options [ 'h' ]));
$ports = str_replace ( '*' , '%' , mres ( $options [ 'p' ]));
2015-11-17 05:14:41 -08:00
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 " ;
}
foreach ( dbFetchRows ( " SELECT `device_id`,`hostname` FROM `devices` WHERE `hostname` LIKE ? " , array ( '%' . $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` = ? " , array ( '%' . $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' ]);
rrdtool_tune ( 'port' , $rrdfile , $port [ 'ifSpeed' ]);
2015-11-17 05:14:41 -08:00
}
}
2016-09-14 10:53:04 -05:00
rrdtool_close ();