Adding multiple devices + device configurations?


I am new to LibreNMS but it’s so well made and well documented that I’m pretty much settled on it to replace our aging ZenOss install. I managed to install LibreNMS, and bulk add devices to it through the CLI, configure some of the SNMP extenders on our machines to monitor certain applications, add Nagios type Services, etc… All seems to be working splendidly.

But now, I googled and searched all over the docs, and I have a big question. Under ZenOSS, which works with some sort of device tree, it was possible to ‘pre-configure’ future hosts from that group and apply a set of similar parameters.

For example: i’d like all of my hosts from group X to have the same Services configured, and to have the same set of Applications for every of those devices. Is this possible, or do I have to configure each of our 100something hosts manually one by one?

Any input would be greatly appreciated, because I really don’t feel like reviewing 100 hosts to click some buttons to add Apache as an application, and configure a dozen Services per host.

Cheers and thanks in advance


I guess it is possible to do on a database level, even though I don’t personally use neither application, nor services.
Have a look at the database for applications and services tables - they seem to store what you are after.

1 Like

Thanks a lot for the reply. I’m digging deeper right now, it seems to be possible through the API. I really wish there was a CLI command to deal with this but it doesn’t seem to be the case. Ideally, a device template would be the best. I might be able to simply add what needs to be added through the API as I add machines through Ansible.

Thanks for your insights about the DB, i’ll also look into it, it might be faster.


What manner of things do you wish to automate? Have you looked into /opt/librenms/addhost.php? I’ve done very simple (I are not program good) things like adding services or setting all ports to disabled/ignored. I was forced to automate these things because nobody in my team would set them otherwise. As long as you include the right require module, you can call dbUpdate or dbInsert to do what you need.

For example, Services. Those can be added manually, server by server. I’d like to be able to setup services for all of my 100 servers, with exactly the same Service set (ex: ICMP, http, etc)… Same goes for Applications, from what I gathered (could be wrong), after Autodiscover, you need to edit each server one by one to activate the Application module, plus activate every module you want (ex Apache, NGINX, Mysql, etc) to gather information for through either the Agent or SNMP extend. This just sounds a bit tedious to me, if you catch my drift…

Find the sql you need. For instance, I needed to set some ping services:

chdir(__DIR__); // cwd to the directory containing this script

use LibreNMS\Exceptions\HostUnreachableException;

$init_modules = array();
require __DIR__ . '/includes/init.php';

if (isset($argv[1]) && isset($argv[2])) {
        $device = dbFetchRow("SELECT * FROM `devices` WHERE `hostname` = ?", array($argv[1]));
        if ($device[device_id] == '') {
                exit("ERROR!!  No Device found!\n\n\n");
        $our_service = dbFetchRow("SELECT * FROM `services` WHERE `device_id` = ?", array($device[device_id]));
        if (!$our_service[device_id] == '') {
                exit("ERROR!!  Device ID found in services already!!\n\n\n");
        $our_service = dbFetchRow("SELECT * FROM `services` WHERE `service_ip` = ?", array($argv[2]));
        if (!$our_service[service_ip] == '') {
                exit("ERROR!!  Device IP found in services already!!\n\n\n");

        $service_id = add_service($device, 'icmp', $argv[1], $argv[2], '', 0); 
        if ($service_id) {
                echo "ICMP Service added.\n";

Amd yada yada I did some more stuff, but we could end that with:

        } else {
                echo "Dang it, it didn't work.\n";
} else {
        echo "Usage: poorly_written_php.php device ip\n";

Try use/modify that

Thanks a lot for your insights, gonna look into that.