App to collect ram/cpu usage from OS and show it in pretty graphs

Overview

System info collector

This is simple app to collect data about system cpu and memory usage over time.

After collecting results into csv file, html file can be created with plot.

Screenshot

Why?

I needed a simple and fast application to collect basic information about the amount of RAM used and CPU consumption on a slow(4x1Ghz) 32 bit ARM computer which uses custom Linux OS build with Yocto.

I looked at a few applications like grafana, but they are too heavy or work in a client server architecture which in this case I would prefer to avoid.

How to use it?

This is console app, so that means that you need to use terminal to use it.

./system_info_collector -l debug -a collect-and-convert -o

should once per second print debug message about refreshed CPU and memory usage.

After a while you can click Ctrl+C once to stop collecting data and wait for automatic preparing and opening prepared html plot data.

SystemInfoCollector.mp4

Performance and memory usage

During testing on i7-4770, app used stable 15-20MB Ram and most of the time, cpu usage was lesser than 0.1%.

Sys-info library which I use have quite big overhead when finding cpu/ram usage for processes, so I plan to do some computations manually. So if you want to use as little resources as possible, you should use only collect basic os info without any processes(this is default mode).

In collect mode, app only needs to read cpu/ram usage and then save it to file, so that is why it uses so little resources.

Converting csv file to html file is more resource intensive, so should be done on more powerful computer.

Results from testing on i7-4770 250000 samples for memory, cpu total and per core usage - with 1s interval, collecting such number of samples should take ~3 days(I used smaller interval to mimic real usage):

Example of first 4 lines of csv file:

INTERVAL_SECONDS=1,CPU_CORE_COUNT=8,MEMORY_TOTAL=23943.921875
UNIX_TIMESTAMP,CPU_USAGE_TOTAL,CPU_USAGE_PER_CORE,MEMORY_USED
1688908461.4185224,0.00,0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00,10472.640625
1688908462.4186845,5.78,4.42;6.14;5.31;5.36;7.21;8.04;4.46;5.26,10473.49609375
  • CSV file size: 19.55 MiB
  • Loading and parsing csv file: 407 ms
  • HTML file size: 129 MiB (new versions use simple regex minimizer, so size should be ~30% smaller)
  • Creating html file: 1.68 s

Example commands

Collect used memory and cpu usage in interval of 1 second and save it to system_data.csv file

./system_info_collector

Collect and convert csv data and automatically open html file in browser, additionally will show more detailed logs

./system_info_collector -l debug -a collect-and-convert -o

Convert csv data file into html document with plot and open it in browser

./system_info_collector -a convert -d /home/user/data.csv -p /home/user/plot.html -o

Collect all basic data with interval of 0.2 seconds

./system_info_collector -l debug -a collect-and-convert -o -m memory-used -m memory-free -m memory-available -m cpu-usage-total -m cpu-usage-per-core -c 0.2

Collect memory and cpu usage of selected processes - will try to find process with command containing firefox in name - FIREFOX name will be used later in plot.

App can only track 1 process with certain name at once, so if two or more processes contains firefox in name, only info about first will be collected

./system_info_collector -e "FIREFOX|firefox" -e "Event Handler|/usr/bin/event_handler --timeout"

Shows help about available arguments

./system_info_collector --help

Running app when OS starts(Linux)

Simple way to collect OS data from start, is to create simple systemd service.

Copy app into /usr/bin folder and create folder for collected data

sudo cp system_info_collector /usr/bin/system_info_collector
sudo mkdir -p /opt/system_info_collector/ # To collect reports

creating service content

sudo touch /etc/systemd/system/system-info-collector.service
sudo gedit /etc/systemd/system/system-info-collector.service # open it with any text editor - I used gedit

paste this code there

[Unit]
Description=System Data Collector

[Service]
ExecStart=/usr/bin/system_info_collector -d /opt/system_info_collector/data.csv

[Install]
WantedBy=default.target

now start service

sudo systemctl daemon-reload
sudo systemctl start system-info-collector
sudo systemctl status system-info-collector # This should print "active (running)" if everything works fine, if there is failure, check log to see what happened
sudo systemctl enable system-info-collector # To enable running service when OS starts

now you can convert collected data with simple command

system_info_collector -a convert -d /opt/system_info_collector/data.csv -p /tmp/plot.html -o

CPU/Memory results

Cpu usage is shown in range between 0 and 100%, if computer have more than 1 core, cpu usage is divided by number of cores, to get value in proper range.

Memory usage is shown in MiB, with range from 0 to total memory size.

When checking for processes -1 is visible both in cpu/memory plot if searched process is not found.

