readPHPArgv(); $ret = $cg->getopt($args, $short_opts, $long_opts); if (PEAR::isError($ret)) { die('Error in command line: ' . $ret->getMessage() . "\n (try --help)\n"); } $gopts = $ret[0]; if (count($gopts) > 0) { foreach ($gopts as $o) { switch ($o[0]) { case '--debug': $weathermap_debugging = true; break; case '--input': $inputfile = $o[1]; break; case '--output': $outputfile = $o[1]; break; case 'help': default: print "Weathermap DSStats converter. Converts rrd targets to DSStats\n"; print "-------------------------------------------------------------\n"; print "Usage: php convert-to-dstats.php [options]\n\n"; print " --input {filename} - File to read from\n"; print " --output {filename} - File to write to\n"; print " --debug - Enable debugging output\n"; print " --help - Show this message\n"; exit(); } } } if ($inputfile === '' || $outputfile === '') { print "You must specify an input and output file. See --help.\n"; exit(); } $map = new WeatherMap; $map->context = 'cacti'; $map->rrdtool = read_config_option('path_rrdtool'); print 'Reading config from '.$inputfile."\n"; $map->ReadConfig($inputfile); // 'Draw' the map, so that we get dimensions for all the nodes // and offsets for links are calculated. $map->DrawMap(null); // loop through all links // adjust node offsets so that links come from correct side of nodes, and ideally still // from underneath them (e.g. NE80 not NE) $map->WriteConfig($outputfile); print 'Wrote new config to '.$outputfile."\n";