Add RRD API
This commit is contained in:
parent
2c954631ca
commit
9349a6b047
|
@ -42,6 +42,7 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
|
|||
- Trackers
|
||||
- Peers
|
||||
- BlackList
|
||||
- RRD
|
||||
- Configuration
|
||||
- Connection
|
||||
- Connection (Core)
|
||||
|
|
6
TODO.md
6
TODO.md
|
@ -1,4 +1,4 @@
|
|||
- Downloads
|
||||
- ~~Downloads~~
|
||||
- ~~Download~~
|
||||
- ~~Download Stats~~
|
||||
- ~~Download Files~~
|
||||
|
@ -13,8 +13,8 @@
|
|||
- ~~File Upload~~
|
||||
- ~~Air Media~~
|
||||
- ~~AirMedia API~~
|
||||
- RRD
|
||||
- RRD [UNSTABLE]
|
||||
- ~~RRD~~
|
||||
- ~~RRD [UNSTABLE]~~
|
||||
- ~~Calls / Contacts~~
|
||||
- ~~Call~~
|
||||
- ~~Contacts~~
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\RRD;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
/**
|
||||
* Class Fetch
|
||||
* @package alphayax\freebox\api\v3\services\RRD
|
||||
*/
|
||||
class Fetch extends Service {
|
||||
|
||||
const API_RDD = '/api/v3/rrd/';
|
||||
|
||||
/**
|
||||
* @param string $db
|
||||
* Name of the rrd database to read
|
||||
* @see alphayax\freebox\api\v3\symbols\RRD\Db
|
||||
* @param int $date_start
|
||||
* The requested start timestamp of the stats to get
|
||||
* NOTE: this can be adjusted to fit the best available resolution
|
||||
* @param int $date_end
|
||||
* The requested end timestamp of the stats to get
|
||||
* NOTE: this can be adjusted to fit the best available resolution
|
||||
* @param int $precision
|
||||
* By default all values are cast to int, if you need floating point precision you can provide a precision factor that will be applied to all values before being returned.
|
||||
* For instance if you want 2 digit precision you should use a precision of 100, and divide the obtained results by 100.
|
||||
* @param array $fields
|
||||
* If you are only interested in getting some fields you can provide the list of fields you want to get.
|
||||
* @see alphayax\freebox\api\v3\symbols\RRD\Fields\Net
|
||||
* @see alphayax\freebox\api\v3\symbols\RRD\Fields\Temp
|
||||
* @see alphayax\freebox\api\v3\symbols\RRD\Fields\Dsl
|
||||
* @see alphayax\freebox\api\v3\symbols\RRD\Fields\FbxSwitch
|
||||
* @return array
|
||||
*/
|
||||
public function getStats( $db, $date_start = null, $date_end = null, $precision = null, array $fields = []){
|
||||
$QueryParameters = $this->buildQuery( $db, $date_start, $date_end, $precision, $fields);
|
||||
$rest = $this->getAuthService( self::API_RDD);
|
||||
$rest->GET( $QueryParameters);
|
||||
|
||||
return $rest->getCurlResponse()['result'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the query
|
||||
* @param string $db
|
||||
* @param int $date_start
|
||||
* @param int $date_end
|
||||
* @param int $precision
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*/
|
||||
protected function buildQuery( $db, $date_start, $date_end, $precision, array $fields){
|
||||
$QueryParameters = [
|
||||
'db' => $db,
|
||||
];
|
||||
if( ! is_null( $date_start)){
|
||||
$QueryParameters['date_start'] = $date_start;
|
||||
}
|
||||
if( ! is_null( $date_end)){
|
||||
$QueryParameters['date_end'] = $date_end;
|
||||
}
|
||||
if( ! is_null( $precision)){
|
||||
$QueryParameters['precision'] = $precision;
|
||||
}
|
||||
if( ! empty( $fields)){
|
||||
$QueryParameters['fields'] = $fields;
|
||||
}
|
||||
return $QueryParameters;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\RRD;
|
||||
|
||||
/**
|
||||
* Symbol Db
|
||||
* @package alphayax\freebox\api\v3\symbols\RRD
|
||||
*/
|
||||
interface Db {
|
||||
|
||||
/** network stats */
|
||||
const NETWORK = 'net';
|
||||
|
||||
/** temperature stats */
|
||||
const TEMPERATURE = 'temp';
|
||||
|
||||
/** xDSL stats */
|
||||
const DSL = 'dsl';
|
||||
|
||||
/** switch stats */
|
||||
const FBX_SWITCH = 'switch';
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\RRD\Fields;
|
||||
|
||||
/**
|
||||
* Symbol Dsl
|
||||
* @package alphayax\freebox\api\v3\symbols\RRD\Fields
|
||||
*/
|
||||
interface Dsl {
|
||||
|
||||
/** dsl available upload bandwidth (in byte/s) */
|
||||
const UPLOAD_BANDWIDTH_AVAILABLE = 'rate_up';
|
||||
|
||||
/** dsl available download bandwidth (in byte/s) */
|
||||
const DOWNLOAD_BANDWIDTH_AVAILABLE = 'rate_down';
|
||||
|
||||
/** dsl upload signal/noise ratio (in 1/10 dB) */
|
||||
const UPLOAD_NOISE_RATIO = 'snr_up';
|
||||
|
||||
/** dsl download signal/noise ratio (in 1/10 dB) */
|
||||
const DOWNLOAD_NOISE_RATIO = 'snr_down';
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\RRD\Fields;
|
||||
|
||||
/**
|
||||
* Symbol FbxSwitch
|
||||
* @package alphayax\freebox\api\v3\symbols\RRD\Fields
|
||||
*/
|
||||
interface FbxSwitch {
|
||||
|
||||
/** receive rate on port 1 (in byte/s) */
|
||||
const RX_1 = 'rx_1';
|
||||
|
||||
/** transmit on port 1 (in byte/s) */
|
||||
const TX_1 = 'tx_1';
|
||||
|
||||
/** receive rate on port 2 (in byte/s) */
|
||||
const RX_2 = 'rx_2';
|
||||
|
||||
/** transmit on port 2 (in byte/s) */
|
||||
const TX_2 = 'tx_2';
|
||||
|
||||
/** receive rate on port 3 (in byte/s) */
|
||||
const RX_3 = 'rx_3';
|
||||
|
||||
/** transmit on port 3 (in byte/s) */
|
||||
const TX_3 = 'tx_3';
|
||||
|
||||
/** receive rate on port 4 (in byte/s) */
|
||||
const RX_4 = 'rx_4';
|
||||
|
||||
/** transmit on port 4 (in byte/s) */
|
||||
const TX_4 = 'tx_4';
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\RRD\Fields;
|
||||
|
||||
/**
|
||||
* Symbol Net
|
||||
* @package alphayax\freebox\api\v3\symbols\RRD\Fields
|
||||
*/
|
||||
interface Net {
|
||||
|
||||
/** upload available bandwidth (in byte/s) */
|
||||
const UPLOAD_BANDWIDTH = 'bw_up';
|
||||
|
||||
/** download available bandwidth (in byte/s) */
|
||||
const DOWNLOAD_BANDWIDTH = 'bw_down';
|
||||
|
||||
/** upload rate (in byte/s) */
|
||||
const UPLOAD_RATE = 'rate_up';
|
||||
|
||||
/** download rate (in byte/s) */
|
||||
const DOWNLOAD_RATE = 'rate_down';
|
||||
|
||||
/** vpn client upload rate (in byte/s) */
|
||||
const VPN_DOWNLOAD_RATE = 'vpn_rate_up';
|
||||
|
||||
/** vpn client download rate (in byte/s) */
|
||||
const VPN_UPLOAD_RATE = 'vpn_rate_down';
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\RRD\Fields;
|
||||
|
||||
/**
|
||||
* Symbol Temp
|
||||
* @package alphayax\freebox\api\v3\symbols\RRD\Fields
|
||||
*/
|
||||
interface Temp {
|
||||
|
||||
/** temperature cpum (in °C) */
|
||||
const CPUM = 'cpum';
|
||||
|
||||
/** temperature cpub (in °C) */
|
||||
const CPUB = 'cpub';
|
||||
|
||||
/** temperature sw (in °C) */
|
||||
const SW = 'sw';
|
||||
|
||||
/** temperature hdd (in °C) */
|
||||
const HDD = 'hdd';
|
||||
|
||||
/** fan rpm */
|
||||
const FAN_SPEED = 'fan_speed';
|
||||
|
||||
/**
|
||||
* temperature sensor 1 (in °C)
|
||||
* @deprecated use cpum
|
||||
*/
|
||||
const TEMP1 = 'temp1';
|
||||
|
||||
/**
|
||||
* temperature sensor 2 (in °C)
|
||||
* @deprecated use cpub
|
||||
*/
|
||||
const TEMP2 = 'temp2';
|
||||
|
||||
/**
|
||||
* temperature sensor 3 (in °C)
|
||||
* @deprecated use sw
|
||||
*/
|
||||
const TEMP3 = 'temp3';
|
||||
}
|
Loading…
Reference in New Issue