Exemple #1
0
function dbGetConfirmLock($sName, $iDuration = null, $pdo = null)
{
    $pdo = is_null($pdo) ? FlexiModelUtil::getInstance()->getXPDO() : $pdo;
    $iDuration = empty($iDuration) ? 60 : (int) $iDuration;
    $oRow = dbFetchOne("select IS_FREE_LOCK(:name) as isfree;", array(":name" => $sName));
    if ($oRow["isfree"] == 1) {
        dbGetLock($sName, $iDuration, $pdo);
    }
}
Exemple #2
0
    echo "                                             Instances start at 0. 0-3 for -n 4\n\n";
    echo "\n";
    echo "Debugging and testing options:\n";
    echo "-d                                           Enable debugging output\n";
    echo "-m                                           Specify single module to be run\n";
    echo "\n";
    echo "Invalid arguments!\n";
    exit;
}
require 'includes/sql-schema/update.php';
$discovered_devices = 0;
if ($config['distributed_poller'] === true) {
    $where .= ' AND poller_group IN(' . $config['distributed_poller_group'] . ')';
}
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 {$where} ORDER BY device_id DESC") as $device) {
    if (dbGetLock('discovering.' . $device['device_id'])) {
        discover_device($device, $options);
    }
}
$end = utime();
$run = $end - $start;
$proctime = substr($run, 0, 5);
if ($discovered_devices) {
    dbInsert(array('type' => 'discover', 'doing' => $doing, 'start' => $start, 'duration' => $proctime, 'devices' => $discovered_devices), 'perf_times');
}
$string = $argv[0] . " {$doing} " . date($config['dateformat']['compact']) . " - {$discovered_devices} devices discovered in {$proctime} secs";
d_echo("{$string}\n");
if ($options['h'] != 'new' && $config['version_check']) {
    include 'includes/versioncheck.inc.php';
}
if (!isset($options['q'])) {
Exemple #3
0
if ($handle = opendir($config['install_dir'] . '/sql-schema')) {
    while (false !== ($file = readdir($handle))) {
        if (filetype($config['install_dir'] . '/sql-schema/' . $file) == 'file' && preg_match($include_dir_regexp, $file)) {
            $filelist[] = $file;
        }
    }
    closedir($handle);
}
asort($filelist);
if (explode('.', max($filelist), 2)[0] <= $db_rev) {
    if ($debug) {
        echo "DB Schema already up to date.\n";
    }
    return;
}
if (!dbGetLock('schema_update')) {
    echo "Schema update already in progress. Exiting\n";
    exit(1);
}
//end if
do {
    sleep(1);
} while (@dbFetchCell('SELECT COUNT(*) FROM `devices` WHERE NOT IS_FREE_LOCK(CONCAT("polling.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("queued.", device_id)) OR NOT IS_FREE_LOCK(CONCAT("discovering.", device_id))') > 0);
foreach ($filelist as $file) {
    list($filename, $extension) = explode('.', $file, 2);
    if ($filename > $db_rev) {
        if (!$updating) {
            echo "-- Updating database schema\n";
        }
        echo sprintf('%03d', $db_rev) . ' -> ' . sprintf('%03d', $filename) . ' ...';
        $err = 0;
Exemple #4
0
    ini_set('display_startup_errors', 0);
    ini_set('log_errors', 0);
    // ini_set('error_reporting', 0);
}
if (isset($options['r'])) {
    $config['norrd'] = true;
}
rrdtool_pipe_open($rrd_process, $rrd_pipes);
echo "Starting polling run:\n\n";
$polled_devices = 0;
if (!isset($query)) {
    $query = "SELECT `device_id` FROM `devices` WHERE `disabled` = 0 {$where} ORDER BY `device_id` ASC";
}
foreach (dbFetch($query) as $device) {
    $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = '" . $device['device_id'] . "'");
    if (dbGetLock('polling.' . $device['device_id'])) {
        poll_device($device, $options);
        RunRules($device['device_id']);
        echo "\r\n";
    }
    $polled_devices++;
}
$poller_end = utime();
$poller_run = $poller_end - $poller_start;
$poller_time = substr($poller_run, 0, 5);
if ($polled_devices) {
    dbInsert(array('type' => 'poll', 'doing' => $doing, 'start' => $poller_start, 'duration' => $poller_time, 'devices' => $polled_devices, 'poller' => $config['distributed_poller_name']), 'perf_times');
}
$string = $argv[0] . " {$doing} " . date($config['dateformat']['compact']) . " - {$polled_devices} devices polled in {$poller_time} secs";
d_echo("{$string}\n");
echo "\n" . 'MySQL: Cell[' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 2) . 's]' . ' Row[' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 2) . 's]' . ' Rows[' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 2) . 's]' . ' Column[' . ($db_stats['fetchcol'] + 0) . '/' . round($db_stats['fetchcol_sec'] + 0, 2) . 's]' . ' Update[' . ($db_stats['update'] + 0) . '/' . round($db_stats['update_sec'] + 0, 2) . 's]' . ' Insert[' . ($db_stats['insert'] + 0) . '/' . round($db_stats['insert_sec'] + 0, 2) . 's]' . ' Delete[' . ($db_stats['delete'] + 0) . '/' . round($db_stats['delete_sec'] + 0, 2) . 's]';