So last Feburary I added the DS18b20 external sensor to three of my Raspberry Pies to monitior temps around the house etc. One of the sensors are in the loft area of the house and thus are exposed to outside temps. Today was the first day with around -8c here in my area. And now my Librenms is reporting 4.4 million Celcius and wrecked the rrd graphs. Since I am work right now I cannot post to much info as I cannot access the rpi’s remotely.
Anywas this issue was escalated to Net-snmp - but here we are again 10 months later with the same issue.
laf
22 November 2024 01:46
2
We graph the data sent to us but without poller debug info we can’t really do much
Yeah sure, as soon as I can. But in the meantime…
opened 07:58AM - 05 Dec 23 UTC
There are several discussions around where people have small servers in places w… here it gets cold and their temperature graphs stop working or they report very very high numbers, such as:
- https://github.com/librenms/librenms/issues/15609
- https://www.reddit.com/r/LibreNMS/comments/18ah8wo/submitted_a_bug_report_any_help_from_reddit/
The value is gathered in `netsnmp_sensor_arch_load()` at https://github.com/net-snmp/net-snmp/blob/759421b42563832fcd28559d438649b0f97f0389/agent/mibgroup/hardware/sensors/lmsensors_v3.c#L79-L81
with the return value being a double which allows negative temperatures.
The value is then changed to a Gauge32 at lmSensorsTable_handler:
https://github.com/net-snmp/net-snmp/blob/759421b42563832fcd28559d438649b0f97f0389/agent/mibgroup/ucd-snmp/lmsensorsMib.c#L224-L227
The issue is a Gauge32 cannot show a negative number, this is what the MIB has defined for this OID so the implementation is correct as far as MIB is concerned.
My suggestion is:
- Update the lmSensors MIB to have an additional field, not sure if the old temperature should be deprecated.
- Update the handler for this new field and convert it to an Integer32
My expectation is its a handful lines of code to do this. If the approach is ok I can even create a PR for it. I'm not sure what the mechanics are of updating the MIB though.
The mib change would be something like:
```
lmTempSensorsValue OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS deprecated
DESCRIPTION
"The temperature of this sensor in mC.
This object has been deprecated in favor of
'lmTempSensorsTemperature(4), which can display
temperatures below 0 degrees Celcius."
::= { lmTempSensorsEntry 3 }
lmTempSensorsTemperature OBJECT-TYPE
SYNTAX Integer32
UNITS "mCel"
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The temperature of this sensor in mCel."
::= { lmTempSensorsEntry 4 }
```
I changed the unit from mC to mCel to follow RFC8428 and currently, its reporting the temperature in milliCoulombs. That's a minor thing in any case.
Okay here we go:
hostname: 192.168.1.50 (unix)
ID: 6
OS: linux
IP: 192.168.1.50
#### Load poller module core ####
Uptime: 1 week 1 day 22 hours 9 minutes 52 seconds
>> SNMP: [3/0.12s] MySQL: [4/0.10s] RRD: [2/0.00s]
>> Runtime for poller module 'core': 0.0953 seconds with 164056 bytes
#### Unload poller module core ####
#### Load poller module os ####
Location: Oslo,Norway
Hardware: Generic ARMv8 64-bit
OS Version: 6.1.21-v8+
OS Features:
Serial:
>> SNMP: [0/0.00s] MySQL: [1/0.01s] RRD: [1/0.00s]
>> Runtime for poller module 'os': 0.0111 seconds with 101752 bytes
#### Unload poller module os ####
#### Load poller module availability ####
1 day : 100%
1 week : 100%
1 month : 99.977%
1 year : 99.981%
>> SNMP: [0/0.00s] MySQL: [13/0.18s] RRD: [5/0.00s]
>> Runtime for poller module 'availability': 0.0429 seconds with 55416 bytes
#### Unload poller module availability ####
#### Load poller module sensors ####
Checking (snmp) temperature temp1...
Checking (snmp) temperature w1_slave_temp-virtual-0:temp1...
31.154 C
4294966.421 C
>> SNMP: [1/0.83s] MySQL: [4/0.11s] RRD: [3/0.00s]
>> Runtime for poller module 'sensors': 0.8416 seconds with 5072 bytes
#### Unload poller module sensors ####
#### Load poller module processors ####
Processor: 32%
Processor: 34%
Processor: 26%
Processor: 17%
>> SNMP: [1/0.03s] MySQL: [5/0.14s] RRD: [5/0.00s]
>> Runtime for poller module 'processors': 0.0525 seconds with 58552 bytes
#### Unload poller module processors ####
#### Load poller module mempools ####
hrstorage [system]: Physical memory: 17% 656.66 MiB / 3.71 GiB
hrstorage [virtual]: Virtual memory: 60% 2.28 GiB / 3.8 GiB
hrstorage [buffers]: Memory buffers: 3% 103.64 MiB / 3.71 GiB
hrstorage [cached]: Cached memory: 41% 1.53 GiB / 3.71 GiB
hrstorage [shared]: Shared memory: 1% 51.41 MiB / 3.71 GiB
hrstorage [swap]: Swap space: 0% 0 B / 100 MiB
>> SNMP: [1/0.03s] MySQL: [6/0.19s] RRD: [7/0.00s]
>> Runtime for poller module 'mempools': 0.0703 seconds with 92672 bytes
#### Unload poller module mempools ####
#### Load poller module storage ####
Storage /: hrstorage
65%
>> SNMP: [1/0.09s] MySQL: [2/0.05s] RRD: [2/0.00s]
>> Runtime for poller module 'storage': 0.1011 seconds with 8192 bytes
#### Unload poller module storage ####
#### Load poller module netstats ####
icmp
ip
ip_forward
snmp
udp
tcp
>> SNMP: [8/0.32s] MySQL: [0/0.00s] RRD: [6/0.00s]
>> Runtime for poller module 'netstats': 0.3368 seconds with 24872 bytes
#### Unload poller module netstats ####
#### Load poller module hr-mib ####
Processes Users
>> SNMP: [1/0.05s] MySQL: [2/0.05s] RRD: [3/0.00s]
>> Runtime for poller module 'hr-mib': 0.0660 seconds with 24216 bytes
#### Unload poller module hr-mib ####
#### Load poller module ucd-mib ####
>> SNMP: [2/0.06s] MySQL: [0/0.00s] RRD: [19/0.01s]
>> Runtime for poller module 'ucd-mib': 0.0742 seconds with 8520 bytes
#### Unload poller module ucd-mib ####
#### Load poller module ipSystemStats ####
ipv4 ipv6
>> SNMP: [1/0.04s] MySQL: [0/0.00s] RRD: [3/0.00s]
>> Runtime for poller module 'ipSystemStats': 0.0496 seconds with 3280 bytes
#### Unload poller module ipSystemStats ####
#### Load poller module ports ####
Caching Oids: Full ports polling ifDescr ifAdminStatus ifOperStatus ifLastChange ifType ifPhysAddress ifMtu ifInErrors ifOutErrors ifInDiscards ifOutDiscards dot3StatsDuplexStatus
Port lo: lo (1 / #24) disabled.
Port eth0: eth0 (2 / #27) dot3Duplex VLAN = ? eth0bps(0 bps/12.52 Mbps)bytes(0 B/101.48 MiB)pkts(1.5 kpps/1.54 kpps)
Port wlan0: Device 02d0:a9a6 (3 / #30) disabled.
>> SNMP: [14/0.47s] MySQL: [4/0.11s] RRD: [2/0.00s]
>> Runtime for poller module 'ports': 0.5112 seconds with 50032 bytes
#### Unload poller module ports ####
#### Load poller module customoid ####
>> SNMP: [0/0.00s] MySQL: [1/0.02s] RRD: [1/0.00s]
>> Runtime for poller module 'customoid': 0.0060 seconds with 2512 bytes
#### Unload poller module customoid ####
#### Load poller module ucd-diskio ####
mmcblk0 mmcblk0p1 mmcblk0p2
>> SNMP: [1/0.04s] MySQL: [1/0.01s] RRD: [4/0.00s]
>> Runtime for poller module 'ucd-diskio': 0.0540 seconds with 13168 bytes
#### Unload poller module ucd-diskio ####
#### Load poller module entity-physical ####
>> SNMP: [0/0.00s] MySQL: [0/0.00s] RRD: [1/0.00s]
>> Runtime for poller module 'entity-physical': 0.0029 seconds with 6832 bytes
#### Unload poller module entity-physical ####
#### Load poller module applications ####
Application: portactivity, app_id=14: ..........................................
>> SNMP: [1/0.11s] MySQL: [4/0.09s] RRD: [2/0.00s]
>> Runtime for poller module 'applications': 0.1264 seconds with 146624 bytes
#### Unload poller module applications ####
#### Load poller module ntp ####
>> SNMP: [0/0.00s] MySQL: [0/0.00s] RRD: [1/0.00s]
>> Runtime for poller module 'ntp': 0.0018 seconds with 1768 bytes
#### Unload poller module ntp ####
Enabled graphs (27): poller_perf ping_perf poller_modules_perf uptime availability netstat_icmp netstat_icmp_info netstat_ip netstat_ip_frag netstat_snmp netstat_snmp_pkt netstat_udp netstat_tcp hr_processes hr_users ucd_cpu ucd_swap_io ucd_io ucd_contexts ucd_interrupts ucd_io_wait ucd_cpu_steal ucd_load ipsystemstats_ipv4 ipsystemstats_ipv4_frag ipsystemstats_ipv6 ipsystemstats_ipv6_frag
>>> Polled nms.gwdebian.net (6) in 3.605 seconds <<<
#### Start Alerts ####
Rule #3 (Syslog, Authentication failure on Device):
Status: NOCHG
Rule #4 (Space on / is >= 90%and < 95%in use):
Status: NOCHG
#### End Alerts (0.0408s) ####
### Start Device Groups ###
### End Device Groups (0.0113s) ###
SNMP [35/2.19s]: Snmpget[17/1.51s] Snmpwalk[18/0.68s]
SQL [66/1.39s]: Select[41/0.67s] Update[24/0.71s] Delete[1/0.01s]
RRD [69/0.04s]: Update[69/0.04s]
and the output of a python script quering the same sensor:
pi@librenms:~ $ python tempsensor.py
22/11/24@07:54:14 - -1.0 C
22/11/24@07:54:17 - -0.9 C
22/11/24@07:54:20 - -0.9 C
22/11/24@07:54:23 - -1.0 C
22/11/24@07:54:26 - -1.0 C
And the source of said script:
#!/usr/bin/env python
import os
import glob
import time
import datetime
def read_temp(decimals = 1, sleeptime = 3):
"""Reads the temperature from a 1-wire device"""
device = glob.glob("/sys/bus/w1/devices/" + "28*")[0] + "/w1_slave"
while True:
try:
timepoint = datetime.datetime.now()
with open(device, "r") as f:
lines = f.readlines()
while lines[0].strip()[-3:] != "YES":
time.sleep(0.2)
lines = read_temp_raw()
timepassed = (datetime.datetime.now() - timepoint).total_seconds()
equals_pos = lines[1].find("t=")
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
temp = round(float(temp_string) / 1000.0, decimals)
print(time.strftime("%d/%m/%y@%H:%M:%S - ")+str(temp)+" C")
time.sleep(sleeptime-timepassed)
timepoint = datetime.datetime.now()
except KeyboardInterrupt:
break
if __name__ == "__main__":
read_temp()
The script has nothing to do with LibreNMS - just providing data before I hit the sack!
And about Librenms:
|Version |24.11.0 - Thu Nov 21 2024 00:15:08 GMT+0100|
|---|---|
|Database Schema |2024_10_13_162920_add_custom_map_nodeimage_column (307)|
|Web Server |Apache/2.4.62 (Raspbian)|
|PHP |8.3.10|
|Python |3.9.2|
|Database |MariaDB 10.5.26-MariaDB-0+deb11u2|
|Laravel |10.48.23|
|RRDtool |1.7.2|