2017-04-25 18:35:42 +01:00
|
|
|
source: Developing/os/Custom-Graphs.md
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2017-04-25 18:35:42 +01:00
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
First we define our graphs in `includes/definitions.inc.php` to share
|
|
|
|
our work and contribute in the development of LibreNMS. :-) (or place
|
|
|
|
in `config.php` if you don't plan to contribute)
|
2019-01-08 13:46:45 -06:00
|
|
|
|
2017-04-25 18:35:42 +01:00
|
|
|
```php
|
2019-01-08 13:46:45 -06:00
|
|
|
// Pulse Secure Graphs
|
|
|
|
$config['graph_types']['device']['pulse_sessions'] = ['section' => 'firewall', 'order' => 0, 'descr' => 'Active Sessions'];
|
|
|
|
$config['graph_types']['device']['pulse_users'] = ['section' => 'firewall', 'order' => 0, 'descr' => 'Active Users'];
|
2017-04-25 18:35:42 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Polling OS
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
OS polling is not necessarily where custom polling should be done,
|
|
|
|
please speak to one of the core devs in
|
|
|
|
[Discord](https://t.libren.ms/discord) for guidance.
|
2017-04-25 18:35:42 +01:00
|
|
|
|
|
|
|
Let's update our example file to add additional polling:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
includes/polling/os/pulse.inc.php
|
|
|
|
```
|
2019-06-20 13:53:45 -05:00
|
|
|
|
|
|
|
We declare two specific graphs for users and sessions numbers. Theses
|
|
|
|
two graphs will be displayed on the firewall section of the graphs tab
|
|
|
|
as it was written in the definition include file.
|
2017-04-25 18:35:42 +01:00
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
2017-06-14 14:32:56 -05:00
|
|
|
use LibreNMS\RRD\RrdDefinition;
|
|
|
|
|
2017-04-25 18:35:42 +01:00
|
|
|
$users = snmp_get($device, 'iveConcurrentUsers.0', '-OQv', 'PULSESECURE-PSG-MIB');
|
|
|
|
|
|
|
|
if (is_numeric($users)) {
|
2017-06-14 14:32:56 -05:00
|
|
|
$rrd_def = RrdDefinition::make()->addDataset('users', 'GAUGE', 0);
|
2017-04-25 18:35:42 +01:00
|
|
|
|
|
|
|
$fields = array(
|
|
|
|
'users' => $users,
|
|
|
|
);
|
|
|
|
|
|
|
|
$tags = compact('rrd_def');
|
|
|
|
data_update($device, 'pulse_users', $tags, $fields);
|
2020-07-23 09:57:22 -05:00
|
|
|
$os->enableGraph('pulse_users');
|
2017-04-25 18:35:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$sessions = snmp_get($device, 'iveConcurrentUsers.0', '-OQv', 'PULSESECURE-PSG-MIB');
|
|
|
|
|
|
|
|
if (is_numeric($sessions)) {
|
2017-06-14 14:32:56 -05:00
|
|
|
$rrd_def = RrdDefinition::make()->addDataset('sessions', 'GAUGE', 0);
|
2017-04-25 18:35:42 +01:00
|
|
|
|
|
|
|
$fields = array(
|
|
|
|
'sessions' => $sessions,
|
|
|
|
);
|
|
|
|
|
|
|
|
$tags = compact('rrd_def');
|
|
|
|
data_update($device, 'pulse_sessions', $tags, $fields);
|
2020-07-23 09:57:22 -05:00
|
|
|
$os->enableGraph('pulse_sessions');
|
2017-04-25 18:35:42 +01:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Displaying
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
The specific graphs are not displayed automatically so we need to
|
|
|
|
write the following PHP code:
|
2017-04-25 18:35:42 +01:00
|
|
|
|
|
|
|
**Pulse Sessions**
|
|
|
|
|
|
|
|
```bash
|
2019-04-20 15:44:40 +02:00
|
|
|
includes/html/graphs/device/pulse_sessions.inc.php
|
2017-04-25 18:35:42 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$rrd_filename = rrd_name($device['hostname'], 'pulse_sessions');
|
|
|
|
|
|
|
|
require 'includes/graphs/common.inc.php';
|
|
|
|
|
|
|
|
$ds = 'sessions';
|
|
|
|
|
|
|
|
$colour_area = '9999cc';
|
|
|
|
$colour_line = '0000cc';
|
|
|
|
|
|
|
|
$colour_area_max = '9999cc';
|
|
|
|
|
|
|
|
$graph_max = 1;
|
|
|
|
$graph_min = 0;
|
|
|
|
|
|
|
|
$unit_text = 'Sessions';
|
|
|
|
|
|
|
|
require 'includes/graphs/generic_simplex.inc.php';
|
|
|
|
```
|
|
|
|
|
|
|
|
**Pulse Users**
|
|
|
|
|
|
|
|
```bash
|
2019-04-20 15:44:40 +02:00
|
|
|
includes/html/graphs/device/pulse_users.inc.php
|
2017-04-25 18:35:42 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$rrd_filename = rrd_name($device['hostname'], 'pulse_users');
|
|
|
|
|
2019-05-20 13:50:12 +02:00
|
|
|
require 'includes/html/graphs/common.inc.php';
|
2017-04-25 18:35:42 +01:00
|
|
|
|
|
|
|
$ds = 'users';
|
|
|
|
|
|
|
|
$colour_area = '9999cc';
|
|
|
|
$colour_line = '0000cc';
|
|
|
|
|
|
|
|
$colour_area_max = '9999cc';
|
|
|
|
|
|
|
|
$graph_max = 1;
|
|
|
|
|
|
|
|
$unit_text = 'Users';
|
|
|
|
|
2019-05-20 13:50:12 +02:00
|
|
|
require 'includes/html/graphs/generic_simplex.inc.php';
|
2017-04-25 18:35:42 +01:00
|
|
|
```
|
|
|
|
|
2019-06-20 13:53:45 -05:00
|
|
|
That should be it, after data has started to be collected graphs
|
|
|
|
should appear in the WebUI.
|