Skip to main content

UMnet network data gatherer

Project description

Agador

Agador is a tool that collects operational data from the network and stores it, either in a text file or in a database. It's intended to be a replacement for rancid and other perl tools that currently handle this for us.

Note that the name isn't an acronym for anything, I just needed to not call this code "new rancid" anymore so I named it after Agador Sparticus - my favorite character from one of my favorite movies.

Overview

Agador brings together several different tools:

  • Netbox is used as an inventory source for devices.
  • Cyberark is used as the source for credentials (but plain text creds work too).
  • umnet-napalm is custom code based on NAPALM that runs various commands on network devices and returns normalized data across all vendors.
  • git is how we store versioned data in files - stuff that we don't want to put in a database. Currently this is just config backups, but could be expanded to include other things if applicable.
  • Nornir manages this whole process. This is a public library that provides Ansible-like functionality - it runs a series of tasks across a set of devices and do stuff with the results.

Inventory Filters

One thing that Agador is concerned with is how to identify different subsets of devices within your inventory. This allows you to restrict gathering certain types of data to only certain types of devices - you don't really want to do 'show mpls' on a firewall, for example. To that end, you must provide Agador with a file that defines Nornir inventory filter functions. These functions can then be referenced in the Command Map and Host Options Map (more details below). See the inventory_filters.py file in example_settings for examples of how this works.

Command Map

The heart of Agador is the command map file. See command_map.yml in the example_settings folder.

netbox_roles:
  - av
  - access-layer-switch
  - bin

The commands section is where you specificy what data to gather, how often, from what subset of devices, and how to store that data.

commands:

  config:
    frequency: 0 0 * * *
    getter: get_config
    save_to_file:
      mapper: SaveConfig
      destination: ${FILES_DIR}/umnet-config-backups

  lldp_neighbors:
    frequency: 0 0 * * *
    getter: get_lldp_neighbors
    inventory_filter: non_security_filter
    save_to_db: UpdateNeighbor

Let's talk about the components of each command:

Parameter Required Description
frequency Yes How often to run this command in crontab format
getter Yes The umnet-napalm getter to run for this command
inventory_filter No A Nornir inventory filter function in the inventory_filters.py file that defines which types of devices this command should run against
save_to_file No* If the resulting data should be saved to a file, specify how this should be done with the following required sub-arguments:
mapper - name of mapper class in agador.mappers.save_to_file to use
destination - destination directory for the data
save_to_db No* If the resulting data should be saved to umnetdb, the name of the mapper class in agador.mappers.save_to_db to use to save the data. Note that before a new mapper can be created, a corresponding model must be built in umnet-db

*Note: You must specify at least one of save_to_file or save_to_db so Agador knows what to do with the data it pulls. You can specify both if applicable.

Credential map

The credential map file tells Agador how to retrieve credentials for logging into the devices. Currently two methods of credential retrieval are supported - Cyberark and plaintext. Here's an example:

defaults:
  mapper: cyberark_umnet
  username: automaton
  password: automaton_user_automaton
  enable: Infrastructure_from_2020-05-01_to_current_enable

custom:

  - inventory_filter: fw_cpp
    mapper: cyberark_nso
    username: srancid
    password: fw-cpp_srancid
    enable: fw-cpp_enable

  - inventory_filter: fw_uhs
    mapper: plaintext
    username: srancid
    password: Abc123!

Let's talk about the components of each section:

Parameter Required Description
mapper Yes How to look up the password and enable. Three methods are currently supported: cyberark_nso, cyberark_umnet, and plaintext.
username Yes Credential username
password Yes Credential password. For cyberark, provide the string to query the Cyberark API for that will return the password. For plaintext, just provide the password in plain text.
enable default only Credential enable. You must provide this in the defaults section, it's optional in the custom section.
inventory_filter custom only Required when providing a custom credential. This is a reference to a filter function in your inventory_filters.py file that tells agador which hosts the custom parameter applies to

Note that when deciding which custom credentials apply to which hosts, the first custom match will be applied. So if your matches overlap, it's best to put the most specific ones at the top and more broad ones below. If no match is found for a host in the custom section, the default credentials will apply.

The credential map is located at /etc/agador/credential_map.yml on wintermute.

Running Agador

agador-run

agador-run runs everything once, ignoring the frequency value for each command in the command map. You can restrict the run to a specific device, a specific Netbox device role, or a subset of commands. For example, the following command will pull lldp neighbors off of dl-arbl-1 and store them in the umnet-db.

agador-run --cmds lldp_neighbors --device dl-arbl-1

This command will pull the arp and route tables off of all the non-legacy DLs and store them in the umnet-db. The role must match a Netbox device role.

agador-run --cmds arp_table,route  --role distribution

Note that this command does consult the command_map to tell it what commands are relevant for what devices. If you try to run a command on a device or a role that does not match the inventory_filter function (ie like running arp_table for an AL), you won't get any results.

Use --help to see all options, you'll see a lot of logging options as well.

agador-run-with-schedule

agador-run-with-schedule is designed to run forever as a background process. It pulls data from the network at regular intervals based on the command_map file.

Configuration

Agador requires you to provide it with a path to a configuration file, either on the cli when you invoke it, or as the environment variable AGADOR_CFG. On wintermute this config file is located at /etc/agador/agador.conf. /etc/profile.d/agador.sh sets AGADOR_CFG to this file for all users when they log in. Look at the example config file in the examples folder of this repo for details on what parameters are required.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agador-0.7.0.tar.gz (203.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agador-0.7.0-py3-none-any.whl (62.1 kB view details)

Uploaded Python 3

File details

Details for the file agador-0.7.0.tar.gz.

File metadata

  • Download URL: agador-0.7.0.tar.gz
  • Upload date:
  • Size: 203.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agador-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e6ea41f78d9ea94c96dd8876bf35656a3a4533fe38b0838f8c56da491b609999
MD5 67b97e3c6d82bf040c66e6e4b3bfc8f2
BLAKE2b-256 179b98ae1765204a60f1f766c55cc419a57d78d1af4bacd47715409eb648a38f

See more details on using hashes here.

File details

Details for the file agador-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: agador-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 62.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agador-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85c5a6d6309a039ad05666850986439306d4ecd21de99d4dd5c30fe690f389bd
MD5 550493623f711027c62fb1d6b35a8069
BLAKE2b-256 c1bbf12ae9d1cddaedba44aed6f2b9f4562ea0c6d17d662b265a85b30f3704ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page