summaryrefslogtreecommitdiffstats
path: root/Meter.c
Commit message (Collapse)AuthorAgeFilesLines
* Update license headers to explicitly say GPLv2+Daniel Lange2021-09-221-1/+1
|
* Simplify delay.tv_usec calculation from BenBEDaniel Lange2021-08-231-1/+1
| | | | Closes #761
* Widen integer type before multiplicationChristian Göttsche2021-08-221-1/+1
| | | | | | Meter.c:320:71: warning: performing an implicit widening conversion to type '__suseconds_t' (aka 'long') of a multiplication performed in type 'int' [bugprone-implicit- widening-of-multiplication-result] struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay - ((globalDelay / 10) * 10)) * 100000 }; ^
* Meter: limit LED mode by widthChristian Göttsche2021-08-171-1/+6
| | | | Stop displaying LED-mode if maximum width is reached.
* Whitespace around operatorsBenny Baumann2021-07-151-1/+1
|
* Pretty-print values in the PCP DynamicMeter codeNathan Scott2021-07-081-6/+10
| | | | | | | | | | | | | | | | | Several improvements to the way values are displayed in the PCP platform DynamicMeter implementation: - handle the initial 'caption' setting as with regular meters, this required a new meter callback because we no longer have just a single meter caption for the DynamicMeter case - if no label is provided for a metric in a configuration file use the short form metric name as a fallback - honour the suffix setting in the configuration file - convert metric values to the canonical units for htop (kbyte and seconds), and use Meter_humanUnit when it makes sense to do so. Also improves the handling of fatal string error messages in a couple of places, thanks to BenBE for the review feedback.
* Add a new DynamicMeter class for runtime Meter extensionNathan Scott2021-07-071-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is based on exploratory work by Sohaib Mohamed. The end goal is two-fold - to support addition of Meters we build via configuration files for both the PCP platform and for scripts ( https://github.com/htop-dev/htop/issues/526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - it uses the special case 'param' field handling that previously was used only by the CPUMeter, such that every runtime-configured Meter is given a unique identifier. Unlike with the CPUMeter this is used internally only. When reading/writing to htoprc instead of CPU(N) - where N is an integer param (CPU number) - we use the string name for each meter. For example, if we have a configuration for a DynamicMeter for some Redis metrics, we might read and write "Dynamic(redis)". This identifier is subsequently matched (back) up to the configuration file so we're able to re-create arbitrary user configurations. The PCP platform configuration file format is fairly simple. We expand configs from several directories, including the users homedir alongside htoprc (below htop/meters/) and also /etc/pcp/htop/meters. The format will be described via a new pcp-htop(5) man page, but its basically ini-style and each Meter has one or more metric expressions associated, as well as specifications for labels, color and so on via a dot separated notation for individual metrics within the Meter. A few initial sample configuration files are provided below ./pcp/meters that give the general idea. The PCP "derived" metric specification - see pmRegisterDerived(3) - is used as the syntax for specifying metrics in PCP DynamicMeters.
* cleaned up includes with iwyumayurdahibhate2021-05-101-1/+0
|
* Request the realtime and monotonic clock times once per sampleNathan Scott2021-04-051-2/+2
| | | | | | | | | | | | | | | | Refactor the sample time code to make one call to gettimeofday (aka the realtime clock in clock_gettime, when available) and one to the monotonic clock. Stores each in more appropriately named ProcessList fields for ready access when needed. Every platform gets the opportunity to provide their own clock code, and the existing Mac OS X specific code is moved below darwin instead of in Compat. A couple of leftover time(2) calls are converted to use these ProcessList fields as well, instead of yet again sampling the system clock. Related to https://github.com/htop-dev/htop/pull/574
* Merging all the points related to calculating time in one placeSohaib2021-04-051-4/+4
| | | | | | | | | | | | | | The end goal is to consolidate all the points in htop that can only work in live-only mode today, so that will be able to inject PCP archive mode and have a chance at it working. The biggest problem we've got at this moment is all the places that are independently asking the kernel to 'give me the time right now'. Each of those needs to be audited and ultimately changed to allow platforms to manage their own idea of time. So, all the calls to gettimeofday(2) and time(2) are potential problems. Ultimately I want to get these down to just one or two. Related to https://github.com/htop-dev/htop/pull/574
* Drop unused attributes of actually used function parametersChristian Göttsche2021-03-241-1/+1
| | | | These parameters were once unused, but not anymore.
* Use unsigned types for CPU counts and associated variablesChristian Göttsche2021-03-191-2/+2
|
* RichString: do not unnecessarily clean whole bufferChristian Göttsche2021-03-171-5/+4
| | | | | | | The local stack buffer does not need to be cleaned to zeros when - just initialized, cause the length is set to 0 and the first character is set to '\0', so all printing functions will safely stop - no further used, i.e. the variable goes out of scope
* Meter: do not access RichString internalsChristian Göttsche2021-03-121-2/+2
| | | | Use a temporary local variable
* Merge branch 'misc' of https://github.com/cgzones/htop into cgzones-miscNathan Scott2021-03-051-3/+1
|\
| * Use ATTR_UNUSED instead of void castingChristian Göttsche2021-03-021-3/+1
| |
* | Separate data-update and drawing of headerChristian Göttsche2021-03-041-8/+0
| |
* | Save text buffer in MeterChristian Göttsche2021-03-041-19/+13
|/
* Rescale graph when value of total is changedMichael F. Schönitzer2021-02-281-3/+4
|
* Fix a couple of small spelling mistakes in commentsNathan Scott2021-02-151-1/+1
|
* LED Meter: display wide characters and restore non-wide ncurses supportChristian Göttsche2021-01-151-1/+6
| | | | | | Print wide characters, like degree sign, properly via mvadd_wch(). Ignore attributes when returning value from RichString_getCharVal() in non-wide ncurses mode to test against raw characters.
* RichString_appendChr: add parameter to set attributesChristian Göttsche2021-01-131-1/+1
| | | | | | | Allows to set attributes when padding process fields in non-wide ncurses mode. Closes: #475
* Mark several non-modified pointer variables constChristian Göttsche2021-01-111-1/+1
|
* Add wrapper function for free and strdupChristian Göttsche2021-01-111-2/+1
| | | | Reduces code in callers and helps avoiding memory leaks.
* RichString_setAttrn: refactor to take a length instead of a stop indexChristian Göttsche2021-01-101-2/+2
| | | | Fixes: #459
* Convert unnecessary static variablesChristian Göttsche2021-01-091-3/+2
| | | | | They are not used in any other function and are not used maybe uninitialized.
* LoadMeter: dynamically adjust color and total of barChristian Göttsche2020-12-261-1/+3
| | | | | | | | | | Change the color and total based on the actual 1min load value: < 1 : green and total of 1.0 < cpu-count : yellow and total of cpu-count else : red and total of 2*cpu-count Closes: #32
* Minor typo and comment clarificationBenny Baumann2020-12-201-2/+2
|
* BarMeter: rework text paddingChristian Göttsche2020-12-201-17/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | In case the text is too long for the bar, try to fit by truncating at a space character. E.g. [|24.1% 2000Mhz 40°C] [24.1% 2000Mhz 40°C] [||||24.1% 2000Mhz] [|||24.1% 2000Mhz] [||24.1% 2000Mhz] [|24.1% 2000Mhz] [24.1% 2000Mhz] [|||| 24.1%] [|||| 24.1%] [|||| 24.1%] [||||24.1%] [|||24.1%] [||24.1%] [|24.1%] [24.1%] [24.1] [24.] [24] [2]
* Meter: fix artifacts with very tiny widthChristian Göttsche2020-12-201-6/+10
| | | | | - The Bar Meter might override the right border - The TextMeter might wrap-around into the next line
* Meter: restore non-wide-character buildChristian Göttsche2020-12-151-0/+4
| | | | | | Use mbstowcs() only with wide ncurses support. Closes: #401
* Split RichString_(append|appendn|write) into wide and asciiChristian Göttsche2020-12-081-2/+2
| | | | | | | | RichString_writeFrom takes a top spot during performance analysis due to the calls to mbstowcs() and iswprint(). Most of the time we know in advance that we are only going to print regular ASCII characters.
* Introduce METER_BUFFER_CHECK and METER_BUFFER_APPEND_CHR to cleanup writing ↵Christian Göttsche2020-12-061-5/+5
| | | | | | to bar buffers Closes: #294
* Use size_t as len type for Meter_UpdateValuesChristian Göttsche2020-12-061-3/+2
| | | | Most of the time the parameter is passed to snprintf type functions
* IWYU updateChristian Göttsche2020-12-061-0/+1
|
* Meter: fix bar coloring without wide ncurses supportChristian Göttsche2020-12-051-6/+5
| | | | attrset() seems to not work with mvaddchnstr()
* Resolve conversion from int to charChristian Göttsche2020-12-051-1/+1
|
* Resolve conversion from int to unsigned and backChristian Göttsche2020-12-051-5/+2
|
* Update even more snprintfsChristian Göttsche2020-11-281-6/+6
| | | | Use size of actual buffers instead of magic numbers
* Add support to change numeric options in settings screenChristian Göttsche2020-11-251-1/+2
| | | | Like delay or highlightDelaySecs
* Fully support non-ascii characters in Meter-BarChristian Göttsche2020-11-251-8/+17
| | | | | | | | | | Currently the code does not handle multi-byte characters, so length- computations take the raw count of C characters and not the to displayed size into account. An example is the degree sign for temperatures. Closes: #329
* Embracing branchesBenny Baumann2020-11-021-9/+20
|
* Spacing around operatorsBenny Baumann2020-11-021-18/+18
|
* Spacing after keywords (for)Benny Baumann2020-11-021-1/+1
|
* Use integer type for item count instead of charChristian Göttsche2020-10-311-5/+3
|
* Hold only a const version of the ProcessList in MetersChristian Göttsche2020-10-261-1/+1
|
* Assert allocating non-zero size memoryChristian Göttsche2020-10-191-1/+1
| | | | | | | | Allocating zero size memory results in implementation-defined behavior: man:malloc(3) : If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be successfully passed to free().
* Make all required includes explicitBenny Baumann2020-10-181-8/+12
| | | | Information as seen by IWYU 0.12 + clang 9 on Linux
* Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann2020-10-161-1/+1
|
* Meter: use explicit type for drawDataChristian Göttsche2020-10-121-1/+1
|

© 2014-2024 Faster IT GmbH | imprint | privacy policy