On Fri, Mar 20, 2020 at 12:05 PM Hardik jain <[email protected]>
wrote:
> 8) *Adding possibility to collect memory (RAM), CPU and flash (disk
> space) usage of devices via the API*:
> I did a bit research to find out that currently only openwrt (linux based)
> is supported by openwisp-controller as a backend (LEDE has been removed in
> latest release, if I am not wrong). So, I had a simple way of collecting
> the data, I do it very often on my Ubuntu to check details when it hangs
> (sometimes) :smile:. Create a system_check.sh shell script.
> system_check.sh file
> # !/bin/sh
> free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n",
> $3,$2,$3*100/$2 }'
> df -h | awk '$NF=="/"{printf "Disk Usage: %d/%dGB (%s)\n", $3,$2,$5}'
> top -bn1 | grep load | awk '{printf "CPU Usage: %.0f%%\n", $(NF-2)*100}'
>
> # convert it into an executable
> chmod +x system_check.sh
>
> # This results in:
>
> ~$ ./system_check.sh
> Memory Usage: 6156/7676MB (80.20%)
> Disk Usage: 27/187GB (15%)
> CPU Usage: 74%
>
> My query is will it be acceptable if I use this simple shell script to
> import data in a python file in api directory, convert it into a JSON
> object (keeping in mind NETJSON device_monitoring spec.) or an alternative
> approach would be required here.
>
>
There's a better way to do it on OpenWRT, try this:
ubus call system info
I forgot to share some scripts I implemented to collect these metrics:
https://github.com/openwisp/lua-monitoring
Federico
--
You received this message because you are subscribed to the Google Groups
"OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/openwisp/CAERYH6UJ1bR2N2rbTP4-unHY5AX6ds3VC2PyarpM1yjr%3DWEhLQ%40mail.gmail.com.