Exemple #1
0
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage billing
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006 - 2012 Adam Armstrong
 */
chdir(dirname($argv[0]));
// FIXME - implement cli switches, debugging, etc.
require 'includes/defaults.inc.php';
require 'config.php';
require 'includes/definitions.inc.php';
require 'includes/functions.php';
$iter = '0';
rrdtool_initialize();
$poller_start = microtime(true);
echo "Starting Polling Session ... \n\n";
// Wait for schema update, as running during update can break update
$dbVersion = dbFetchCell('SELECT version FROM dbSchema');
if ($dbVersion < 107) {
    logfile("BILLING: Cannot continue until dbSchema update to >= 107 is complete");
    exit(1);
}
foreach (dbFetchRows('SELECT * FROM `bills`') as $bill_data) {
    echo 'Bill : ' . $bill_data['bill_name'] . "\n";
    // replace old bill_gb with bill_quota (we're now storing bytes, not gigabytes)
    if ($bill_data['bill_type'] == 'quota' && !is_numeric($bill_data['bill_quota'])) {
        $bill_data['bill_quota'] = $bill_data['bill_gb'] * $config['billing']['base'] * $config['billing']['base'];
        dbUpdate(array('bill_quota' => $bill_data['bill_quota']), 'bills', '`bill_id` = ?', array($bill_data['bill_id']));
        echo 'Quota -> ' . $bill_data['bill_quota'];
Exemple #2
0
 *   This file is part of LibreNMS.
 *
 * @package    librenms
 * @subpackage graphing
 * @copyright  (C) 2006 - 2012 Adam Armstrong
 */
$start = microtime(true);
if (isset($_GET['debug'])) {
    $debug = true;
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 0);
    ini_set('log_errors', 0);
    ini_set('error_reporting', E_ALL);
} else {
    $debug = false;
    ini_set('display_errors', 0);
    ini_set('display_startup_errors', 0);
    ini_set('log_errors', 0);
    ini_set('error_reporting', 0);
}
$init_modules = array('web', 'graphs');
require realpath(__DIR__ . '/..') . '/includes/init.php';
rrdtool_initialize(false);
require $config['install_dir'] . '/html/includes/graphs/graph.inc.php';
rrdtool_close();
if ($debug) {
    echo '<br />';
    printf("Runtime %.3fs", microtime(true) - $start);
    echo '<br />';
    printStats();
}
Exemple #3
0
/**
 * Generates and pipes a command to rrdtool
 *
 * @internal
 * @param string $command create, update, updatev, graph, graphv, dump, restore, fetch, tune, first, last, lastupdate, info, resize, xport, flushcached
 * @param string $filename The full patth to the rrd file
 * @param string $options rrdtool command options
 * @return array the output of stdout and stderr in an array
 * @throws FileExistsException thrown when a create command is set to rrdtool < 1.4 and the rrd already exists
 * @throws Exception thrown when the rrdtool process(s) cannot be started
 */
function rrdtool($command, $filename, $options)
{
    global $config, $debug, $vdebug, $rrd_async_process, $rrd_sync_process;
    try {
        $cmd = rrdtool_build_command($command, $filename, $options);
    } catch (FileExistsException $e) {
        c_echo('RRD[%g' . $filename . " already exists%n]\n", $debug);
        return array(null, null);
    }
    c_echo("RRD[%g{$cmd}%n]\n", $debug);
    // do not write rrd files, but allow read-only commands
    $ro_commands = array('graph', 'graphv', 'dump', 'fetch', 'first', 'last', 'lastupdate', 'info', 'xport');
    if (!empty($config['norrd']) && !in_array($command, $ro_commands)) {
        c_echo('[%rRRD Disabled%n]');
        return array(null, null);
    }
    // send the command!
    if ($command == 'last' && rrdtool_initialize(false)) {
        // send this to our synchronous process so output is guaranteed
        $output = $rrd_sync_process->sendCommand($cmd);
    } elseif (rrdtool_initialize()) {
        // don't care about the return of other commands, so send them to the faster async process
        $output = $rrd_async_process->sendCommand($cmd);
    } else {
        throw new Exception('rrdtool could not start');
    }
    if ($vdebug) {
        echo 'RRDtool Output: ';
        echo $output[0];
        echo $output[1];
    }
    return $output;
}