Closed mivale closed 1 year ago
Yes you can use the API to retrieve a specific item.
See: https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API#get-api2pluginitem
Hi,
I read this and tried it, but got an error : http://host:61208/api/2/fs/size
Error: 500 Internal Server Error
Sorry, the requested URL 'http://host:61208/api/2/fs/size' caused an error:
Internal Server Error
Might this be because the fs plugin returns its values in an array rather than as an object?
Edit:
This does work:
http://host:61208/api/2/fs/fs_type/ext4
But it naturally returns
{"ext4": [{"size": 7138959360, "device_name": "/dev/sda1", "fs_type": "ext4", "key": "mnt_point", "used": 4026884096, "percent": 56.4, "free": 2725834752, "mnt_point": "/"}]}
I've also tried
http://host:61208/api/2/fs/mnt_point// => 404 http://host:61208/api/2/fs/mnt_point/%2F => 404
What i'd like is the stats for mnt_point / :-)
Sorry, the Fs plugin return a list of dict, so you need to use: https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API#get-api2pluginitem
Edit: https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API#get-api2pluginitemvalue
Please see my edit to the previous comment :-)
Also see my edit to my previous comment :)
==> https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API#get-api2pluginitemvalue
I see. But I don't see how to retrieve the values for mnt_point == /
Can you help me please by providing an example? /api/2/fs/mnt_point// gives me an error
Sorry, but do not have the answer... You need to encode the "/" in the request (perhaps try to replace it by the %2F code).
Tried that already.
I will give up for now since I have no time to look into the source.
Thanks for your time :-)
Ok, keep us inform if you find a solution. I am interested.
Hi, I'm currently also trying to get fs stats from glances, but this leading "/" for all moint points makes the current rest API unusable for this plugin. Impossible also to use the device name as a key, for the same reason. Most of the tools I tried weren't able to pass the correct URI (even using curl --path-as-is ), same for browser content. A solution I see would be for glances to expose some UUID for each mount point, otherwise I can't see how that can be used.
Thanks to StackOverflow (https://stackoverflow.com/questions/19767484/passing-arguments-containing-slashes-to-bottle) i found a way to do this by changing the routing in Bootle (the API Framework used under the wood by Glances).
On the develop branch, it's now work:
$ curl "http://0.0.0.0:61208/api/3/fs/mnt_point//" | json_pp
{
"/" : [
{
"device_name" : "/dev/mapper/ubuntu--gnome--vg-root",
"free" : 62967816192,
"fs_type" : "ext4",
"key" : "mnt_point",
"mnt_point" : "/",
"percent" : 72.7,
"size" : 243334156288,
"used" : 167978885120
}
]
}
I am going to patch the develop branch.
Patch will be release in the next version of Glances.
Hi,
Couldn't find this is in the docs. Since the fs plugin returns its API data as an array, is it possible to retrieve only the data for a certain mount point?
I have two mount points, / and /boot and want to check them both separately using the API.
The docs are unclear on this point. Browsing the code wasn't very helpful either, but that's on me!
Is it possible? If not, it just as easy to retrieve everything :-)