Data file compatibility

Compatibility between different versions of app is not guaranteed, so if you want to collect create graphs from csv file, be sure that you use the same version of app.

Usually incompatibilities are quite easy to workaround by manually adding/removing records from csv file.

OS Support

Currently, fully supported is only Linux, due using manually reading /proc files(performance reasons).

App should also fully work on Mac, but on Windows capturing process cpu/memory usage is not supported(except that, everything should work fine).

License

MIT License

Copyright (c) 2023 Rafał Mikrut and contributors

You might also like...
Tool to draw low-resolution graphs in terminal
Tool to draw low-resolution graphs in terminal

lowcharts Tool to draw low-resolution graphs in terminal. lowcharts is meant to be used in those scenarios where we have numerical data in text files

An easy to use library for pretty print tables of Rust structs and enums.
An easy to use library for pretty print tables of Rust structs and enums.

tabled An easy to use library for pretty printing tables of Rust structs and enums. Table of Contents Usage Settings Style Themes ASCII Psql Github Ma

📺(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.
📺(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.

📺(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.

A small CLI tool to query ArcGIS REST API services, implemented in Rust. The server response is returned as pretty JSON.

A small CLI tool to query ArcGIS REST API services, implemented in Rust. The server response is returned as pretty JSON.

A pretty (simple) alternative to strace

lurk lurk is a simple and pretty alternative to strace. It allows the user to trace system calls of a process or of a command. In contrast to strace,

Designed as successor to Pretty-Good-Video for improved codec structure, API design & performance

Pretty Fast Video Minimal video codec designed as a successor to Pretty Good Video Goals are to improve: Quality API design Codec structure (Hopefully

😎 Pretty way of writing regular expressions in Rust

🔮 Write readable regular expressions The crate provides a clean and readable way of writing your regex in the Rust programming language: Without pret

A simple program to show a histogram on the terminal.

A simple program to show a histogram on the terminal.

Show unused code from multi-crate Rust projects

Warnalyzer Remove unused code from multi-crate Rust projects. The dead_code lint family of rustc is limited to one crate only and thus can't tell whet

Releases(0.2.0)
Owner
Rafał Mikrut
Rafał Mikrut
dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory

dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory. It's parallel by default and will max

Sebastian Thiel 1.8k Jan 2, 2023
Zenith - sort of like top or htop but with zoom-able charts, CPU, GPU, network, and disk usage

Zenith - sort of like top or htop but with zoom-able charts, CPU, GPU, network, and disk usage

Benjamin Vaisvil 1.6k Jan 4, 2023
A CLI tool which can help you automatically kill process of your choice. Useful for freeing up memory and CPU usage!

Quickiller There are always programs such as chrome that keep eating up your resources even when closed! The only way to prevent this is to kill all o

Codingsquirrel 1 Dec 8, 2021
A small script in rust to get the cpu usage in %'s with a gradient color for the text

cpu_usage-polybar A small script in rust to get the cpu usage in %'s with a gradient color for the text To get it to work on your PC you will have to

Sara 4 Apr 18, 2023
A simple code that will load a shellcode directly into RAM memory in a new process

「 ?? 」About RustSCLoader RustSCLoader is a simple code that has the intention of loading a shellcode directly into RAM memory in a new process that wi

null 5 May 15, 2023
Work to enable a Classic Mac (24-bit 68000) with ~16MB of RAM.

Apple SE FDHD ROM analysis In order to build a Mac clone that doesn't fully emulate the hardware (which is possible because the ROM abstracts hardware

Simon Frankau 6 Oct 6, 2023
belt is a command line app that can show your time from a list of selected time zones

A CLI app to show your time from a list of selected time zones, and a rust lib to parse dates in string formats that are commonly used.

Rollie Ma 23 Nov 4, 2022
Blazingly fast Rust CLI app to sync data from a folder of excel workbooks into generated c# code for unity usage

Extensions supported ( .xls, .xlsx, .xlsm, .xlsb, .xla, .xlam, .ods ) Speed Test Image shows the results of 5000defs synced from 2 workbooks and 5 she

null 4 Feb 16, 2023
Track and query Cargo dependency graphs.

cargo-guppy: track and query dependency graphs This repository contains the source code for: guppy: a library for performing queries on Cargo dependen

guppy 42 Dec 30, 2022
Kusa is a simple CLI tool that works on any platform and displays GitHub contribution graphs.

Kusa is a simple CLI tool that works on any platform and displays GitHub contribution graphs. Installation Homebrew (only macOS) $ brew tap Ryu0118/Ku

Ryu 103 Jun 18, 2023