summaryrefslogtreecommitdiffstats
path: root/Meter.c
AgeCommit message (Collapse)Author
2021-08-23Simplify delay.tv_usec calculation from BenBEDaniel Lange
Closes #761
2021-08-22Widen integer type before multiplicationChristian Göttsche
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 }; ^
2021-08-17Meter: limit LED mode by widthChristian Göttsche
Stop displaying LED-mode if maximum width is reached.
2021-07-15Whitespace around operatorsBenny Baumann
2021-07-08Pretty-print values in the PCP DynamicMeter codeNathan Scott
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.
2021-07-07Add a new DynamicMeter class for runtime Meter extensionNathan Scott
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.
2021-05-10cleaned up includes with iwyumayurdahibhate
2021-04-05Request the realtime and monotonic clock times once per sampleNathan Scott
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
2021-04-05Merging all the points related to calculating time in one placeSohaib
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
2021-03-24Drop unused attributes of actually used function parametersChristian Göttsche
These parameters were once unused, but not anymore.
2021-03-19Use unsigned types for CPU counts and associated variablesChristian Göttsche
2021-03-17RichString: do not unnecessarily clean whole bufferChristian Göttsche
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
2021-03-12Meter: do not access RichString internalsChristian Göttsche
Use a temporary local variable
2021-03-05Merge branch 'misc' of https://github.com/cgzones/htop into cgzones-miscNathan Scott
2021-03-04Separate data-update and drawing of headerChristian Göttsche
2021-03-04Save text buffer in MeterChristian Göttsche
2021-03-02Use ATTR_UNUSED instead of void castingChristian Göttsche
2021-02-28Rescale graph when value of total is changedMichael F. Schönitzer
2021-02-15Fix a couple of small spelling mistakes in commentsNathan Scott
2021-01-15LED Meter: display wide characters and restore non-wide ncurses supportChristian Göttsche
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.
2021-01-13RichString_appendChr: add parameter to set attributesChristian Göttsche
Allows to set attributes when padding process fields in non-wide ncurses mode. Closes: #475
2021-01-11Mark several non-modified pointer variables constChristian Göttsche
2021-01-11Add wrapper function for free and strdupChristian Göttsche
Reduces code in callers and helps avoiding memory leaks.
2021-01-10RichString_setAttrn: refactor to take a length instead of a stop indexChristian Göttsche
Fixes: #459
2021-01-09Convert unnecessary static variablesChristian Göttsche
They are not used in any other function and are not used maybe uninitialized.
2020-12-26LoadMeter: dynamically adjust color and total of barChristian Göttsche
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
2020-12-20Minor typo and comment clarificationBenny Baumann
2020-12-20BarMeter: rework text paddingChristian Göttsche
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]
2020-12-20Meter: fix artifacts with very tiny widthChristian Göttsche
- The Bar Meter might override the right border - The TextMeter might wrap-around into the next line
2020-12-15Meter: restore non-wide-character buildChristian Göttsche
Use mbstowcs() only with wide ncurses support. Closes: #401
2020-12-08Split RichString_(append|appendn|write) into wide and asciiChristian Göttsche
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.
2020-12-06Introduce METER_BUFFER_CHECK and METER_BUFFER_APPEND_CHR to cleanup writing ↵Christian Göttsche
to bar buffers Closes: #294
2020-12-06Use size_t as len type for Meter_UpdateValuesChristian Göttsche
Most of the time the parameter is passed to snprintf type functions
2020-12-06IWYU updateChristian Göttsche
2020-12-05Meter: fix bar coloring without wide ncurses supportChristian Göttsche
attrset() seems to not work with mvaddchnstr()
2020-12-05Resolve conversion from int to charChristian Göttsche
2020-12-05Resolve conversion from int to unsigned and backChristian Göttsche
2020-11-28Update even more snprintfsChristian Göttsche
Use size of actual buffers instead of magic numbers
2020-11-25Add support to change numeric options in settings screenChristian Göttsche
Like delay or highlightDelaySecs
2020-11-25Fully support non-ascii characters in Meter-BarChristian Göttsche
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
2020-11-02Embracing branchesBenny Baumann
2020-11-02Spacing around operatorsBenny Baumann
2020-11-02Spacing after keywords (for)Benny Baumann
2020-10-31Use integer type for item count instead of charChristian Göttsche
2020-10-26Hold only a const version of the ProcessList in MetersChristian Göttsche
2020-10-19Assert allocating non-zero size memoryChristian Göttsche
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().
2020-10-18Make all required includes explicitBenny Baumann
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-16Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann
2020-10-12Meter: use explicit type for drawDataChristian Göttsche
2020-10-10Mark Object pointer to _display function constChristian Göttsche