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

AOS-EMU2: Add contact,relay,outlet discovery; update yaml,snmprec,json #8317

Merged
merged 7 commits into from Mar 17, 2018

Conversation

Projects
None yet
4 participants
@axemann
Contributor

axemann commented Mar 1, 2018

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

@axemann

This comment has been minimized.

Contributor

axemann commented Mar 2, 2018

Hey guys, not sure what to do about the snmprec error. The same pre-commit parameters pass on my test box: https://p.libren.ms/view/a921acc6.

array($state_index_id,'Normal',0,1,0) ,
array($state_index_id,'Alert',0,2,1)
);
foreach ($states as $value) {

This comment has been minimized.

@murrant

murrant Mar 9, 2018

Member

This is using old style state definitions.
Please see the documentation for an updated code style (or use yaml).
https://docs.librenms.org/Developing/Sensor-State-Support/

$index = $contact['emsInputContactStatusInputContactIndex'];
$oid = '.1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.' . $index;
$descr = $contact['emsInputContactStatusInputContactName'];
$currentstate = $contact['emsInputContactStatusInputContactState'];

This comment has been minimized.

@murrant

murrant Mar 9, 2018

Member

This returns a string when you use the mib, so you need to convert the string to a numeric value.

$state_index_id = create_state_index($state_name_nc);
if ($state_index_id !== null) {
$states = array(
array($state_index_id,'Normal',0,1,0) ,

This comment has been minimized.

@murrant

murrant Mar 9, 2018

Member

Most of the time it is better if you used the names returned by snmp instead of Normal and Alert. So: contactOpenEMS and contactClosedEMS. Or at least change the description to Open and Closed ( you can keep the inverted generic values so it correctly shows up as green or red)

mib_dir:
- apc
discovery:
- sysObjectID:
- .1.3.6.1.4.1.318.1.3.8.2
- .1.3.6.1.4.1.318.1.3.8.3
discovery_modules:

This comment has been minimized.

@murrant

murrant Mar 9, 2018

Member

It is kind of pointless and misleading to disable all these modules. Most don't do anything on your device.

@murrant

This comment has been minimized.

Member

murrant commented Mar 9, 2018

While troubleshooting, I converted the states to the new format, here you go:

        $state_name_nc = 'emsInputContactNormalState_NC';
        $states = array(
            array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'),
            array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
        );
        create_state_index($state_name_nc, $states);
        $state_name_no = 'emsInputContactNormalState_NO';
        $states = array(
            array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
            array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
        );
        create_state_index($state_name_no, $states);
        $state_name_nc = 'emsOutputRelayNormalState_NC';
        $states = array(
            array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
            array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
        );
        create_state_index($state_name_nc, $states);
       $state_name_no = 'emsOutputRelayNormalState_NO';
        $states = array(
            array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
            array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
        );
        create_state_index($state_name_no, $states);
        $state_name_on = 'emsOutletNormalState_ON';
        $states = array(
            array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'On'),
            array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Off'),
        );
        create_state_index($state_name_on, $states);
        $state_name_off = 'emsOutletNormalState_OFF';
        $states = array(
            array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'On'),
            array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Off'),
        );
        create_state_index($state_name_off, $states);

Remember my suggestion to change the descriptions from Alert/Normal to the snmp name or Open/Closed.

@axemann

This comment has been minimized.

Contributor

axemann commented Mar 9, 2018

Thanks @murrant. I'll work on fixing this up tonight/tomorrow and incorporating your converted states above. Sorry for all the trouble, still learning over here. :-)

@murrant

This comment has been minimized.

Member

murrant commented Mar 10, 2018

No worries. I'd like to convert the existing ones so people have good source code to look at, but haven't had time and it's working mostly 😀

@murrant

This comment has been minimized.

Member

murrant commented Mar 10, 2018

Let us know if you have any questions.

@murrant murrant changed the title from Add contact,relay,outlet discovery; update yaml,snmprec,json to AOS-EMU2: Add contact,relay,outlet discovery; update yaml,snmprec,json Mar 17, 2018

@murrant murrant added the Device 🖥 label Mar 17, 2018

@murrant

This comment has been minimized.

Member

murrant commented Mar 17, 2018

@laf another one trying to insert strings into a numeric field in the database.

@scrutinizer-notifier

This comment has been minimized.

scrutinizer-notifier commented Mar 17, 2018

The inspection completed: No new issues

@murrant murrant merged commit d20d6fc into librenms:master Mar 17, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

inetAnt added a commit to criteo-forks/librenms that referenced this pull request Mar 19, 2018

AOS-EMU2: Add contact,relay,outlet discovery; update yaml,snmprec,json (
librenms#8317)

* Add contact,relay,outlet discovery; update yaml,snmprec,json

* Fix formatting

* Another attempt at fixing sensors

* Update state mappings and fix json sensor ordering

* Capture values numerically.
Remove extra if/else statement
Make test data more interesting.

* Fix whitespace.

* Update sensors test data for order_by
@lock

This comment has been minimized.

lock bot commented May 16, 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 16, 2018

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