Added basic support for distributing billing (#15156)

This commit is contained in:
Neil Lathwood 2023-07-25 18:09:34 +01:00 committed by GitHub
parent a2f906c3f4
commit a69d50e962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -186,6 +186,15 @@ It's not necessary to run discovery services on all pollers. In fact, you should
only run one discovery process per poller group.
Designate a single poller to run discovery (or a separate server if required).
If you run billing, you can do this in one of two ways:
1. Run poll-billing.php and calculate-billing.php on a single poller which will
create billing information for all bills. Please note this poller must have
snmp access to all of your devices which have ports within a bill.
1. The other option is to enable `$config['distributed_billing'] = true;` in
config.php. Then run poll-billing.php on a single poller per group. You can run
calculate-billing.php on any poller but only one poller overall.
**Dispatcher service**
When using the dispatcher service, discovery can run on all nodes.
@ -259,11 +268,12 @@ Running an install of LibreNMS in /opt/librenms
```php
$config['distributed_poller_name'] = php_uname('n');
$config['distributed_poller_group'] = '0';
$config['distributed_billing'] = true;
```
!!! setting "poller/distributed"
```bash
lnms config:set distributed_poller_group 0
lnms config:set distributed_poller_memcached_host "example.com"
lnms config:set distributed_poller_memcached_port 11211
lnms config:set distributed_poller true
@ -294,11 +304,12 @@ Running an install of LibreNMS in /opt/librenms
```php
$config['distributed_poller_name'] = php_uname('n');
$config['distributed_poller_group'] = '0';
$config['distributed_billing'] = true;
```
!!! setting "poller/distributed"
```bash
lnms config:set distributed_poller_group 0
lnms config:set distributed_poller_memcached_host "example.com"
lnms config:set distributed_poller_memcached_port 11211
lnms config:set distributed_poller true
@ -327,11 +338,12 @@ Running an install of LibreNMS in /opt/librenms
```php
$config['distributed_poller_name'] = php_uname('n');
$config['distributed_poller_group'] = '2,3';
$config['distributed_billing'] = true;
```
!!! setting "poller/distributed"
```bash
lnms config:set distributed_poller_group '2,3'
lnms config:set distributed_poller_memcached_host "example.com"
lnms config:set distributed_poller_memcached_port 11211
lnms config:set distributed_poller true
@ -348,6 +360,7 @@ Runs discovery and polling for groups 2 and 3.
```conf
33 */6 * * * librenms /opt/librenms/cronic /opt/librenms/discovery-wrapper.py 1
*/5 * * * * librenms /opt/librenms/discovery.php -h new >> /dev/null 2>&1
*/5 * * * * librenms /opt/librenms/poll-billing.php >> /dev/null 2>&1
*/5 * * * * librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16
15 0 * * * librenms /opt/librenms/daily.sh >> /dev/null 2>&1
```

View File

@ -41,7 +41,11 @@ foreach ($query->get(['bill_id', 'bill_name']) as $bill) {
echo 'Bill : ' . $bill->bill_name . "\n";
$bill_id = $bill->bill_id;
$port_list = dbFetchRows('SELECT * FROM `bill_ports` as P, `ports` as I, `devices` as D WHERE P.bill_id=? AND I.port_id = P.port_id AND D.device_id = I.device_id', [$bill_id]);
if ($config['distributed_poller'] && $config['distributed_billing']) {
$port_list = dbFetchRows('SELECT * FROM `bill_ports` as P, `ports` as I, `devices` as D WHERE P.bill_id=? AND I.port_id = P.port_id AND D.device_id = I.device_id AND D.poller_group IN (?)', [$bill_id, $config['distributed_poller_group']]);
} else {
$port_list = dbFetchRows('SELECT * FROM `bill_ports` as P, `ports` as I, `devices` as D WHERE P.bill_id=? AND I.port_id = P.port_id AND D.device_id = I.device_id', [$bill_id]);
}
$now = dbFetchCell('SELECT NOW()');
$delta = 0;