https://github.com/duckthom/php-vnstat
vnstat json output parser for PHP
https://github.com/duckthom/php-vnstat
Last synced: about 1 year ago
JSON representation
vnstat json output parser for PHP
- Host: GitHub
- URL: https://github.com/duckthom/php-vnstat
- Owner: DuckThom
- License: other
- Created: 2016-12-08T22:58:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-23T15:03:16.000Z (over 9 years ago)
- Last Synced: 2025-03-27T06:34:42.646Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-vnstat
vnstat json output parser for PHP
[](https://styleci.io/repos/75982156)
[](https://packagist.org/packages/luna/vnstat)
[](https://packagist.org/packages/luna/vnstat)
## Usage
```php
use Luna\Vnstat\Vnstat;
class YourClass extends Awesomeness implements Ideas
{
protected $interface = 'eth0';
public function runWithStaticMethod()
{
$jsonObject = Vnstat::get($this->interface);
}
public function runWithNewInstance()
{
$vnstat = new Vnstat($this->interface);
$vnstat->run();
$rawJson = $vnstat->getJson();
$response = $vnstat->getResponse();
}
}
```
## Methods
```php
public function Vnstat::__construct(string $interface): void
```
```php
public function Vnstat::get(string $interface): \Luna\Vnstat\VnstatResponse
```
```php
public function Vnstat::getResponse(): \Luna\Vnstat\VnstatResponse
```
```php
public function Vnstat::setExecutablePath(string $executable): $this
```
```php
public function Vnstat::getExecutablePath(): string
```
```php
public function Vnstat::setJson(string $json): $this
```
```php
public function Vnstat::getJson(): string
```
## Errors/Exceptions
Throws `Luna\Vnstat\Exceptions\InvalidJsonException` if the string returned by `Vnstat::getJson()` was an invalid json string.
Throws `Luna\Vnstat\Exceptions\ExecutableNotFoundException` if `which vnstat` failed.
Throws `\Symfony\Component\Process\Exception\ProcessFailedException` if `vnstat --query --json -i $interface` failed.