summaryrefslogtreecommitdiff
path: root/src/print_cpu_usage.c
AgeCommit message (Collapse)Author
2020-03-28avoid out-of-bounds read after invalid %cpu conversionSamuel Holland
In the case where no CPU number is given, skipping a character of padding actually skips the null terminator, causing further iterations through the loop to read out of bounds. Have sscanf() return the number of characters read, instead of reconstructing it from the CPU number. This was observed as a failure in test 024-cpu-usage-invalid-cpu.
2019-07-29Improve NetBSD port. (#361)Thomas Klausner
Detect and link against ossaudio. Comment out unused code and functions.
2019-07-29print_cpu_usage: use buffered file APIMichael Stapelberg
fixes #343 fixes #344
2019-01-23Fix non Linux build for #309eplanet
2019-01-23Switch to autotools (#316)Michael Stapelberg
2018-11-07Fix error messageseplanet
2018-11-05print_cpu_usage.c: Support non-consecutive CPUsTwentyFourD
Fixes #308
2018-10-21print_cpu_usage: fix invalid %cpu placeholder outputGaël PORTAY
Currently, the module cpu_usage prints %cpu0 information for the invalid %cpu placeholder (i.e. the cpu number is missing). Consider the following configuration. order += "cpu_usage" cpu_usage { format = "cpu0=%cpu0 cpu1=%cpu1 cpu=%cpu" # missing cpu number -------------------^ } The configuration above produces the output below. $ i3status -c config i3status: trying to auto-detect output_format setting i3status: auto-detected "term" cpu0=-2% cpu1=-49% cpu=-2% cpu0=06% cpu1=02% cpu=06% cpu0=05% cpu1=06% cpu=05% ... The module prints %cpu0 at the third placeholder where it should report an error. This commit fixes this behavior by initializing `number' to -1. If the cpu is missing in %cpu placeholder, the sscanf function does not set `number'. Because `number' is -1 (lower to 0), an error is reported and the placeholder is skipped. $ i3status -c ./config i3status: trying to auto-detect output_format setting i3status: auto-detected "term" provided CPU number '-1' above detected number of CPU 4 cpu0= cpu1=-48% cpu= provided CPU number '-1' above detected number of CPU 4 cpu0= cpu1=11% cpu= provided CPU number '-1' above detected number of CPU 4 cpu0= cpu1=03% cpu= ...
2018-07-31Fix for issue 300: Correctly print usage for cpu 10=
2018-07-13able to print percentageFelix Buehler
its now possible to have percentage before and after a variable. except for the date. But percentage with dates does not make much sense to me, so i skipped it.
2017-03-26Multiple CPU support for cpu_usage (#209)eplanet
This change addresses the issue #199 asking for multiple CPU support. It takes an arbitrary CPU number and outputs its usage using the same arithmetics as for CPU aggregation. It currently doesn't support FreeBSD.
2016-11-15Add 'format_below_threshold' option for 'disk' moduleMihai Coman
Add 'format_above_threshold' option for 'cpu_temperature' module Add 'format_above_threshold' option for 'cpu_usage' module Add 'format_above_threshold' option for 'load' module
2016-04-13Add CPU usage color thresholdsMark Schreiber
CPU usage had previously not supported the color option. Add support for a "degraded" state above which the degraded color is used, and a higher "bad" state above which the "bad" color is used. One possible use for these might be indicating whether one or all cores are saturated. Unlike the color settings for other, these are set high enough to be disabled by default. This is done because i3status determines CPU usage over only the last display interval, which means that, a user with a low refresh rate might see frequent, potentially-annoying color changes.
2015-10-04Added support for lemonbarBrendan Van Hook
2015-04-02sys/dkstat.h has been removed from OpenBSD and it's functionality actually ↵Jasper Lievisse Adriaanse
lived/lives in sys/sched.h
2015-03-25print_cpu_usage: Fix warnings on non linuxBaptiste Daroussin
Move linux variable under LINUX boundaries
2015-03-16clang-format-3.5 -i **/*.[ch], update modelineMichael Stapelberg
From here on, we’ll use clang-format to automatically format the source. This has worked well in i3, so we are introducing it for i3status.
2014-03-12Unify use of string comparisonsMats
* strncmp(s1, s2, strlen(s2)) → BEGINS_WITH(s1, s2) * strncmp(s1, s2, strlen(s1)) → strcmp(s1, s2) * Prefer case-insensitive comparison for options
2013-10-07Allow to print cpu usage on NetBSDArnaud Degroote
2012-11-15DragonFlyBSD support addedScott Tincman
2012-06-28Avoid division by zero when calculating CPU usage.Mateusz Poszwa
2012-05-09Error handling: Never output null as full_text (JSON), prefix messages with ↵Michael Stapelberg
i3status (Thanks Artemis) The former made i3bar crash, the latter is helpful for debugging.
2012-04-29Fix CPU usage on OpenBSD. Currently only takes the first cpu into account, ↵Jasper Lievisse Adriaanse
but works fine otherwise.
2012-04-08add yajl compat codeMichael Stapelberg
2012-03-25Properly output JSON with libyajlMichael Stapelberg
2012-02-16Implement the i3bar JSON protocolMichael Stapelberg
This hardcodes all the JSON parts. Strings are not properly escaped currently. The best/easiest way to fix this is by actually using libyajl.
2011-08-29fix parentheses in cc1457c4f0f4cccb8bec326dd0bb13082ac806e6Mateusz Poszwa
2011-08-26initialize variables to fix compiler warningMichael Stapelberg
2011-08-25make modules more resilient to failureConnor Lane Smith
2011-07-24Add support for cpu usage on FreeBSDBaptiste Daroussin
2011-05-06Fix trailing whitespaces, document cpu_usage in manpageMichael Stapelberg
2011-05-06Add print_cpu_usagePeter Bui