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

Access to "sub" index (when OID has multiple indexes) #9893

Merged
merged 10 commits into from Mar 5, 2019

Conversation

Projects
None yet
3 participants
@PipoCanaja
Copy link
Contributor

commented Mar 2, 2019

Following a discussion that took place a couple of weeks ago, here is a proposal to give access in yaml to all the parts of an index.

Simple example with the FANs in Huawei VRP devices:

        state:
             data:
                -
                     oid: hwFanStatusTable
                     value: hwEntityFanState
                     num_oid: '.1.3.6.1.4.1.2011.5.25.31.1.1.10.1.7.{{ $index }}'
                     descr: 'Slot {{ $subindex0 }} Fan {{ $subindex1 }} Status'
                     group: Fans
                     state_name: hwEntityFanState
                     states:
                         - { descr: Normal, graph: 1, value: 1, generic: 0 }
                         - { descr: Abnormal, graph: 1, value: 2, generic: 2 }

This OID is indexed by "slot" and by "fanID". So in a stack of switches, you will have :

hwEntityFanState..

So, for the 2nd fan of the 1st stack member, instead of :
"descr: 'Fan {{ $subindex}} Status'" which would show "Fan 1.2 Status"
you can do :
"descr: 'Slot {{ $subindex0 }} Fan {{ $subindex1 }} Status'" which shows "Slot 1 Fan 2 Status"

The variables are named $subindex with X from 0 to n, parsing left to right the OID exploded around ".".

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.

@TheGreatDoc TheGreatDoc added the Feature label Mar 4, 2019

@PipoCanaja PipoCanaja changed the title WIP Access to "sub" index (when OID has multiple indexes) Access to "sub" index (when OID has multiple indexes) Mar 4, 2019

@PipoCanaja

This comment has been minimized.

Copy link
Contributor Author

commented Mar 4, 2019

OK, ready for review. Let me know if you are OK with the implementation, naming (we could also use {{ $index[0] }} to look a little bit more "phpish" :) )

PipoCanaja and others added some commits Mar 4, 2019

@murrant

This comment has been minimized.

Copy link
Member

commented Mar 4, 2019

I feel like that is a little easier to follow. Look ok to you?

@murrant

murrant approved these changes Mar 4, 2019

@PipoCanaja

This comment has been minimized.

Copy link
Contributor Author

commented Mar 4, 2019

Ooooh ;) Nice, agreed !

@PipoCanaja

This comment has been minimized.

Copy link
Contributor Author

commented Mar 4, 2019

Interesting. Travis failed on a file that is not part of this PR. Any clue how that can happen ?

@murrant

This comment has been minimized.

Copy link
Member

commented Mar 5, 2019

Yeah, the PR for that had style issues, but skipped checking them because the code to make testing faster was incorrect.

@murrant murrant merged commit 4599b36 into librenms:master Mar 5, 2019

4 of 6 checks passed

codeclimate Code Climate encountered an error attempting to analyze this pull request.
Details
Travis CI - Pull Request Build Failed
Details
Inspection Summary
Details
Node: analysis
Details
WIP Ready for review
Details
license/cla Contributor License Agreement is signed.
Details

@PipoCanaja PipoCanaja deleted the PipoCanaja:subindexVariable branch Mar 17, 2019

funzoneq added a commit to funzoneq/librenms that referenced this pull request Apr 30, 2019

Access to "sub" index (when OID has multiple indexes) (librenms#9893)
* accessing in YAML each part of the index in case oid has more than one

* accessing in YAML each part of the index in case oid has more than one

* accessing in YAML each part of the index in case oid has more than one

* accessing in YAML each part of the index in case oid has more than one

* accessing in YAML each part of the index in case oid has more than one

* accessing in YAML each part of the index in case oid has more than one

* accessing in YAML each part of the index in case oid has more than one

* Codeclimate

* Initialisation + comments

* Like this

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 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.