proc-api/DOCUMENTATION.md

132 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2022-04-28 20:48:15 +00:00
DOCUMENATION
============
The following is the listing of all supported routes and methods by the API.
The API is broken down into the different actions
Custom headers
--------------
When submitting a GET request to the `/proc` endpoints,
you can specify the `Accept:` header and choose
exactly what format you would like back. The API accepts the following mime
types
* `application/json`
* *Default response*
* Returns as a json dictionary with sensible keys
* `text/plain`
* Returns exact response from the `/proc` file system
* For more about the format of these responses, refer to the proc(5) manpage
2022-04-29 19:57:25 +00:00
Security tokens
---------------
The application provides the `-a` flag, which accepts a path as a required
argument. The file specified in the path should contain a series of strings,
each on a new line. Each line represents a valid token that the client can send
to authorize the request. This token must be send in a `Authorization:` header.
If the token is not given, or the wrong token is given, the server will instead
return a 403.
2022-04-28 20:48:15 +00:00
Proc file responses
============
[GET] /proc/uptime
-------------
* returns uptime and idle time
2022-04-29 16:57:33 +00:00
* Same as /proc/uptime file
2022-04-28 20:48:15 +00:00
Sample response
```
{
"uptime": 72583.24
"idle" : 834157.72
}
```
[GET] /proc/meminfo
-------------------
* returns infomration regarding system memory
2022-04-29 16:57:33 +00:00
* All responses are in kB
* Same as /proc/meminfo file
2022-04-28 20:48:15 +00:00
2022-04-29 17:34:10 +00:00
[GET] /proc/loadavg
-------------------
* returns system load averaged over 1, 5, and 10 mins
* returns number of currently running processes over the total number of
process
* returns the last proccessed PID used
* Same as /proc/loadavg file
Sample response
```
{
"1" : 0.56,
"5" : 0.69,
"10" : 1.30,
"processes" : "2/849",
"lastPID" : 28225,
}
```
2022-04-29 17:54:52 +00:00
[GET] /proc/sys/kernel/hostname
--------------------------------
* returns hostname
* Same as /proc/sys/kernel/hostname file
Sample response
```
{
"hostname": "Samplebox"
}
```
2022-04-29 18:02:33 +00:00
Special formatted responses and aliases
2022-04-28 20:48:15 +00:00
===========================
2022-04-29 16:57:33 +00:00
[GET] /uptime
-------------
* Returns a redirect to /proc/uptime
2022-04-28 20:48:15 +00:00
[GET] /load
----------
2022-04-29 17:34:10 +00:00
* Returns a redirect to /proc/loadavg
2022-04-28 20:48:15 +00:00
[GET] /mem
----------
* returns memory usage
* formatted version of /proc/meminfo
* All responses are in kB
Sample response
```
{
"memtotal" : 16255116,
"memfree" : 2127320,
"memavailable" : 12324924,
}
```
2022-04-29 17:54:52 +00:00
[GET] /hostname
---------------
* Returns redirect to /proc/sys/kernel/hostname
2022-04-29 18:02:33 +00:00
[GET] /up
---------
* Always returns a 200 OK
* Can be used for testing latency