dev
  • Contents
      • NAV documentation
        • Getting help
        • First steps
        • Digging deeper
      • Overview
        • What it is
        • What NAV does
        • A brief history of NAV
      • Installing NAV
        • Installing a pre-packaged version of NAV
        • Installing NAV from source code
      • Getting started with NAV
        • Minimal configuration
        • Starting NAV
        • Logging in to the web interface
        • Seeding your database
        • Further reading
      • Getting organized
        • Organizing your seed data
        • Organizing your collected data
      • Howtos
        • Command line utilities provided in NAV
        • Installing NAV from source code
        • Install from source on Debian
        • Installing Graphite for use with NAV on Debian
        • Integrating Graphite with NAV
        • Migrating RRD data to Graphite (from NAV 3 to NAV 4)
        • Troubleshooting topology problems in NAV
        • Robustifying e-mail
        • Migrating data from one NAV installation to another
        • Authenticating with the apache plugin mod_auth_openidc and Feide
        • Controlling log output from NAV
        • The NAV API
        • NAV API Parameters
      • FAQ
        • Is vendor X / device Y supported?
        • Why are there gaps in my graphs?
        • Why does NAV list my device’s uplink as N/A?
        • Why doesn’t device X show as down in the status page when I know it’s down?
        • A device is down, I see it on the status page, my profile should cover the event, but I am not alerted. Why?
        • Why is my Cisco switch’ syslog full of SNMP-3-AUTHFAIL messages for requests from my NAV server?
        • I added a new IP Device using SeedDB, but nothing happens. Why?
        • How do I make NAV send SMS alerts?
        • How long are ARP and CAM records kept in the database?
      • Reference material
        • Management profiles
        • Arnold
        • Cabling and Patch
        • Event Engine
        • Event Templates
        • Event- and alert type hierarchy
        • Geomap
        • IPAM - IP Address Management
        • ipdevpoll
        • External authentication (LDAP, REMOTE_USER)
        • MailIn
        • navstats
        • PortAdmin
        • Radius
        • Setting up FreeRADIUS to log to NAV
        • smsd
        • snmptrapd
        • Backend processes in NAV
      • Network Administration Visualized release notes
        • NAV 5.8
        • NAV 5.7
        • NAV 5.6
        • NAV 5.5
        • NAV 5.4
        • NAV 5.3
        • NAV 5.2
        • NAV 5.1
        • NAV 5.0
        • NAV 4.9
        • NAV 4.8
        • NAV 4.7
        • NAV 4.6
        • NAV 4.5
        • NAV 4.4
        • NAV 4.3
        • NAV 4.2
        • NAV 4.1
        • NAV 4.0
        • NAV 3.15
        • NAV 3.14
        • NAV 3.13
        • NAV 3.12
        • NAV 3.11
        • NAV 3.10
        • NAV 3.9
        • NAV 3.8
      • Glossary
      • Hacking NAV
        • Hacker’s guide to NAV
        • Hacking with PyCharm
        • Using NAV with Docker for development
        • Javascript hacking
        • Checklist for releasing a new NAV version
        • Writing a new servicemon plugin
        • Adding support for a new environment probe device to NAV
        • The NAV API
        • Extending NAV locally
        • How to customize parts of NAV’s web interface
        • NAVbar search providers
        • Establishing SNMP tunnels using socat/SSH
  • Page
      • navstats
        • Introduction
        • Usage
        • Example
          • SQL
          • Namespace
          • Resulting config
          • Result
  • « MailIn
  • PortAdmin »
  • navstats
    • Introduction
    • Usage
    • Example
      • SQL
      • Namespace
      • Resulting config
      • Result
Source

navstats¶

navstats makes it possible to retrieve any data from the database and send it to Graphite so that it can be used in graphs and reports in NAV and other tools with access to the Graphite web-api.

Introduction¶

navstats was originally to be called Management statistics and was meant to cover the need for having relevant statistics regarding your network to show to your boss or management. However, finding a common ground for what the management wanted to see turned out to be impossible, and the fleeting and not very well formulated demands meant that nothing concrete was going to be made ever.

This lead to a fundamental shift in the proposal. What was implemented was a way to enable NAV administrators to write SQL-statements that produced the statistics they wanted and periodically send it to Carbon. Thus the NAV administrator himself decides what data is important, and the Graphite web-api enables him to extract data as he wishes - either as a graph directly in NAV or to other external tools.

The original request and final proposal is available on Launchpad and GitHub.

Usage¶

There are three steps for starting out with navstats:

  1. navstats requires that you either know the structure of the NAV database very well or is able to formulate your requirement to someone that does, for instance using one of the support-channels. The reason for this is that you need an SQL statement that produces the number(s) you are looking for.

  2. You need to know what a metric path is in Graphite, and how it is relevant for storing data. Basically, you need to choose the naming scheme for your data. All NAV-data starts with nav., so your data should probably have another prefix.

  3. Read the navstats.conf-file and fill in what you gathered in step 1 and 2. Make sure the navstats-process is not running before editing the config-file by running the command nav stop navstats

Example¶

We use the example from the config-file that continuously counts the different types of equipment in the database.

SQL¶

SELECT vendorid, typename, count(*)
FROM netbox JOIN type USING(typeid)
GROUP BY typename, vendorid;

The query will produce lines like this:

vendorid |        typename         | count
----------+-------------------------+-------
brocade  | 4/24_san_switch         |     1
hp       | hp2610_24               |     2
hp       | hp2610_24_pwr           |     1

Namespace¶

We choose to put all data in the namespace nav.stats.

Resulting config¶

[netbox_types]
path=nav.stats.devices.{}.{}
query=select vendorid, typename, count(*)
    from netbox join type using(typeid)
    group by typename, vendorid;

Thus the path for the values above will be:

nav.stats.devices.brocade.4/24_san_switch
nav.stats.devices.hp.hp2610_24
nav.stats.devices.hp.hp2610_24_pwr

(The script will do some modifications to the path to make sure Graphite can handle them.)

Result¶

The script (the one that is started as a cron-job when you write nav start navstats) will make sure to run the SQL and send the output to Graphite.

The result will be browsable in Graphite like shown below. You can use Graphite’s powerful web-api to access the data in the format you wish.

../_images/navstats-graphite-tree.png

Back to top

© Copyright 2012-2023 Uninett AS, 2022-2023 Sikt.
Created using Sphinx 4.4.0.