Skip to content

Add 1-Wire sensor monitoring#3822

Merged
ktsaou merged 1 commit intonetdata:masterfrom
dspinellis:w1sensor
Jun 15, 2018
Merged

Add 1-Wire sensor monitoring#3822
ktsaou merged 1 commit intonetdata:masterfrom
dspinellis:w1sensor

Conversation

@dspinellis
Copy link
Contributor

Auto-detect and display data from multiple 1-Wire temperature sensors.
Sensor names are user-configurable.

@dspinellis
Copy link
Contributor Author

1-wire

Here is an image of the resultant dashboard.

'absolute', 1, 10])
self.definitions['temp']['lines'] = lines
return len(self.probes) > 0
except Exception as error:
Copy link
Member

Choose a reason for hiding this comment

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

Some suggestions:

  1. Make exception more specific
  2. Remove all code from try/except block which can not cause an exception

Like:

try:
    filenames = os.listdir(W1_DIR)
except OSError as err:  # i believe we only need OSError here, but i am not sure
    self.error(err)
    return None

...
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

value = round(int(matched.group(1)) / 1000., 1)
value = int(value * 10)
data['w1sensor_temp_' + identifier] = value
except Exception as error:
Copy link
Member

Choose a reason for hiding this comment

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

please make exception more specific

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ilyam8
Copy link
Member

ilyam8 commented Jun 14, 2018

@dspinellis thanks for the contribution 👍

@dspinellis
Copy link
Contributor Author

Thanks! I pushed a commit addressing your comments. I can then squash the commits when the PR passes code review.

value = round(int(matched.group(1)) / 1000., 1)
value = int(value * 10)
data['w1sensor_temp_' + identifier] = value
except OSError as err:
Copy link
Member

Choose a reason for hiding this comment

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

add IOError here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, done!

@dspinellis
Copy link
Contributor Author

I squashed my commits following your approval of the changes.

# default module values (can be overridden per job in `config`)
update_every = 5
priority = 60000
retries = 60
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm mistaken, you're using the same number of retries as the default, in which case this line can probably be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, retries and priority can be removed since it is current default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you; I removed them.

Copy link
Member

@Ferroin Ferroin left a comment

Choose a reason for hiding this comment

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

Beyond the one codre comment I left (which isn't really critical), looks good to me.

@ilyam8
Copy link
Member

ilyam8 commented Jun 14, 2018

@dspinellis please do a rebase

Multiple 1-Wire temperature sensors are auto-detected and monitored.
Displayed sensor names are user-configurable.
@dspinellis
Copy link
Contributor Author

I rebased and squashed the commit to remove the unneeded default values.

@ktsaou
Copy link
Member

ktsaou commented Jun 15, 2018

Well done!
Thank you @dspinellis !

@ktsaou ktsaou merged commit 9598db2 into netdata:master Jun 15, 2018
@Ferroin Ferroin mentioned this pull request Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants