feature: HPE Comware Processor Discovery #6029

Merged
merged 4 commits into from Mar 1, 2017

Conversation

Projects
None yet
6 participants
@Rosiak
Contributor

Rosiak commented Feb 27, 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.

  • Have you signed the Contributors agreement - please do NOT submit a pull request unless you have (signing the agreement in the same pull request is fine). Your commit message for signing the agreement must appear as per the docs.
  • Have you followed our code guidelines?

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

@mention-bot

This comment has been minimized.

Show comment
Hide comment
@mention-bot

mention-bot Feb 27, 2017

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

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

@LibreNMS-CI

This comment has been minimized.

Show comment
Hide comment
@LibreNMS-CI

This comment has been minimized.

Show comment
Hide comment
@murrant

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant Mar 1, 2017

Member

@Rosiak I was wondering if we could use the entPhysicalData from the database, soooo, I re-wrote this. Do you like this better?


if ($device['os'] == 'comware') {
    echo 'HPE Comware ';

    if (dbFetchCell('SELECT COUNT(`entPhysical_id`) FROM `entPhysical` WHERE `device_id` = ?', array($device['device_id']))) {
        $indexes = dbFetchColumn('SELECT `entPhysicalIndex` FROM `entPhysical` WHERE device_id = ? AND entPhysicalName = ?', array($device['device_id'], 'Board'));
    } else {
        $entity_data = snmpwalk_cache_oid($device, 'entPhysicalName', array(), 'ENTITY-MIB');
        $indexes = array_keys(array_filter($entity_data, function ($entry) {
            return $entry['entPhysicalName'] == 'Board';
        }));
    }

    if (!empty($indexes)) {
        $procdata = snmpwalk_cache_oid($device, 'hh3cEntityExtCpuUsage', array(), 'HH3C-ENTITY-EXT-MIB');

        foreach ($indexes as $i => $entIndex) {
            if (isset($procdata[$entIndex])) {
                $cur_oid = ".1.3.6.1.4.1.25506.2.6.1.1.1.1.6.$entIndex";
                $cur_value = $procdata[$entIndex]['hh3cEntityExtCpuUsage'];
                $descr = 'Slot ' . ++$i;
                discover_processor($valid['processor'], $device, $cur_oid, $entIndex, 'comware', $descr, '1', $cur_value);
            }
        }
    }
}
Member

murrant commented Mar 1, 2017

@Rosiak I was wondering if we could use the entPhysicalData from the database, soooo, I re-wrote this. Do you like this better?


