Skip to content

Instantly share code, notes, and snippets.

@merry-swjung
Created June 8, 2020 15:31
Show Gist options
  • Save merry-swjung/92be621c5da4a29b4ed23a4eaa1c8e24 to your computer and use it in GitHub Desktop.
Save merry-swjung/92be621c5da4a29b4ed23a4eaa1c8e24 to your computer and use it in GitHub Desktop.
$ vi /home/usage/check_data.py
...
#cpu usage
status, cpu_usage = commands.getstatusoutput("""mpstat | tail -n 1 | awk '{print 100-$NF}'""")
...
$ tail /var/log/usage_per_min.log
LOG_DATE:2020/06/08 15:13 | CPU_USAGE:1.46% | CONN_NUMBER:0 | DISK_USAGE:3.72% (total 80.14GB) | MEM_USAGE:4.9% (total 3.92GB)
LOG_DATE:2020/06/08 15:14 | CPU_USAGE:1.46% | CONN_NUMBER:0 | DISK_USAGE:3.72% (total 80.14GB) | MEM_USAGE:4.9% (total 3.92GB)
LOG_DATE:2020/06/08 15:15 | CPU_USAGE:1.46% | CONN_NUMBER:0 | DISK_USAGE:3.72% (total 80.14GB) | MEM_USAGE:4.9% (total 3.92GB)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment