Real-time CPU and memory monitor to measure and visualize resources consumption in homemade projects. This is a simple project inspired by a question from StackOverflow: https://stackoverflow.com/questions/41133281/better-way-to-implement-matplotlib-animation-with-live-data-from-cpu
- Make sure that you have Python and virtualenv installed
- Run virtualenv into project's folder and use
pip
to installrequirements.txt
pip install -r requirements
- Run the script as depicted below.
python monitor.py <memory_notation> <pid_file>
where memory_notation:
k = kilobytes
m = megabytes
g = gigabytes
otherwise = bytes
// this snippet was tested only on Linux
int savePid(String filepath) {
int pid = Integer.parseInt(new File("/proc/self").getCanonicalFile().getName());
File tmp = new File(filepath);
tmp.write(pid);
return pid;
}