if ($device['os'] == 'comware') {
    echo 'HPE Comware ';

    if (dbFetchCell('SELECT COUNT(`entPhysical_id`) FROM `entPhysical` WHERE `device_id` = ?', array($device['device_id']))) {
        $indexes = dbFetchColumn('SELECT `entPhysicalIndex` FROM `entPhysical` WHERE device_id = ? AND entPhysicalName = ?', array($device['device_id'], 'Board'));
    } else {
        $entity_data = snmpwalk_cache_oid($device, 'entPhysicalName', array(), 'ENTITY-MIB');
        $indexes = array_keys(array_filter($entity_data, function ($entry) {
            return $entry['entPhysicalName'] == 'Board';
        }));
    }

    if (!empty($indexes)) {
        $procdata = snmpwalk_cache_oid($device, 'hh3cEntityExtCpuUsage', array(), 'HH3C-ENTITY-EXT-MIB');

        foreach ($indexes as $i => $entIndex) {
            if (isset($procdata[$entIndex])) {
                $cur_oid = ".1.3.6.1.4.1.25506.2.6.1.1.1.1.6.$entIndex";
                $cur_value = $procdata[$entIndex]['hh3cEntityExtCpuUsage'];
                $descr = 'Slot ' . ++$i;
                discover_processor($valid['processor'], $device, $cur_oid, $entIndex, 'comware', $descr, '1', $cur_value);
            }
        }
    }
}
+ if ($index == $procindex) {
+ $cur_oid = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.6.';
+
+ discover_processor($valid['processor'], $device, $cur_oid . $procindex, $procindex, 'comware', 'Slot ' . $x, '1', $value['h3cEntityExtCpuUsage']);

This comment has been minimized.

@murrant

murrant Mar 1, 2017

Member

Should be hh3cEntityExtCpuUsage

@murrant

murrant Mar 1, 2017

Member

Should be hh3cEntityExtCpuUsage

@Rosiak

This comment has been minimized.

Show comment
Hide comment
@Rosiak

Rosiak Mar 1, 2017

Contributor

Perfectly fine with that @murrant !

Contributor

Rosiak commented Mar 1, 2017

Perfectly fine with that @murrant !

@LibreNMS-CI

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant approved these changes Mar 1, 2017

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Mar 1, 2017

Member

lol, I'm against that personally as per the other PR which did the same.

Doing it this way requires entity-physical discovery module to be enabled and have run before this (admittedly after the second run it won't matter if entity-physical runs first or not). However the dependancy on another module imho is a no no as you're restricting users who have sensors enabled because they want to see them but not entity-physical.

Other discovery modules which require entityphysical info do another walk afaik - which if we can get the updated snmp Class finished and merged won't be an issue as the results will be cached.

Member

laf commented Mar 1, 2017

lol, I'm against that personally as per the other PR which did the same.

Doing it this way requires entity-physical discovery module to be enabled and have run before this (admittedly after the second run it won't matter if entity-physical runs first or not). However the dependancy on another module imho is a no no as you're restricting users who have sensors enabled because they want to see them but not entity-physical.

Other discovery modules which require entityphysical info do another walk afaik - which if we can get the updated snmp Class finished and merged won't be an issue as the results will be cached.

@murrant

This comment has been minimized.

Show comment
Hide comment
@murrant

murrant Mar 1, 2017

Member

@laf I specifically made a fallback so this doesn't rely on the entity-physical module, only takes advantage of it if it exists.

Member

murrant commented Mar 1, 2017

@laf I specifically made a fallback so this doesn't rely on the entity-physical module, only takes advantage of it if it exists.

@laf

This comment has been minimized.

Show comment
Hide comment
@laf

laf Mar 1, 2017

Member

Yeah I didn't realise that until you pointed it out as I'd only read the reply on email where it said you rewritten it to pull from DB.

As you pointed out in irc, this still does mean that someone could have stale data if entity-physical was disabled 6 months ago as an example. It's not a huge concern but does still swing me more to why bother checking the DB if we can't be sure when that data was from.

Member

laf commented Mar 1, 2017

Yeah I didn't realise that until you pointed it out as I'd only read the reply on email where it said you rewritten it to pull from DB.

As you pointed out in irc, this still does mean that someone could have stale data if entity-physical was disabled 6 months ago as an example. It's not a huge concern but does still swing me more to why bother checking the DB if we can't be sure when that data was from.

@LibreNMS-CI

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

This comment has been minimized.

Show comment
Hide comment
@scrutinizer-notifier

scrutinizer-notifier Mar 1, 2017

The inspection completed: No new issues

The inspection completed: No new issues

@Rosiak

This comment has been minimized.

Show comment
Hide comment
@Rosiak

Rosiak Mar 1, 2017

Contributor

As it's only disco job, I'm not concerned regarding the "extra" snmp req as this not that "expensive" at this point.

Contributor

Rosiak commented Mar 1, 2017

As it's only disco job, I'm not concerned regarding the "extra" snmp req as this not that "expensive" at this point.

@murrant murrant merged commit 1f59322 into librenms:master Mar 1, 2017

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Rosiak Rosiak deleted the Rosiak:comware-processor branch Nov 15, 2017

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot May 16, 2018

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

lock bot commented May 16, 2018

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

@librenms librenms 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.