Netdata convert uptime seconds to days

Hi,
I’m using Netdata to collect performance data from my servers.
I would like to see the number of days since last reboot.
I’m able to get the uptime from the server, but it is in seconds and I want to see it in days.
My current configuration is:

sensor:
  - platform: netdata
    host: <Server IP>
    port: 19999
    name: Server1
    resources:
      uptime:
        data_group: system.uptime
        element: uptime

How can I do this conversion?

One day is 86400 seconds (non leap day).
So divide by 86400 and depending on if you want it as a float or int cast it to that or round the value.

Thanks for your answer.
I know its 86400 seconds in 24 hours, but I was unable to configure it in the configuration.yaml file.

Any advice will be appreciated :grinning:

It will need to be a template sensor.

{{ states.sensor.server1 / 86400 | int }}

Or what the sensor you have is called.
I don’t think you can edit that sensors state.

I updated the configuration:

      uptime:
        data_group: system.uptime
        value_template: {{ states.sensor.Server1 / 86400 | int }}

But I’m getting a configuration error:
Error loading /config/configuration.yaml: invalid key: “OrderedDict([(‘states.sensor.Server1 / 86400 | int’, None)])”
in “/config/configuration.yaml”, line 32, column 0

What am I missing here?

As I said, I don’t think you can edit the current entity.
You need to create a new with this value as a calculation.

See https://www.home-assistant.io/integrations/template/

Hi,
I tried to solve the same problem yesterday. And I have came across this post. Thx Hellis81 for “little kick” in the right direction. I don’t know how numlock-master progressed, but for me the configuration works like this:

sensor:
  # NetData
  - platform: netdata
    host: 192.168.1.1
    port: 19999
    name: Turris 
    resources:
      connection tracker:
        data_group: netfilter.conntrack_sockets
        element: connections
        icon: mdi:cellphone-arrow-down
      uptime:
        data_group: system.uptime
        element: uptime
        icon: mdi:av-timer
        
# Netdata prezentace 
  - platform: template
    sensors:
      turris_uptime_day:
        friendly_name: "Uptime"
        unit_of_measurement: 'days'
        value_template: "{{ (states('sensor.turris_uptime')|float / 86400)|round(1)}}"
        icon_template: mdi:av-timer
      
      turris_active_connection:
        friendly_name: "Aktivní spojení"
        unit_of_measurement: ''
        value_template: "{{ states('sensor.turris_connection_tracker')|float / 1 }}"
        icon_template: mdi:cellphone-arrow-down

And in dashboard looks like:.

image

1 Like

I was pretty lost for the last couple of days (nights…) but your post, Mag_Re, did it and now it’s working!
Thanks.

Glad to hear it. I just have to point out to you one more bug for netdata integration, which has been standing for a long time. And it bothered me quite a bit.

You can use only one element for the same data group. And so You can´t use same data group twice ( I have tried bypass for this bug an I have failed :frowning:)