You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exposes the Linux /proc and /sys filesystems with a series of classes.
Additionally provides extra classes :
- all data is returned as python dictionaries.
- static data is memoized to improve performance.
NB - this module will only work on Linux.
Usage
From python3
The simplest interface is to the Resources module which takes a list of keys
to specify which /proc or /sys files to read:
Access all keys
#!/usr/bin/env python3importpprintfromlnxprocimportResourcesres=Resources() # will read all resourcesres.read()
data=res.normalize()
pprint.pprint(data)
Show available keys
To show available keys and the corresponding file for each key:
Normally the proc and sys filesystems are rooted at '/'. In some cases
such as inside a docker container they may have been mapped in at a
different location. An example is shown in the alpineapi container
where the root is /hostfs.
#!/usr/bin/env python3importpprintfromlnxprocimportResourcesres=Resources(root='/hostfs') # will read all resourcesres.read()
data=res.normalize()
pprint.pprint(data)
REST APi
See script buildscripts/test.sh.
The endpoints are:
- /keys # lists available keys
- /resource # return json output for all resources and pids
- /resource/<key> # return json output e.g. /resource/stat
- /pid/<pid>/<key> # return json output for pid e.g. /pid/23012/stat
Development
This repo uses docker as an isolation environment. Install:
- curl
- make
- docker-ce
To make:
make
To make changes, edit files and execute:
make unittest
For other make targets see buildscripts/README.md