ytti / oxidized-web

Web UI + RESTful API for Oxidized
118 stars 72 forks source link

Querying `/node/stats?format=json` does not properly serialize the node stats #222

Open ctrowat opened 3 years ago

ctrowat commented 3 years ago

When making a GET request to the specified endpoint node stats are not returned correctly. Instead I get a response like this:

{
    "DEVICE1": "#<Oxidized::Node::Stats:0x000055fbadc63230>",
    "DEVICE2": "#<Oxidized::Node::Stats:0x000055fbadc31168>",
    "DEVICE3": "#<Oxidized::Node::Stats:0x000055fbadb44110>",
    "DEVICE4": "#<Oxidized::Node::Stats:0x000055fbadc2a750>",
...
}
fernandolcx commented 2 years ago

same here

robertcheramy commented 2 months ago

I can reproduce. ?format=text also not working.

danwalkeruk commented 1 month ago

Confirmed here, I made an issue on the other repo https://github.com/ytti/oxidized/issues/3234, and it has been mentioned here before https://github.com/ytti/oxidized-web/issues/182

I have zero Ruby knowledge, but from some brief poking and GPT-ing, it seems to be that within lib/oxidized/web/webapp.rb there needs to be a serialisation method for the Node::Stats class, as currently when it's converted to json, you just get the above.

Anyone with Ruby knowledge able to take a look? Doesn't seem a big fix for this one.