load-average
Load Average
To get server load average via API
Required Parameters
Filed | Description | Example |
apiuser | The API user name | eenos_api |
apiauth | The API user password | eenos123 |
Request URL
Post URL = /load-average/
Full URL = https://your-host-name:5555/api/load-average/
Example CURL Command
curl -X POST -d "apiuser=eenos_api&apiauth=eenos123" https://your-host-name:5555/api/load-average/
Output
{'data': {'load_average': '0.23 0.41 0.37'},
'info': 'Current server load',
'status': 200}
Python Code
import requests
from pprint import pprint
# The api url
api_ulr='https://your-host-name:5555/api/load-average/'
# The data in dictionary format
data={
'apiuser': 'eenos_api',
'apiauth':'eenos123'
}
try:
result=requests.post(api_ulr, data = data)
pprint(result.json())
except Exception as e:
pprint(str(e))
pass
PHP Code
<?php
// The API URL
$url='https://your-host-name:5555/api/load-average/';
//The data you want to send via POST
$fields= [
'apiuser' => 'eenos_api',
'apiauth' => 'eenos123'
];
//url-ify the data for the POST
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
echo $result;
?>