fix: Detection blank or unknown device types and update #5412 #5414

Merged
merged 2 commits into from Jan 13, 2017

Projects

None yet

5 participants

@laf
Member
laf commented Jan 12, 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.

Fixes: #5412

@laf laf fix: Detection blank or unknown device types and update #5412
dc0b83e
@mention-bot

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

includes/common.php
@@ -1527,9 +1527,12 @@ function load_os(&$device)
);
// Set type to a predefined type for the OS if it's not already set
- if ($device['type'] == 'unknown' || $device['type'] == '') {
+ if ($device['type'] == 'unknown' || $device['type'] == '' || $config['os'][$device['os']]['type'] != $device['type']) {
@murrant
murrant Jan 13, 2017 edited Contributor

It feels like this should be, I'm not somewhere where I can test it right now...

    // Set type to a predefined type for the OS if it's not already set
    if ($config['os'][$device['os']]['type'] && $config['os'][$device['os']]['type'] != $device['type']) {
        $device['type'] = $config['os'][$device['os']]['type'];
        $sql = dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id']));
        log_event('Device type changed '.$device['type'].' => '.$config['os'][$device['os']]['type'], $device, 'system');
        echo "Changed Type! : ".$device['type'].PHP_EOL;
    }
@murrant murrant Less ifs
6e821ac
@scrutinizer-notifier

The inspection completed: 1 updated code elements

@murrant murrant merged commit 6ff3ae8 into librenms:master Jan 13, 2017

2 checks passed

Auto-Deploy Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@laf laf deleted the laf:issue-5412 branch Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment