Giter Site home page Giter Site logo

lukastautz / cpu_logger Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 42 KB

cpu_logger is a minimal program written in C logging the load, steal and memory usage of a linux system. It can also generate html files with graphical statistics (using dygraphs) and averages.

License: GNU General Public License v3.0

Makefile 6.66% C 93.34%
cpu-load cpu-monitoring cpu-steal logger memory-usage minimal monitoring

cpu_logger's Introduction

cpu_logger

cpu_logger is a minimal program written in C logging the load, steal and memory usage of a linux system. It can also generate html files with graphical statistics (using dygraphs) and averages.

Internals

cpu_logger saves the data in a binary file. It appends the data in the interval specified when calling cpu_logger.

Configuration

You can edit config.h if you don't want to save for example the used memory.

Memory consumption

On my machines it needs around 56 kB of memory (32 kB RSS), although that does depend on the configuration and the cpu architecture. (Note that depending on the program used to measure the used amount of memory, the displayed consumption may be higher as Linux file cache influences it greatly (unfortunately caching is hard/impossible to disable as O_DIRECT has too much disadvantages to be used).)

Disk space needed

It needs (with all features enabled) 10 bytes per interval. If you for example log it every 10 seconds it needs approx. 30 MiB of disk space a year. I recommend that you log to a ramdisk as

Binary size

The binaries are linked against dietlibc 12 KiB big each.

Building

Simply call make. It is recommended to use dietlibc, as the static binaries linked against dietlibc are smaller (and need way less memory) than the dynamically linked against glibc. However, if dietlibc is not installed, the programs are linked against glibc. That's also the cause for possible (harmless) errors and the ugly Makefile.

Starting daemon

Simply call cpu_logger LOG_FILE INTERVAL_IN_SECONDS (after you built it and copied the binaries to /bin). There is also a systemd-service-file example (although it probably isn't the best possible). The daemon doesn't need to run as root, it only needs read access to /proc/meminfo and /proc/cpuinfo and write access to the log file.

Generating the html file

Simply call cpu_logger_html LOG_FILE. You can see a live example at layer7 here. The html files have the disadvantage that as all data is contained the file can get quite large.

Why?

The goal of cpu_logger is that it absolutely doesn't affect the system. I would say that with 52 KiB memory usage and near to no cpu usage (as it sleeps the most time), that goal is reached. It of course doesn't have as much functions as the bigger programs, but that wasn't the goal.

I have a suggestion/It doesn't work/I found a bug

Feel free to open an issue or pull request.

Steal time

Please note that steal time does only work (AFAIK) with KVM, and the provider can disable it or provide arbitrary values. If the cpu speed varies, but the displayed steal is always 0.00%, steal time reporting is likely disabled.

cpu_logger's People

Contributors

lukastautz avatar

Stargazers

Mike Wazar avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.