-
-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Meters from external source #526
Comments
Thanks for writing the idea up. I think this would make a lot of sense. Just a few random thoughts from reading through your initial proposal: variable=value is much more common than variable:value, I'd stick with "=" htop could just listen to a named pipe (FIFO) and programs sending "meter info" there would get bars or column info as requested displayed. Records need to be smaller than I'd put everything in one line terminated by
and for columns
(you see, I'd use named colors or possibly html color codes ( config would just need a "on / off switch" and an option to set the initial umask for the FIFO |
May as well accept (parse) floating point since values ultimately become 'double's within htop? One important consideration is counter values vs non-counter values - counters are (almost always) converted to rates (the change in value divided by the change in time) over consecutive samples, so either:
I think the former approach makes more sense because otherwise a change in the sampling interval (e.g. through the htop UI) would require some kind of side-protocol to inform the script of the new interval. |
the idea is having the script to be long-running and providing |
Lately I find myself having
|
As this would become a new Meter for htop this would become a new To get an idea how meters typically work have a look at e.g. the CPUMeter or the MemoryMeter. For simple text meters the UptimeMeter or the SysArchMeter are good candidates for having a look at how things work. The SysArchMeter also demonstrates the aspect of splitting things across different platforms. To have the final ExternalDataSourceMeter be as extensible as possible it's recommended to formalize its protocol in a first step. The final documentation for this protocol should land in When processing the data (stream) from the external source be sure to take care of defensive programming. The parser should assume malformed data coming in and treat valid data as the exception. Note: |
Hi, I was thinking about these custom meters. Also, I think variable=value is much more common than variable:value, I think most Linux config files follow this style. for example: audit daemon config file: Last thing: What's the range of numbers custom Meters will take? |
Usually it's not very wise to have more than 4 values displayed in one (bar) meter as space is quite limited. Also you need colors for those values which makes those meters stand out too much if too colorful. It's not a hard limit, but a general recommendation.
That's up to the protocol decision what we settle at. The above description mostly was some grough description of what could be.
Opposite to the process fields, the meters currently have no fixed IDs. Instead Meters are identified by their MeterClass. The ID you see in those code snippets is for having multiple instances of the same meter. Don't worry about that too much yet as having more than one custom meter can be added easily later on (if the source allows for easy parameterization). |
It would be nice if the character that makes the meter could be changed from "|" to the one the user prefers. Is there ANY way to change that ugly default pipe for a better visual character with more body defined by us? Thanks in advance. |
@Noctumsempra I split this into a separate issue (#647) as this issue here is not about UI, but backend functionality. |
Thank you! And also sorry for posting in the wrong issue. Regards. |
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 ( htop-dev#526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - its use 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.
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 ( htop-dev#526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - its use 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.
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 ( htop-dev#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.
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 ( htop-dev#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.
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 ( htop-dev#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.
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 ( htop-dev#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.
Mention PR #1571 as related to this one. |
Based on several requests (cf. #406, #899historic) and as the general case would be quite interesting, it might be good to have a generic "Custom Script Meter".
The basic idea for such a meter would be, that
htop
could allow for up to 4 external "meter scripts" that it would execute and run in the background. The output of the program would then be parsed into a meter as follows:The lines have the following meaning:
bar_range
: Specifies the min and max limits of the bar meter. Values inbar_data
are scaled accordinglybar_data
: Up to seven integer values separated by space giving the data to show in the bar graph.bar_color
: The colors for up to seven channels denoted by up to 7 integers separated by spaces (1=blue, 2=green, 3=cyan, 4=red, 5=magenta, 6=yellow/orange, 7=grey, 8=shadowed). Missing colors are defaulted to 7 (grey).bar_label
: The text to display right-aligned in the meter. Text left-truncated at spaces if too long. Merges color with displayed bar values.text
: Text to display in the text meter style.led
: Text for the "large digits" display. Digits are automatically displayed as large retro 7-segment LED characters. Otherwise identical to text. If not present, caption fromtext
is used.The option value starts directly after the colon (
:
). For options giving plain numbers, these need to be separated by exactly one space, no decimal separator or thousands separator may be given. Invalid values are dropped and the whole record is replaced by its default values. Settings forbar_range
andbar_color
are remembered (thus only need to be given once), other values must be given at 1Hz or higher. Parsing for the values of one second ends when encountering a blank line. Last record parsed is displayed.The text was updated successfully, but these errors were encountered: