Ejemplo n.º 1
0
        echo $ping->getMessage();
    } else {
        $ping->setArgs(array('count' => 1, 'timeout' => 2));
        $result = $ping->ping($sw_ip);
    }
    $result = (array) $result;
    if (isset($result["_round_trip"]["avg"])) {
        $sw_ping = $result["_round_trip"]["avg"];
    }
    if ($sw_ping == 0) {
        $old = file_get_contents('DS/store/sw/sw_data_' . $sw_id . '.json', true);
        preg_match_all('/"date":"(.*?)"}"/', $old, $datetime);
        $date = $datetime[1];
    }
    $data = array('swid' => $sw_id, 'ping' => $sw_ping, 'date' => $date);
    //echo "". var_dump($data) ."<br>";
    $data = json_encode($data);
    if (!file_exists('DS/store/sw/sw_data_' . $sw_id . '.json')) {
        //echo "<br> создаю id: {$sw_id}";
        $ds->put($data, 'sw_data_' . $sw_id, 'sw');
    } else {
        //echo "<br> обновляю id: {$sw_id}";
        $ds->delete('sw_data_' . $sw_id, 'sw');
        //unlink('DS/store/monitoring/sw_data_'.$sw_id.'.json');
        //echo $ds->status();
        $ds->put($data, 'sw_data_' . $sw_id, 'sw');
    }
}
unset($mysqldb);
unset($ds);
//var_dump($result);
Ejemplo n.º 2
0
        echo $ping->getMessage();
    } else {
        $ping->setArgs(array('count' => 1, 'timeout' => 2));
        $result = $ping->ping($sw_ip);
    }
    $result = (array) $result;
    if (isset($result["_round_trip"]["avg"])) {
        $sw_ping = $result["_round_trip"]["avg"];
    }
    if ($sw_ping == 0) {
        $old = file_get_contents('DS/store/nas/nas_data_' . $sw_id . '.json', true);
        preg_match_all('/"date":"(.*?)"}"/', $old, $datetime);
        $date = $datetime[1];
    }
    $data = array('id' => $sw_id, 'ping' => $sw_ping, 'date' => $date);
    //echo "". var_dump($data) ."<br>";
    $data = json_encode($data);
    if (!file_exists('DS/store/nas/nas_data_' . $sw_id . '.json')) {
        //echo "<br> создаю id: {$sw_id}";
        $ds->put($data, 'nas_data_' . $sw_id, 'nas');
    } else {
        //echo "<br> обновляю id: {$sw_id}";
        $ds->delete('nas_data_' . $sw_id, 'nas');
        //unlink('DS/store/monitoring/sw_data_'.$sw_id.'.json');
        //echo $ds->status();
        $ds->put($data, 'nas_data_' . $sw_id, 'nas');
    }
}
unset($mysqldb);
unset($ds);
//var_dump($result);