JSON-API
Retrieve JSON data from a web server or a local script. Each property of the returned JSON structure will then be available as a symbol in AnyViz. Arrays and nested objects are supported. Note that this connection type can only be used for reading.
Connection Parameters
URL/Path |
For HTTP-GET requests, provide the URL starting with http:// or https:// .
To call a script, the absolute path must be provided (not available on Windows).
|
Interval (sec) | The Cloud Adapter attempts to keep all data up-to-date every second. If this request frequency overloads the endpoint, a custom interval in seconds can be specified. |
Example Script
As an example of a custom script, the following content can be saved as getSystemInfo.sh
on the Linux system of the Cloud Adapter.
Then, under "URL/Path," the absolute path to the file can be specified to monitor the CPU usage and memory consumption of the operating system in AnyViz.
#!/bin/bash
get_cpu_usage() {
top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}'
}
get_memory_usage() {
free | awk '/Mem/{printf "%.2f", $3/$2*100}'
}
create_json() {
cpu_usage=$(get_cpu_usage)
memory_usage=$(get_memory_usage)
echo "{\"cpu_usage\": $cpu_usage, \"memory_usage\": $memory_usage}"
}
create_json