cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
341
Views
2
Helpful
2
Replies

How to get total power consumption data via GNMI?

rc-dev
Level 1
Level 1

I have been trying to collect telemetry data and I am getting a hard time obtaining power data.
Here's a sample telemetry collector config (telegraf):

```

[[inputs.gnmi]]
name_prefix = "app.company.network.device."
addresses = ["${HOST_ADDRESS}"]
username = "${USERNAME}"
password = "${PASSWORD}"
encoding = "json_ietf"
redial = "10s"
[[inputs.gnmi.subscription]]
name = "ps"
origin = "openconfig"
path = "/components/component/power-supply/state"
subscription_mode = "sample"
sample_interval = "60s"

```

According to YANGSUITE, I should get Datatype:`ieeefloat32` in Basetype:`binary`, but for some reason I get unreadable values like this:

```

app.company.network.device.ps,
device=DEV-SW-01,
host=dev-server,
name=PowerSupply1/B,
telemetry_source=entec-network openconfig_platform_psu:input_voltage="Q1HAAA==",
openconfig_platform_psu:output_current="P3YEGQ==",
openconfig_platform_psu:output_voltage="QmF3zw==",
openconfig_platform_psu:output_power="QlMAAA==",
openconfig_platform_psu:enabled=true,
openconfig_platform_psu:capacity="RDLAAA==",
openconfig_platform_psu:input_current="Psk3TA==" 1709529211201225000

```

Can anyone tell my what kind of encoding is this?
Other yang models sends the data correctly, but for `openconfig-platform-psu` the data is somehow encoded?
It's not base64, I already tried to decode it.
Can anyone shed some light please?

For Additional Info:

SW: `C9300-48UXM`

IOS-XE ver: `17.09.04a`

2 Accepted Solutions

Accepted Solutions

Torbjørn
Spotlight
Spotlight

These values are base64 encoded ieeefloat32 as described. If you decode from base64 to binary, you can quite easily convert it to ieeefloat32. For example:

Base64: QmF3zw== (output voltage)

Binary: 01000010 01100001 01110111 11001111

Float32: 56.367

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

View solution in original post

Base64 encoding is sometimes used for binary data transmission, it's not the default for GNMI with protobuf encoding as far as i recall. Try your telegraf configuration using the encoding parameter with a value "binary" in the [[inputs.gnmi]] section, this will tell GNMI to retrieve the data in raw binary format here.

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

2 Replies 2

Torbjørn
Spotlight
Spotlight

These values are base64 encoded ieeefloat32 as described. If you decode from base64 to binary, you can quite easily convert it to ieeefloat32. For example:

Base64: QmF3zw== (output voltage)

Binary: 01000010 01100001 01110111 11001111

Float32: 56.367

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

Base64 encoding is sometimes used for binary data transmission, it's not the default for GNMI with protobuf encoding as far as i recall. Try your telegraf configuration using the encoding parameter with a value "binary" in the [[inputs.gnmi]] section, this will tell GNMI to retrieve the data in raw binary format here.

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io