Giter Club home page Giter Club logo

puppet-librenms's Introduction

librenms

A Puppet module for managing LibreNMS

Usage

The Puppet manifest used by Vagrant (vagrant/librenms.pp) shows how to

  • Setup LibreNMS (install, configuration, permissions, ACLs, users, etc.)
  • Use puppetlabs-mysql to configure database, user and grants
  • Setup snmpd and create and SNMPv3 user
  • Add the LibreNMS node to LibreNMS

The manifest used by Vagrant uses two optional features of this module that

  • Install the required php packages
  • Configure Apache to serve LibreNMS on port 80 (http)

Hints for production

To import a node into LibreNMS using exported resources:

class { '::snmpd':
  allow_address_ipv4 => '10.0.0.0',
  allow_netmask_ipv4 => '8',
  users              => { 'monitor' => { 'pass' => 'my-password' } },
}

class { '::librenms::device':
  proto => 'v3',
  user  => 'monitor',
  pass  => 'my_password',
}

To use SNMPv2 instead:

class { '::librenms::device':
  proto      => 'v2',
  community  => 'public',
}

Create and remove devices using LibreNMS v0 API:

librenms_device { 'snmpv3.example.org':
  ensure     => 'present',
  url        => 'https://librenms.example.org/api/v0',
  auth_token => '0123456789abcde0123456789abcded0',
  snmpver    => 'v3',
  authlevel  => 'noAuthNoPriv',
  authname   => 'snmpuser',
  authpass   => 'secret',
  authalgo   => 'sha',
  cryptopass => 'secret',
  cryptoalgo => 'aes',
}

librenms_device { 'snmpv2.example.org':
  ensure     => 'present',
  url        => 'https://librenms.example.org/api/v0',
  auth_token => '0123456789abcde0123456789abcded0',
  snmpver    => 'v2c',
  community  => 'public',
}

# Ensure that a decommissioned node is not present in LibreNMS
librenms_device { 'decommissioned.example.org':
  ensure => 'absent',
}

The provider uses the "force_add" parameter to ensure that nodes that are (temporarily) inaccessible (e.g. being provisioned) are added correctly.

You can also manage services using the LibreNMS v0 API:

librenms_service { 'http-on-librenms':
  ensure     => 'present',
  url        => 'http://librenms.example.org/api/v0',
  auth_token => '0123456789abcde0123456789abcded0',
  hostname   => 'librenms.example.org',
  type       => 'http',
  ip         => 'librenms.example.org',
  param      => 'C 50 --sni -S',
}

There are couple of caveats regarding service management:

  • The "desc" parameter, which defaults to the resource title, is used as an identifier at the LibreNMS. This is because it is the only property which is purely informational. You can use this to import existing resources to Puppet. If multiple services matching the same "desc" on the same device are found then Puppet will bail out and ask you to resolve the situation.
  • No verification is done on any of the parameters at Puppet or LibreNMS end except for basic data type validation. For example you can change "type" from "http" (valid) to "https" (invalid) without any errors or warnings.

To create CustomOID checks use the librenms_customoid type. Below an example of how to use this with net-snmp-systemd-service-status:

$service = 'sshd'

# Convert human-readable (ASCII) name to an OID
$oid = librenms::name_to_oid($service)
$descr = "${service} on ${::fqdn}"

@@librenms_customoid { $descr:
  ensure   => present,
  
  # Database username and password: there's no API support for manipulating
  # CustomOIDs
  username => 'librenms',
  password => 'secret',
  
  # Bind this CustomOID to hostname that matches value of $::fqdn fact
  hostname => $::fqdn,
  
  # Alternatively use sysName instead for the mapping
  # sysName   => $::hostname,
   
  # Turn on alerting for this CustomOID.
  alert    => 1,
  
  # Human readable description
  descr    => $descr,
  
  # The OID, which matches the service name converted to ASCII.
  oid      => $oid,
  
  # Send critical alert if the service is not up. We get 0 if it is up, 1
  # otherwise.
  limit    => 1,
  
  # Collect using tags
  tag      => 'default'
}

Then just realize the exported resources on the LibreNMS server:

Librenms_customoid <<| tag == 'default' |>>

See lib/puppet/type/librenms_customoid.rb for documentation of all the available parameters.

Testing with Vagrant

If you have Vagrant and virtualbox installed then setting up LibreNMS test instance from scratch should be as easy as:

$ vagrant up

LibreNMS UI can be reached via

Username is "admin" and password is "vagrant". The instance adds itself to LibreNMS, so you should see one device, "librenms.vagrant.example.lan" under devices.

If you want to use snmpwalk note that the username is "librenms" and password is "vagrant123".

puppet-librenms's People

Contributors

kibahop avatar mattock avatar msvilp avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

puppet-librenms's Issues

Why not depend on native (puppetlabs) modules ?

Hi guys,

I think I love your module but I wonder why you don't rely on the default puppet modules like stdlib, systemd, etc instead of your own. This makes it pretty difficult for other modules to use these libs from other providers, like puppetlabs, as well.

Please let me know!

Cheers,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.