Device Components. #2623

Merged
merged 10 commits into from Jan 19, 2016

Projects

None yet

8 participants

@adaniels21487
Contributor

The purpose of this feature is to provide a framework for discovery modules to store
information in the database, without needing to add new tables for each feature.

This Feature provides:

  • A database structure to store data.
  • An API to store and retrieve data from the database.
  • Integration to the LibreNMS APIv0.
  • Ability to disable/ignore components.
  • Default alerting rules.
  • Developer documentation

Resolves #1650.

@adaniels21487 adaniels21487 Device Components.
The purpose of this feature is to provide a framework for discovery modules to store
information in the database, without needing to add new tables for each feature.

This Feature provides:
- A database structure to store data.
- An API to store and retrieve data from the database.
- Integration to the LibreNMS APIv0.
- Ability to disable/ignore components.
- Default alerting rules.

- The API returns $COMPONENT[$device_id][$component_id] to allow pulling of data for multiple devices.
  The intent is to be able to create 'Applications' the consolidate data from applications covering multiple devices.
- Added some developer documentation
c63b711
@f0o
Member
f0o commented Dec 15, 2015

Please dont add anything to alert_rules. Not everybody needs that rule being forced upon.

You should add it to the default set though.

Also how does polling of components work?

@adaniels21487
Contributor

Hi @f0o,
I'm not sure wht you mean with the alerting, would you like the rule added but in the disabled state or something else. I should note that even with the rule enabled, alerts will only be sent if the specific component is put into an alert state be a poller module.

Re: Polling of components.
Components is only a framework, a storage container. Developers will create their own discovery and poller modules.

The PR contains some comprehensive documentation that explains how it all works.

Thanks,
Aaron

@laf
Member
laf commented Dec 16, 2015

@adaniels21487 He means that we shouldn't force rules on to people. You can add it to the default suggested list but we don't create rules automatically, especially from updates as someone could wake up to 1000's of alerts one day without realising that a new rule has been added.

@adaniels21487
Contributor

Hi @laf,
Understood.
Are you able to confirm if the default list means creating the alert in the disabled state, or something else?

Thanks,
Aaron

@laf
Member
laf commented Dec 16, 2015

@adaniels21487 Have a check of something like html/includes/print-alert-rules.inc.php. It contains an array we use to insert the data, just append your rule to the end.

@adaniels21487
Contributor

Thanks @laf,
So, I've had a chance to sleep on this.

My original plan was to have an opt-out alerting approach, where the rule would alert on any components if status=0 && disabled=0 && ignore=0 and if a particular alert was not desired, the component could be set ignore=1.

As you mention it is not desirable to have an automatic update start polling something new which starts generating alerts in the middle of the night. I agree, this would not be cool.
With the rule that is currently there, even if moved to the default list still allows this to happen as it is not specific to any type of component, it is generic.

Would a better approach be to remove all rules from this component feature and have modules that create components make thier own addiitions to the default list?
For example, Instead of components adding:

$default_rules[] = array(
    'device_id' => '-1',
    'rule'      => '%macros.component_alert = "1"',
    'severity'  => 'critical',
    'extra'     => '{"mute":false,"count":"-1","delay":"300"}',
    'disabled'  => 0,
    'name'      => 'Component Alert',
);

Cisco-CBQOS should add:

$default_rules[] = array(
    'device_id' => '-1',
    'rule'      => '%macros.component_alert = "1" && %component.type = "Cisco-CBQOS"',
    'severity'  => 'critical',
    'extra'     => '{"mute":false,"count":"-1","delay":"300"}',
    'disabled'  => 0,
    'name'      => 'Cisco-CBQOS Alert',
);

Is this a better approach, please let me know what you think.

Thanks,
Aaron

@laf
Member
laf commented Dec 18, 2015

@adaniels21487 I'd say don't add any rules or suggestions even to the defaults. The first example is just too generic to be of any use but the second one is too custom for most. As long as you've got docs on it then it should be all good.

@adaniels21487 adaniels21487 Merge branch 'master' of https://github.com/adaniels21487/librenms in…
…to issue-1650

Conflicts:
	html/api_v0.php
	html/includes/api_functions.inc.php
6286d7c
@f0o
Member
f0o commented Dec 23, 2015

Gonna spin it up over xmas

@Rosiak Rosiak removed the Rebase Needed label Dec 24, 2015
@Rosiak
Contributor
Rosiak commented Jan 5, 2016

@librenms/core-team
Where are we at with this one?

@Rosiak Rosiak referenced this pull request Jan 5, 2016
Closed

Device State Monitoring #2694

adaniels21487 added some commits Jan 13, 2016
@adaniels21487 adaniels21487 - Compress API filters to a loop
- Check for filters for valid fields
87e88da
@adaniels21487 adaniels21487 - Move 085.sql to 089.sql 29ae6aa
@adaniels21487 adaniels21487 Merge branch 'master' of https://github.com/adaniels21487/librenms in…
…to issue-1650
6492b88
@paulgear paulgear commented on the diff Jan 13, 2016
html/includes/api_functions.inc.php
@@ -507,6 +508,59 @@ function get_graph_by_portgroup() {
}
+function get_components() {
+ global $config;
+ $code = 200;
+ $status = 'ok';
+ $message = '';
+ $app = \Slim\Slim::getInstance();
+ $router = $app->router()->getCurrentRoute()->getParams();
+ $hostname = $router['hostname'];
+
+ // Do some filtering if the user requests.
@paulgear
paulgear Jan 13, 2016 Member

This section feels like it could be collapsed into one data structure + a loop. Not a blocker, though.

@adaniels21487
adaniels21487 Jan 14, 2016 Contributor

Good call..

@paulgear
Member

@adaniels21487 I definitely think this is something we'd like to include soon. In fact, I think we could extend it to become the core of our polling & discovery infrastructure eventually.

adaniels21487 added some commits Jan 15, 2016
@adaniels21487 adaniels21487 - Moved sql beacuse of upstream changes f61838a
@adaniels21487 adaniels21487 Merge branch 'master' into issue-1650
ad75198
@paulgear paulgear removed the Rebase Needed label Jan 15, 2016
@adaniels21487
Contributor

Hi @paulgear,
I have fixed 3 of the issues but I dont understand the code duplication issue.
The two pieces of code it has identified both populate the $options['filter'] array, but arent the same, Could this report be a hangover of the (now removed) if/then/else you highlighted above?

Thanks,
Aaron

@laf
Member
laf commented Jan 17, 2016

Sometimes scrutinizer complains of things you can't fix or just aren't worth it.

@laf
Member
laf commented Jan 18, 2016

All good from my perspective 👍

@paulgear paulgear merged commit a340f35 into librenms:master Jan 19, 2016

1 check passed

Auto-Deploy Build finished. No test results found.
Details
@adaniels21487 adaniels21487 deleted the adaniels21487:issue-1650 branch Jan 20, 2016
@djtecha djtecha referenced this pull request Jan 28, 2016
Closed

Custom information table #2874

@djtecha
djtecha commented Jan 28, 2016

Looks like the example code in the docs don't exist. I'm very confused as to how this is supposed to be inserted. Is it done via the poller as a unix agent or through API calls? Or is it to new and the kinks are being ironed out? Maybe i'm too excited to play with it...

@adaniels21487
Contributor

Hi @djtecha,
You're a bit to quick for me. The referenced examples are in the following PR's, yet to be merged:
#2841 - Cisco OTV
#2840 - Cisco CBQoS

Thanks,
Aaron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment