Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Cisco MAC accounting discovery, polling and HTML templates. #10158

Merged
merged 4 commits into from May 21, 2019

Conversation

Projects
None yet
4 participants
@deesel
Copy link
Contributor

commented Apr 28, 2019

====================================
Component | Version
--------- | -------
LibreNMS  | 1.50-65-g6188041ba
DB Schema | 2019_02_10_220000_add_dates_to_fdb (132)
PHP       | 7.3.4
MySQL     | 10.3.9-MariaDB-1:10.3.9+maria~bionic
RRDTool   | 1.6.0
SNMP      | NET-SNMP 5.7.3
====================================

There were several problems with Cisco MAC accounting:

  • Discovery module never created any MAC accounting entries.
  • Poller then only walked through cipMacHCSwitchedBytes and cipMacHCSwitchedPkts counters, but some (older) devices support only cipMacSwitchedBytes and cipMacSwitchedPkts.
  • HTML templates used period names unknown to rrdtool ('day' => '1d', 'twoday' => '2d'...)
  • SQL query to get MAC accounting entries used incorrect column name to sort by default.
  • rrdtool complains about empty arguments; should use quotes (empty string) in place of an argument (:: => :'':)

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@CLAassistant

This comment has been minimized.

Copy link

commented Apr 28, 2019

CLA assistant check
All committers have signed the CLA.

@label-actions

This comment has been minimized.

Copy link

commented Apr 30, 2019

Please add test data so we can ensure your change is not broken in the future.

Read the docs to find out how: https://docs.librenms.org/Developing/os/Test-Units

@murrant

This comment has been minimized.

Copy link
Member

commented Apr 30, 2019

Can you add test data for this module?

Add this to tests/module_tables.yaml and follow the docs to capture snmprec and json files.

cisco-mac-accounting:
    mac_accounting:
        excluded_fields: [ma_id, port_id, poll_time, poll_prev, poll_period]
        joins:
            - { left: mac_accounting.port_id, right: ports.port_id, select: [ifIndex] }
        order_by: ports.ifIndex, mac
@deesel

This comment has been minimized.

Copy link
Contributor Author

commented May 2, 2019

I had to slightly modify tests/module_tables.yml like this:

cisco-mac-accounting:
    mac_accounting:
        excluded_fields: [ma_id, port_id, poll_time, poll_prev, poll_period, cipMacHCSwitchedBytes_input_rate, cipMacHCSwitchedBytes_output_rate, cipMacHCSwitchedPkts_input_rate, cipMacHCSwitchedPkts_output_rate]
        joins:
            - { left: mac_accounting.port_id, right: ports.port_id, select: [ifIndex] }
        custom_where: WHERE ports.device_id=?
        order_by: ports.ifIndex, mac

*_rate fields are actually calculated based on current time, which is obviously different each time the test is run. Also, WHERE clause needed to be fixed, because mac_accounting table has no device_id column.

Finally, because cisco-mac-accounting module uses port data, it needs to be tested together with the ports module.

./scripts/pre-commit.php --db --snmpsim -m ports,cisco-mac-accounting

@PipoCanaja PipoCanaja changed the title Fix Cisco MAC acounting discovery, polling and HTML templates. Fixed Cisco MAC accounting discovery, polling and HTML templates. May 4, 2019

@murrant

This comment has been minimized.

Copy link
Member

commented May 9, 2019

There is a spot where you can set dependencies, in LibreNMS\Util\ModuleTestHelper.php

@deesel

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2019

I didn't know this, thanks. Dependency is set now in LibreNMS\Util\ModuleTestHelper.php

@@ -47,32 +47,32 @@
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
<span class=device-head>Day</span><br />
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => 'day'))."'>
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => '1d'))."'>

This comment has been minimized.

Copy link
@murrant

murrant May 14, 2019

Member

These dates don't work. I think it should be a timestamp.

This comment has been minimized.

Copy link
@deesel

deesel May 20, 2019

Author Contributor

Can you be more specific regarding of what exactly doesn't work, please? According to RRDtool documentation, time offset units can be specified as abbreviations too. Generated RRDtool command looks like this:

rrdtool graph /tmp/b6L3kMK3W97WqQp5 --alt-autoscale-max --rigid -E --start -1d --end 1558349100 --width 745 --height 300 -c BACK#EEEEEE00 -c SHADEA#EEEEEE00 ... <additional output omitted>

...and works like a charm. I use RRDtool v1.6.0.

@murrant murrant merged commit 2dc05ee into librenms:master May 21, 2019

6 checks passed

Inspection Summary
Details
Node: analysis
Details
Travis CI - Pull Request Build Passed
Details
WIP Ready for review
Details
codeclimate All good!
Details
license/cla Contributor License Agreement is signed.
Details

@deesel deesel deleted the deesel:bugfix branch May 21, 2019

@lock lock bot locked as resolved and limited conversation to collaborators Jul 20, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.