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

feature: Added support for sensors to be discovered from yaml #6859

Merged
merged 12 commits into from Jun 26, 2017

Conversation

laf
Copy link
Member

@laf laf commented Jun 17, 2017

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

Just pushing, nothing more right now.

@mention-bot
Copy link

Thank you for submitting a PR @laf! We have found the following @Rosiak based on the history of these files to review this PR.

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@laf
Copy link
Member Author

laf commented Jun 18, 2017

Ok this is open for feedback now.

@murrant I've removed the oid_name section in the last commit that you don't like :P

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@murrant
Copy link
Member

murrant commented Jun 19, 2017

Looks amazing laf :)

@ghost
Copy link

ghost commented Jun 19, 2017

YAML type is working only for OIDs in table or can be used for all kinds?

@laf
Copy link
Member Author

laf commented Jun 19, 2017

How do you mean @FTBZ?

@laf
Copy link
Member Author

laf commented Jun 19, 2017

Do you mean can it be used for OIDs that aren't in a table? No not at the moment. If you have an example device that this doesn't work on then I can look at seeing what we can do.

@ghost
Copy link

ghost commented Jun 19, 2017

Exactly, I have already had cases where the OIDs of sensors are not in tables but I do not remember which. Good to know for further integration.

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@murrant
Copy link
Member

murrant commented Jun 19, 2017

If you snmpwalk a single item, doesn't basically return a single getnext?

foreach ($data_array as $data) {
foreach ((array)$data['oid'] as $oid) {
$tmp_name = $data['oid'];
$pre_cache[$tmp_name] = snmpwalk_cache_oid($device, $oid, $pre_cache[$tmp_name], $device['dynamic_discovery']['mib'], null, '-OeQUs');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check if the oid has already been fetched here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And send an empty array to the walk function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Walking a single entry is ok but I'm not sure how well the code will work against that yet. I've added support for passing a description as a string as well as saying which key in the array contains the description so it's possibly ok with single OIDs.

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@laf
Copy link
Member Author

laf commented Jun 19, 2017

Rebased. Should pass travis now.

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@maciejkaczkowski
Copy link
Contributor

  1. Is possible to add {{ $index }} to descr? I have device without descr of ports:
    .1.3.6.1.4.1.11195.2.1.10.2.1.12.1 = INTEGER: -68
    .1.3.6.1.4.1.11195.2.1.10.2.1.12.2 = INTEGER: -57
    .1.3.6.1.4.1.11195.2.1.11.2.1.27.1 = INTEGER: 100
    .1.3.6.1.4.1.11195.2.1.11.2.1.27.2 = INTEGER: 90

Tuner Input Level 1 = -68
Tuner Input Level 2 = -57
Modulator Output Level 1 = 100
Modulator Output Level 2 = 90

  1. Is possible to add option to skip if empty or skip if value = xxx?

@laf
Copy link
Member Author

laf commented Jun 20, 2017

I've added support for using index in descr.

Can you give me an example on what you'd want to skip?

@LibreNMS-CI
Copy link

Auto-Deploy finished, Test PR at http://6859.ci.librenms.org or https://6859.ci.librenms.org

@maciejkaczkowski
Copy link
Contributor

Thank you.
For example Arris C4, if card is not inserted to chassis then value is 999
https://github.com/librenms/librenms/blob/master/includes/discovery/sensors/temperature/cmts.inc.php

@laf
Copy link
Member Author

laf commented Jun 22, 2017

@maciejkaczkowski I've added that support:

skip_values:

@laf
Copy link
Member Author

laf commented Jun 26, 2017

This should be good for a merge now imho.

@murrant
Copy link
Member

murrant commented Jun 26, 2017

Looks good to me laf, I plan to try to convert one of the devices I have, but we don't have to wait on me to merge.

@Rosiak
Copy link
Member

Rosiak commented Jun 26, 2017

Almost there!
However it only adds one of the multiple sensors under otherStateSensorTable:
Working
screen shot 2017-06-26 at 20 00 14
This PR:
screen shot 2017-06-26 at 20 00 20

Output from SNMP from this table:

otherStateSensorId.513106929 = nbAlinkEnc_0_3_SPLK
otherStateSensorId.2637721517 = nbAlinkEnc_0_4_SMOK
otherStateSensorId.3502248167 = nbLinkStatus_eth0
otherStateSensorId.3823829717 = nbAlinkPowerStatus_can0
otherStateSensorValue.513106929 = 0
otherStateSensorValue.2637721517 = 0
otherStateSensorValue.3502248167 = 1
otherStateSensorValue.3823829717 = 0
otherStateSensorErrorStatus.513106929 = 0
otherStateSensorErrorStatus.2637721517 = 0
otherStateSensorErrorStatus.3502248167 = 0
otherStateSensorErrorStatus.3823829717 = 0
otherStateSensorLabel.513106929 = Spot leak  (3)
otherStateSensorLabel.2637721517 = Smoke  (4)
otherStateSensorLabel.3502248167 = Ethernet Link Status
otherStateSensorLabel.3823829717 = A-Link Bus Power
otherStateSensorEncId.513106929 = nbAlinkEnc_0
otherStateSensorEncId.2637721517 = nbAlinkEnc_0
otherStateSensorEncId.3502248167 = nbBaseEnclosure
otherStateSensorEncId.3823829717 = nbBaseEnclosure
otherStateSensorPortId.513106929 =
otherStateSensorPortId.2637721517 =
otherStateSensorPortId.3502248167 =
otherStateSensorPortId.3823829717 =
otherStateSensorValueStr.513106929 = No Leak
otherStateSensorValueStr.2637721517 = No Smoke
otherStateSensorValueStr.3502248167 = Up
otherStateSensorValueStr.3823829717 = OK
otherStateSensorEntry.8.513106929 = 513106929
otherStateSensorEntry.8.2637721517 = 2637721517
otherStateSensorEntry.8.3502248167 = 3502248167
otherStateSensorEntry.8.3823829717 = 3823829717

Copy link
Member

@Rosiak Rosiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a tiny comment, then I think we're good to go!

- { descr: motionDetected, graph: 0, value: 1, generic: 2 }
-
oid: otherStateSensorTable
value: otherStateSensorValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the correct name is:
otherStateSensorErrorStatus

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, don't think it matters though.

num_oid: .1.3.6.1.4.1.5528.100.4.2.10.1.3.
descr: otherStateSensorLabel
index: '{{ $index }}'
state_name: otherStateSensorErrorStatus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about otherStateSensor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how it is in the old code so replicating that.

- { descr: motionDetected, graph: 0, value: 1, generic: 2 }
-
oid: otherStateSensorTable
value: otherStateSensorValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the correct name is:
otherStateSensorErrorStatus

num_oid: .1.3.6.1.4.1.5528.100.4.2.10.1.3.
descr: otherStateSensorLabel
index: '{{ $index }}'
state_name: otherStateSensorErrorStatus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about otherStateSensor?

@scrutinizer-notifier
Copy link

The inspection completed: No new issues

@laf laf merged commit 5e32474 into librenms:master Jun 26, 2017
@laf laf deleted the feature/yaml-for-discovery branch June 26, 2017 22:28
@lock
Copy link

lock bot commented May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants