Tip: Read out system load via JSON API
As an example of an individual script, the following content can be stored as getSystemInfo.sh on the Linux system of the Cloud Adapter. The absolute path to the file can then be specified under “URL/Path” in order to be able to monitor the CPU utilization 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