2 min read

Host Temperature Monitoring with NewRelic

Whether you’re a homelab enthusiast with a rack of servers, or just a tinkerer with a Raspberry Pi running a few services, temperature might be something worth paying attention to. These devices run 24/7, and without alerts, you have no idea if something is off. It could be that:

  • the environment they’re sitting in could get too hot, or
  • the software running on them is causing issues

None of the above would end well if left unchecked.

In this guide, I’ll show you how I send host temperature data to New Relic and make it usable.

I use New Relic because I’m already familiar with it, and its free tier is enough for a small setup.

Collect temperature data

On Linux, CPU temperature is typically exposed via sysfs:

/sys/class/thermal/thermal_zone*/temp

The value is in millidegrees Celsius. For example, 55000 means 55°C.

Send it to New Relic

New Relic’s Flex integration (nri-flex) can run shell commands and ingest the output as metrics.

Here’s a minimal configuration:

integrations:
  - name: nri-flex
    config:
      name: systemTempIntegration
      apis:
        - name: CpuTemp
          commands:
            - run: 'echo -n "cpu_raw="; cat /sys/class/thermal/thermal_zone1/temp'
              split_by: "="
          math:
            cpu: ${cpu_raw} / 1000

This does three things:

  • runs a command to read the raw temperature
  • parses it into a key-value pair
  • converts it to degrees Celsius

Visualize

Create a dashboard in New Relic and add a timeseries chart with the following query:

SELECT average(cpu) FROM CpuTempSample WHERE hostname = 'your-host' TIMESERIES

That’s usually enough to see trends and spot spikes.

Alerting

If you care about thresholds, add an alert condition on the cpu metric.

The exact numbers depend on your hardware, but a simple setup could be:

  • warning around 70°C
  • critical around 85°C

That’s it. A small integration, one dashboard, and optional alerts.