Rancid Integration

A file from Observium called generate-rancid.php produces the router.db that I require for rancid. (Modified a bit) Does what I need. However, this file from Observium and is not GPL. It’s pretty short, I can’t think of a way to start from scratch. How can I rewrite it to be GPL?

We already a have a GPL licensed copy of that file at scripts/gen_rancid.php

1 Like

:grimacing: Certainly missed that, sorry Murrant! Did not mean to waste your time.

I can see at least two possible changes after a quick review: (Assuming anybody using LibreNMS would use at least Rancid 3)

50c50
<         if ($devices['disabled']) {
---
>         if ($devices['disabled'] || !$device['status']) {
53c53
<         echo $devices['hostname'] . ':' . $rancid_map[$devices['os']] . ':' . $status . PHP_EOL;
---
>         echo $devices['hostname'] . ';' . $rancid_map[$devices['os']] . ';' . $status . PHP_EOL;

I also might submit to drop WHERE ignore = 0 or make an option as I might not want to pull it out of SVN if it is simply ignored for a while.

Thank you for your consideration.

Go ahead and create a pull request for this on github :slight_smile:

1 Like

Is that a difference between rancid 2 and 3? If so you’ll need to add a flag to allow people to select which version they use. Changing it blanket as per the patch above will break existing setups for people. If ; is backwards compatible in 2 then ignore that.

Also on the status check, that will remove devices that are currently down which might not be what people expect. I’d have thought you want to add all your devices regardless of being down or not as once it’s fixed config will be backed up without having to re-run the generator.

Rancid 2 is deprecated, nevertheless, I completely agree with not breaking existing setups. (That said, is anybody besides me using Rancid on Librenms?) How about a new variable? Also, should rancid_map be moved to config.php?

if (isset($config['new_rancid']) && $config['new_rancid'] == TRUE)
{
  // Rancid is up to date
  $rancid_colon = ';';
} else {
  // Rancid is old
  $rancid_colon = ':';

It will not exactly remove devices. See here:

   if (isset($rancid_map[$devices['os']])) {
        $status = "up";
        if ($devices['disabled'] || !$devices['status']) {
            $status = "down";

I think that after you see the whole snippet, you’ll understand I’m modifying the line to set status to down, not to remove from rancid. If a device is down, don’t waste time trying to poll it. Devices with a status of “down” stay in rancid.

How about a bool for ingnore? Acceptable? I used to have many devices that I wanted to ping, rancid poll, but not snmp poll. (Didn’t have enough CPU) So, the ability to add devices to Rancid that were ignored in Librenms was important to me. Ideas?

I don’t “git” much (pun intended), so I suppose I should read up on that. Thanks.

The best way forward is to submit your changes as a pull request on github (we have docs on that) and we can discuss it there. It’s hard to see without the diff.