Merge branch 'master' into i18n
This commit is contained in:
commit
b29c2b1c89
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
@ -1,6 +1,11 @@
|
||||
name: Build Go binaries
|
||||
|
||||
on: push
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'docs/release.svg'
|
||||
- 'README.md'
|
||||
- 'CHANGELOG.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -14,4 +19,4 @@ jobs:
|
||||
env:
|
||||
SRCPATH: ./cmd/gotop
|
||||
with:
|
||||
args: darwin/amd64/1 linux/amd64 linux/386 linux/arm64 linux/arm7 linux/arm6 linux/arm5 windows/amd64 windows/386 freebsd/amd64 freebsd/386
|
||||
args: darwin/amd64 linux/amd64 linux/386 linux/arm64 linux/arm7 linux/arm6 linux/arm5 windows/amd64 windows/386 freebsd/amd64 freebsd/386
|
||||
|
15
.github/workflows/release.yml
vendored
15
.github/workflows/release.yml
vendored
@ -22,6 +22,13 @@ jobs:
|
||||
event-type: my-release
|
||||
client-payload: '{"tag": "${{ steps.tag_name.outputs.tag }}"}'
|
||||
|
||||
- name: Update and inform Homebrew
|
||||
uses: dawidd6/action-homebrew-bump-formula@v3
|
||||
with:
|
||||
token: ${{ secrets.homebrew }}
|
||||
formula: gotop
|
||||
revision: ${{ steps.tag_name.outputs.tag }}
|
||||
|
||||
- name: Update Arch AURs
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
@ -29,3 +36,11 @@ jobs:
|
||||
repository: xxxserxxx/gotop-linux
|
||||
event-type: my-release
|
||||
client-payload: '{"tag": "${{ steps.tag_name.outputs.tag }}"}'
|
||||
|
||||
- name: Trigger extensions build
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.REPO_ACCESS_TOKEN }}
|
||||
repository: xxxserxxx/gotop-builder
|
||||
event-type: my-release
|
||||
client-payload: '{"tag": "${{ steps.tag_name.outputs.tag }}"}'
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ dist/
|
||||
|
||||
build/gotop_*
|
||||
build.log
|
||||
|
||||
tmp/
|
||||
|
29
CHANGELOG.md
29
CHANGELOG.md
@ -13,7 +13,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
> - **Fixed**: for any bug fixes.
|
||||
> - **Security**: in case of vulnerabilities.
|
||||
|
||||
## [4.0.0] PENDING
|
||||
## [4.0.1] 2020-06-08
|
||||
|
||||
**Darwin-only release**
|
||||
|
||||
### Changed
|
||||
|
||||
- The change to remove GPL dependencies did not remove *all* dependencies. This corrects that (#131)
|
||||
|
||||
|
||||
## [4.0.0] 2020-06-07
|
||||
|
||||
**Command line options have changed.**
|
||||
|
||||
@ -33,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Adds ability to write out a configuration file
|
||||
- Adds a command for specifying the configuration file to use
|
||||
- Merged cmatsuoka's console font contribution
|
||||
- Added contribution from @wcdawn for building on machines w/ no Go/root access
|
||||
|
||||
### Changed
|
||||
|
||||
@ -40,6 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Extensions are now built with a build tool; this is an interim solution until issues with the Go plugin API are resolved.
|
||||
- Command line help text is cleaned up.
|
||||
- Version bump of gopsutil
|
||||
- Prometheus client replaced by [VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics). This eliminated 6 indirect package dependencies and saved 3.5MB (25%) of the compiled binary size.
|
||||
- Relicensed to MIT-3 (see [#36](https://github.com/xxxserxxx/gotop/issues/36))
|
||||
|
||||
### Removed
|
||||
|
||||
@ -56,6 +68,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Temperatures on Darwin were all over the place, and wrong (#48)
|
||||
- Config file loading from `~/.config/gotop` wasn't working
|
||||
- There were a number of minor issues with the config file that have been cleaned up.
|
||||
- Compile errors on FreeBSD due to golang.org/x/sys API breakages
|
||||
- Key bindings now work in FreeBSD (#95)
|
||||
- Only report battery sensor errors once (reduce noise in the log, #117)
|
||||
- Fixes a very small memory leak from the spark and histograph widgets (#128)
|
||||
|
||||
## [3.5.3] - 2020-05-30
|
||||
|
||||
The FreeBSD bugfix release. While there are non-FreeBSD fixes in here, the focus was getting gotop to work properly on FreeBSD.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Address FreeBSD compile errors resulting to `golang.org/x/sys` API breakages
|
||||
- Key bindings now work in FreeBSD (#95)
|
||||
- Eliminate repeated logging about missing sensor data on FreeBSD VMs (#97)
|
||||
- Investigated #14, a report about gotop's memory not matching `top`'s numbers, and came to the conclusions that (a) `gotop` is more correct in some cases (swap) than `top`, and (b) that the metric `gotop` is using (`hw.physmem`) is probably correct -- or that there's no obviously superior metric. So no change.
|
||||
|
||||
## [3.5.2] - 2020-04-28
|
||||
|
||||
|
690
LICENSE
690
LICENSE
@ -1,661 +1,29 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Sean E. Russell <ser@ser1.net> 87651D71
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
210
README.md
210
README.md
@ -9,16 +9,19 @@ Another terminal based graphical activity monitor, inspired by [gtop](https://gi
|
||||
|
||||
Join us in [\#gotop:matrix.org](https://riot.im/app/#/room/#gotop:matrix.org) ([matrix clients](https://matrix.to/#/#gotop:matrix.org)).
|
||||
|
||||

|
||||

|
||||
|
||||
<div id="release" align="center">Current release: <a href="https://github.com/xxxserxxx/gotop/releases/tag/v4.0.1">v4.0.1</a></div>
|
||||
|
||||
See the [mini-blog](https://github.com/xxxserxxx/gotop/wiki/Micro-Blog) for updates on the build status, and the [change log](/CHANGELOG.md) for release updates.
|
||||
|
||||
<img src="./assets/screenshots/demo.gif" />
|
||||
<img src="./assets/screenshots/kitchensink.gif" />
|
||||
|
||||
</div>
|
||||
|
||||
## Installation
|
||||
|
||||

|
||||

|
||||
|
||||
Working and tested on Linux, FreeBSD and MacOS. Windows binaries are provided, but have limited testing. OpenBSD works with some caveats; cross-compiling is difficult and binaries are not provided.
|
||||
|
||||
If you install gotop by hand, or you download or create new layouts or colorschemes, you will need to put the layout files where gotop can find them. To see the list of directories gotop looks for files, run `gotop -h`. The first directory is always the directory from which gotop is run.
|
||||
@ -29,26 +32,33 @@ If you install gotop by hand, or you download or create new layouts or colorsche
|
||||
sudo layman -a guru
|
||||
sudo emerge gotop
|
||||
```
|
||||
- OSX: gotop is in *homebrew-core*. `brew install gotop`. Make sure to uninstall and untap any previous installations or taps.
|
||||
- **OSX**: gotop is in *homebrew-core*. `brew install gotop`. Make sure to uninstall and untap any previous installations or taps.
|
||||
- **Prebuilt binaries**: Binaries for most systems can be downloaded from [the github releases page](https://github.com/xxxserxxx/gotop/releases). RPM and DEB packages are also provided.
|
||||
- **Source**: This requires Go >= 1.14. `go get -u github.com/xxxserxxx/gotop/cmd/gotop`
|
||||
|
||||
### Console Users Note
|
||||
### Extension builds
|
||||
|
||||
An evolving mechanism in gotop are extensions. This is designed to allow gotop to support feature sets that are not universally needed without blowing up the application for average users with usused features. Examples are support for specific hardware sets like video cards, or things that are just obviously not a core objective of the application, like remote server monitoring.
|
||||
|
||||
The path to these extensions is a tool called [gotop-builder](https://github.com/xxxserxxx/gotop-builder). It is easy to use and depends only on having Go installed. You can read more about it on the project page, where you can also find binaries for Linux that have *all* extensions built in. If you want less than an all-inclusive build, or one for a different OS/architecture, you can use gotop-builder itself to create your own.
|
||||
|
||||
|
||||
### Console Users
|
||||
|
||||
gotop requires a font that has braille and block character Unicode code points; some distributions do not provide this. In the gotop repository is a `pcf` font that has these points, and setting this font may improve how gotop renders in your console. To use this, run these commands:
|
||||
|
||||
```shell
|
||||
$ curl -O -L https://raw.githubusercontent.com/xxxserxxx/gotop/master/fonts/Lat15-VGA16-braille.psf
|
||||
$ setfont Lat15-VGA16-braille.psf
|
||||
curl -O -L https://raw.githubusercontent.com/xxxserxxx/gotop/master/fonts/Lat15-VGA16-braille.psf
|
||||
setfont Lat15-VGA16-braille.psf
|
||||
```
|
||||
|
||||
### Building
|
||||
|
||||
This is the download & compile approach.
|
||||
|
||||
gotop should build with most versions of Go. If you have a version other than 1.14 installed, remove the `go` line at the end of `go.mod`.
|
||||
gotop should build with most versions of Go. If you have a version other than 1.14 installed, remove the `go` line at the end of `go.mod` and it should work.
|
||||
|
||||
```
|
||||
```shell
|
||||
git clone https://github.com/xxxserxxx/gotop.git
|
||||
cd gotop
|
||||
sed -i '/^go/d' go.mod # Do this if you have go != 1.14
|
||||
@ -57,6 +67,8 @@ go build -o gotop ./cmd/gotop
|
||||
|
||||
Move `gotop` to somewhere in your `$PATH`.
|
||||
|
||||
If Go is not installed or is the wrong version, and you don't have root access or don't want to upgrade Go, a script is provided to download Go and the gotop sources, compile gotop, and then clean up. See `scripts/install_without_root.sh`.
|
||||
|
||||
## Usage
|
||||
|
||||
Run with `-h` to get an extensive list of command line arguments. Many of these can be configured by creating a configuration file; see the next section for more information. Key bindings can be viewed while gotop is running by pressing the `?` key, or they can be printed out by using the `--list keys` command.
|
||||
@ -66,152 +78,20 @@ In addition to the key bindings, the mouse can be used to control the process li
|
||||
- click to select process
|
||||
- mouse wheel to scroll through processes
|
||||
|
||||
## Config file
|
||||
For more information on other topics, see:
|
||||
|
||||
Most command-line settings can be persisted into a configuration file. The config file is named `gotop.conf` and can be located in several places. The first place gotop will look is in the current directory; after this, the locations depend on the OS and distribution. On Linux using XDG, for instance, the home location of `~/.config/gotop/gotop.conf` is the second location. The last location is a system-wide global location, such as `/etc/gotop/gotop.conf`. The `-h` help command will print out all of the locations, in order. Command-line options override values in any config files, and only the first config file found is loaded.
|
||||
- [Layouts](docs/layouts.md)
|
||||
- [Configuration](docs/configuration.md)
|
||||
- [Color schemes](docs/colorschemes.md)
|
||||
- [Device filtering](docs/devices.md)
|
||||
- [Extensions](docs/extensions.md)
|
||||
|
||||
A configuration file can be created using the `--write-config` command-line argument. This will try to place the config file in the home config directory (the second location), but if it's unable to do so it'll write a file to the current directory.
|
||||
|
||||
Config file changes can be made by combining command-line arguments with `--write-config`. For example, to persist the `solarized` theme, call:
|
||||
|
||||
```
|
||||
gotop -c solarized --write-config
|
||||
```
|
||||
|
||||
### Colorschemes
|
||||
|
||||
gotop ships with a few colorschemes which can be set with the `-c` flag followed by the name of one. You can find all the colorschemes in the [colorschemes folder](./colorschemes).
|
||||
|
||||
To make a custom colorscheme, check out the [template](./colorschemes/template.go) for instructions and then use [default.json](./colorschemes/default.json) as a starter. Then put the file at `~/.config/gotop/<name>.json` and load it with `gotop -c <name>`. Colorschemes PR's are welcome!
|
||||
|
||||
To list all built-in color schemes, call:
|
||||
|
||||
```
|
||||
gotop --list colorschemes
|
||||
```
|
||||
|
||||
### Layouts
|
||||
|
||||
gotop can parse and render layouts from a specification file. The format is
|
||||
intentionally simple. The amount of nesting levels is limited. Some examples
|
||||
are in the `layouts` directory; you can try each of these with, e.g.,
|
||||
`gotop --layout-file layouts/procs`. If you stick your layouts in
|
||||
`$XDG_CONFIG_HOME/gotop`, you can reference them on the command line with the
|
||||
`-l` argument, e.g. `gotop -l procs`.
|
||||
|
||||
The syntax for each widget in a row is:
|
||||
```
|
||||
(rowspan:)?widget(/weight)?
|
||||
```
|
||||
and these are separated by spaces.
|
||||
|
||||
1. Each line is a row
|
||||
2. Empty lines are skipped
|
||||
3. Spaces are compressed (so you can do limited visual formatting)
|
||||
4. Legal widget names are: cpu, disk, mem, temp, batt, net, procs
|
||||
5. Widget names are not case sensitive
|
||||
4. The simplest row is a single widget, by name, e.g. `cpu`
|
||||
5. **Weights**
|
||||
1. Widgets with no weights have a weight of 1.
|
||||
2. If multiple widgets are put on a row with no weights, they will all have
|
||||
the same width.
|
||||
3. Weights are integers
|
||||
4. A widget will have a width proportional to its weight divided by the
|
||||
total weight count of the row. E.g.,
|
||||
|
||||
```
|
||||
cpu net
|
||||
disk/2 mem/4
|
||||
```
|
||||
|
||||
The first row will have two widgets: the CPU and network widgets; each
|
||||
will be 50% of the total width wide. The second row will have two
|
||||
widgets: disk and memory; the first will be 2/6 ~= 33% wide, and the
|
||||
second will be 5/7 ~= 67% wide (or, memory will be twice as wide as disk).
|
||||
9. If prefixed by a number and colon, the widget will span that number of
|
||||
rows downward. E.g.
|
||||
|
||||
```
|
||||
mem 2:cpu
|
||||
net
|
||||
```
|
||||
|
||||
Here, memory and network will be in the same row as CPU, one over the other,
|
||||
and each half as high as CPU; it'll look like this:
|
||||
|
||||
```
|
||||
+------+------+
|
||||
| Mem | |
|
||||
+------+ CPU |
|
||||
| Net | |
|
||||
+------+------+
|
||||
```
|
||||
|
||||
10. Negative, 0, or non-integer weights will be recorded as "1". Same for row
|
||||
spans.
|
||||
11. Unrecognized widget names will cause the application to abort.
|
||||
12. In rows with multi-row spanning widgets **and** weights, weights in
|
||||
lower rows are ignored. Put the weight on the widgets in that row, not
|
||||
in later (spanned) rows.
|
||||
13. Widgets are filled in top down, left-to-right order.
|
||||
14. The larges row span in a row defines the top-level row span; all smaller
|
||||
row spans constitude sub-rows in the row. For example, `cpu mem/3 net/5`
|
||||
means that net/5 will be 5 rows tall overall, and mem will compose 3 of
|
||||
them. If following rows do not have enough widgets to fill the gaps,
|
||||
spacers will be used.
|
||||
|
||||
Yes, you're clever enough to break the layout algorithm, but if you try to
|
||||
build massive edifices, you're in for disappointment.
|
||||
|
||||
To list all built-in color schemes, call:
|
||||
|
||||
```
|
||||
gotop --list layouts
|
||||
```
|
||||
|
||||
### Device filtering
|
||||
|
||||
Some devices have quite a number of data points; on OSX, for instance, there are dozens of temperature readings. These can be filtered through a configuration file. There is no command-line argument for this filter.
|
||||
|
||||
The list will grow, but for now the only device that supports filtering is the temperature widget. The configuration entry is called `temperature`, and it contains an exact-match list of comma-separated values with no spaces. To see the list of valid values, run gotop with the `--list devices` command. Gotop will print out the type of device and the legal values. For example, on Linux:
|
||||
|
||||
```
|
||||
$ gotop --list devices
|
||||
Temperatures:
|
||||
acpitz
|
||||
nvme_composite
|
||||
nvme_sensor1
|
||||
nvme_sensor2
|
||||
pch_cannonlake
|
||||
coretemp_packageid0
|
||||
coretemp_core0
|
||||
coretemp_core1
|
||||
coretemp_core2
|
||||
coretemp_core3
|
||||
ath10k_hwmon
|
||||
```
|
||||
You might then add the following line to the config file. First, find where gotop looks for config files:
|
||||
```
|
||||
$ gotop -h | tail -n 6
|
||||
Colorschemes & layouts that are not built-in are searched for (in order) in:
|
||||
/home/USER/workspace/gotop.d/gotop, /home/USER/.config/gotop, /etc/xdg/gotop
|
||||
The first path in this list is always the cwd. The config file
|
||||
'gotop.config' can also reside in one of these directories.
|
||||
|
||||
Log files are stored in /home/ser/.cache/gotop/errors.log
|
||||
```
|
||||
So you might use `/home/YOU/.config/gotop.conf`, and add (or modify) this line:
|
||||
```
|
||||
temperatures=acpitz,coretemp_core0,ath10k_hwmon
|
||||
```
|
||||
This will cause the temp widget to show only four of the eleven temps.
|
||||
|
||||
### CLI Options
|
||||
|
||||
Run `gotop -h` to see the list of all command line options.
|
||||
|
||||
## More screen shots
|
||||
|
||||
#### '-l kitchensink' + colorscheme
|
||||
<img src="./assets/screenshots/kitchensink.gif" />
|
||||
|
||||
#### "-l battery"
|
||||
<img src="./assets/screenshots/battery.png" />
|
||||
|
||||
@ -229,10 +109,36 @@ Run `gotop -h` to see the list of all command line options.
|
||||
- [shirou/gopsutil](https://github.com/shirou/gopsutil)
|
||||
- [goreleaser/nfpm](https://github.com/goreleaser/nfpm)
|
||||
- [distatus/battery](https://github.com/distatus/battery)
|
||||
- [VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) Check this out! The API is clean, elegant, introduces many fewer indirect dependencies than the Prometheus client, and adds 50% less size to binaries.
|
||||
|
||||
## History
|
||||
|
||||
The original author of gotop started a new tool in Rust, called [ytop](https://github.com/cjbassi/ytop). This repository is a fork of original gotop project with a new maintainer.
|
||||
**ca. 2020-01-25** The original author of gotop started a new tool in Rust, called [ytop](https://github.com/cjbassi/ytop), and deprecated his Go version. This repository is a fork of original gotop project with a new maintainer to keep the project alive and growing. An objective of the fork is to maintain a small, focused core while providing a path to extend functionality for less universal use cases; examples of this is sensor support for NVidia graphics cards, and for aggregating data from remote gotop instances.
|
||||
|
||||
## Alternatives
|
||||
|
||||
I obviously think gotop is the Bee's Knees, but there are many alternatives. Many of these have been around for years. All of them are terminal-based tools.
|
||||
|
||||
- Grandpa [top](http://sourceforge.net/projects/unixtop/). Written 36 years ago, C, installed by default on almost every Unix decendant.
|
||||
- [htop](https://hisham.hm/htop/). A prettier top. Similar functionality. 16 years old!
|
||||
- [atop](https://www.atoptool.nl/). Detailed process-focused inspection with a table-like view. Been around for 9 long years.
|
||||
- [iftop](http://www.ex-parrot.com/~pdw/iftop/), a top for network connections. More than just data transfer, iftop will show what interfaces are connecting to what IP addresses. Requires root access to run.
|
||||
- [iotop](http://guichaz.free.fr/iotop/), top for disk access. Tells you *which* processes are writing to and from disk space, and how much. Also requires root access to run.
|
||||
- [nmon](http://nmon.sourceforge.net) a dashboard style top; widgets can be dynamically enabled and disabled, pure ASCII rendering, so it doesn't rely on fancy character sets to draw bars.
|
||||
- [bashtop](https://github.com/aristocratos/bashtop), in pure bash! Beautiful and space efficient, and [deserves special comment](docs/bashtop.md). If you use anything other than gotop, I'd recommend bashtop.
|
||||
- [ytop](https://github.com/cjbassi/ytop), a rewrite of gotop (ca. 3.0) in Rust. Same great UI, different programming language.
|
||||
- [slabtop](https://gitlab.com/procps-ng/procps), part of procps-ng, looks like top but provides kernel slab cache information! Requires root.
|
||||
- [systemd-cgtop](https://www.github.com/systemd/systemd), comes with systemd (odds are your system uses systemd, so this is already installed), provides a resource use view of control groups -- basically, which services are using what resources. Does *not* require root to run.
|
||||
- [virt-top](https://libvirt.org/) top for virtualized containers (VMs, like QEMU).
|
||||
- [ctop](https://bcicen.github.io/ctop/) top for containers (LXC, like docker)
|
||||
|
||||
|
||||
### A comment on clones
|
||||
|
||||
In a chat room I heard someone refer to gotop as "another one of those fancy language rewrites people do." I'm not the original author of gotop, so it's easy to not take offense, but I'm going on record as saying that I disagree with that sentiment: I think these rewrites are valuable, useful, and healthy to the community. They increase software diversity at very little [cost to users](https://en.wikipedia.org/wiki/Information_overload), and are a sort of evolutionary mechanism: as people do rewrites, some are worse, but some are better, and users benefit. Rewrites provide options, which fight against [monocultures](https://github.com). As importantly, most developers are really only fluent in a couple of programming languages. We all have *familiarity* with a dozen, and may even have extensive experience with a half-dozen, but if you don't constantly use a language, you tend to forget the extended library APIs, your development environment isn't tuned, you're rusty with using the tool sets, and you may have forgotten a lot of the language peculiarities and gotchas. The barrier to entry for contributing to a software project -- to simply finding and fixing a bug -- in a language you're not intimate with can be very high. It gets much worse if the project owner is a stickler for quality and style. So I believe that gotop's original author's decision to rewrite his project in Rust is a net positive. He probably made fewer design mistakes in ytop (we always do, on the second rewrite), and Rust developers -- who may have hesitated learning or brushing up on Go to submit an improvement -- have another project to which they can contribute.
|
||||
|
||||
Diversity is good. Don't knock the free stuff.
|
||||
|
||||
|
||||
## Stargazers over time
|
||||
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
|
||||
//_ "net/http/pprof"
|
||||
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
jj "github.com/cloudfoundry-attic/jibber_jabber"
|
||||
ui "github.com/gizak/termui/v3"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/shibukawa/configdir"
|
||||
"github.com/xxxserxxx/lingo"
|
||||
"github.com/xxxserxxx/opflag"
|
||||
@ -446,9 +446,12 @@ func run() int {
|
||||
ui.Render(bar)
|
||||
}
|
||||
|
||||
// TODO https://godoc.org/github.com/VictoriaMetrics/metrics#Set
|
||||
if conf.ExportPort != "" {
|
||||
go func() {
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
|
||||
metrics.WritePrometheus(w, true)
|
||||
})
|
||||
http.ListenAndServe(conf.ExportPort, nil)
|
||||
}()
|
||||
}
|
||||
@ -488,7 +491,7 @@ func getLayout(conf gotop.Config) (io.Reader, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func runTests(conf gotop.Config) int {
|
||||
func runTests(_ gotop.Config) int {
|
||||
fmt.Printf("PASS")
|
||||
return 0
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// FromName loads a Colorscheme by name; confDir is used to search
|
||||
// directories for a scheme matching the name. The search order
|
||||
// is the same as for config files.
|
||||
func FromName(confDir configdir.ConfigDir, c string) (Colorscheme, error) {
|
||||
if cs, ok := registry[c]; ok {
|
||||
return cs, nil
|
||||
|
@ -1,46 +1,68 @@
|
||||
package colorschemes
|
||||
|
||||
/*
|
||||
The standard 256 terminal colors are supported.
|
||||
|
||||
-1 = clear
|
||||
|
||||
You can combine a color with 'Bold', 'Underline', or 'Reverse' by using bitwise OR ('|') and the name of the Color.
|
||||
For example, to get Bold red Labels, you would do 'Labels: 2 | Bold'.
|
||||
|
||||
Once you've created a colorscheme, add an entry for it in the `handleColorscheme` function in 'main.go'.
|
||||
*/
|
||||
|
||||
//revive:disable
|
||||
const (
|
||||
Bold int = 1 << (iota + 9)
|
||||
Underline
|
||||
Reverse
|
||||
)
|
||||
|
||||
//revive:enable
|
||||
|
||||
/*
|
||||
Colorscheme defines colors and fonts used by TUI elements. The standard
|
||||
256 terminal colors are supported.
|
||||
|
||||
For int values, -1 = clear
|
||||
|
||||
Colors may be combined with 'Bold', 'Underline', or 'Reverse' by using
|
||||
bitwise OR ('|') and the name of the Color. For example, to get bold red
|
||||
labels, you would use 'Labels: 2 | Bold'
|
||||
*/
|
||||
type Colorscheme struct {
|
||||
Name string
|
||||
// Name is the key used to look up the colorscheme, e.g. as provided by the user
|
||||
Name string
|
||||
// Who created the color scheme
|
||||
Author string
|
||||
|
||||
// Foreground color
|
||||
Fg int
|
||||
// Background color
|
||||
Bg int
|
||||
|
||||
// BorderLabel is the color of the widget title label
|
||||
BorderLabel int
|
||||
BorderLine int
|
||||
// BorderLine is the color of the widget border
|
||||
BorderLine int
|
||||
|
||||
// should add at least 8 here
|
||||
// CPULines define the colors used for the CPU activity graph, in
|
||||
// order, for each core. Should add at least 8 here; they're
|
||||
// selected in order, with wrapping.
|
||||
CPULines []int
|
||||
|
||||
// BattLines define the colors used for the battery history graph.
|
||||
// Should add at least 2; they're selected in order, with wrapping.
|
||||
BattLines []int
|
||||
|
||||
// MemLines define the colors used for the memory histograph.
|
||||
// Should add at least 2 (physical & swap); they're selected in order,
|
||||
// with wrapping.
|
||||
MemLines []int
|
||||
|
||||
// ProcCursor is used as the color for the color bar in the process widget
|
||||
ProcCursor int
|
||||
|
||||
// SparkLine determines the color of the data line in spark graphs
|
||||
Sparkline int
|
||||
|
||||
// DiskBar is the color of the disk gauge bars (currently unused,
|
||||
// as there's no disk gauge widget)
|
||||
DiskBar int
|
||||
|
||||
// colors the temperature number a different color if it's over a certain threshold
|
||||
TempLow int
|
||||
// TempLow determines the color of the temperature number when it's under
|
||||
// a certain threshold
|
||||
TempLow int
|
||||
// TempHigh determines the color of the temperature number when it's over
|
||||
// a certain threshold
|
||||
TempHigh int
|
||||
}
|
||||
|
@ -162,7 +162,6 @@ func load(in io.Reader, conf *Config) error {
|
||||
}
|
||||
conf.Statusbar = bv
|
||||
case netinterface:
|
||||
// FIXME this should be a comma-separated list
|
||||
conf.NetInterface = kv[1]
|
||||
case layout:
|
||||
conf.Layout = kv[1]
|
||||
|
@ -16,35 +16,22 @@ func TestParse(t *testing.T) {
|
||||
f func(c Config, e error)
|
||||
}{
|
||||
{
|
||||
i: "logdir",
|
||||
i: "graphhorizontalscale",
|
||||
f: func(c Config, e error) {
|
||||
assert.Error(t, e, "invalid config syntax")
|
||||
assert.Error(t, e, "invalid graphhorizontalscale syntax")
|
||||
},
|
||||
},
|
||||
{
|
||||
i: "logdir=foo=bar",
|
||||
i: "helpvisible=true=false",
|
||||
f: func(c Config, e error) {
|
||||
assert.NotNil(t, e)
|
||||
},
|
||||
},
|
||||
{
|
||||
i: "foo=bar",
|
||||
f: func(c Config, e error) {
|
||||
assert.NotNil(t, e)
|
||||
},
|
||||
},
|
||||
{
|
||||
i: "configdir=abc\nlogdir=bar\nlogfile=errors",
|
||||
i: "GRAPHHORIZONTALSCALE=1\nhelpVisible=true",
|
||||
f: func(c Config, e error) {
|
||||
assert.Nil(t, e, "unexpected error")
|
||||
assert.Equal(t, "abc", c.ConfigDir)
|
||||
},
|
||||
},
|
||||
{
|
||||
i: "CONFIGDIR=abc\nloGdir=bar\nlogFILe=errors",
|
||||
f: func(c Config, e error) {
|
||||
assert.Nil(t, e, "unexpected error")
|
||||
assert.Equal(t, "abc", c.ConfigDir)
|
||||
assert.Equal(t, 1, c.GraphHorizontalScale)
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -60,14 +47,14 @@ func TestParse(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
i: "helpvisible=true\nupdateinterval=30\naveragecpu=true\nPerCPULoad=true\ntempscale=100\nstatusbar=true\nnetinterface=eth0\nlayout=minimal\nmaxlogsize=200",
|
||||
i: "helpvisible=true\nupdateinterval=30\naveragecpu=true\nPerCPULoad=true\ntempscale=F\nstatusbar=true\nnetinterface=eth0\nlayout=minimal\nmaxlogsize=200",
|
||||
f: func(c Config, e error) {
|
||||
assert.Nil(t, e, "unexpected error")
|
||||
assert.Equal(t, true, c.HelpVisible)
|
||||
assert.Equal(t, time.Duration(30), c.UpdateInterval)
|
||||
assert.Equal(t, true, c.AverageLoad)
|
||||
assert.Equal(t, true, c.PercpuLoad)
|
||||
assert.Equal(t, widgets.TempScale(100), c.TempScale)
|
||||
assert.Equal(t, widgets.TempScale(70), c.TempScale)
|
||||
assert.Equal(t, true, c.Statusbar)
|
||||
assert.Equal(t, "eth0", c.NetInterface)
|
||||
assert.Equal(t, "minimal", c.Layout)
|
||||
@ -77,7 +64,7 @@ func TestParse(t *testing.T) {
|
||||
}
|
||||
for _, tc := range tests {
|
||||
in := strings.NewReader(tc.i)
|
||||
c := Config{}
|
||||
c := NewConfig()
|
||||
e := load(in, &c)
|
||||
tc.f(c, e)
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package devices
|
||||
|
||||
// TODO: https://github.com/elastic/go-sysinfo
|
||||
// TODO: https://github.com/mackerelio/go-osstat
|
||||
// TODO: https://github.com/akhenakh/statgo
|
||||
// TODO: https://github.com/jaypipes/ghw
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
psCpu "github.com/shirou/gopsutil/cpu"
|
||||
)
|
||||
|
||||
// FIXME: broken % under Linux. Doesn't reflect reality *at all*.
|
||||
func init() {
|
||||
f := func(cpus map[string]int, l bool) map[string]error {
|
||||
cpuCount, err := psCpu.Counts(l)
|
||||
|
162
devices/data/smc.tsv
Normal file
162
devices/data/smc.tsv
Normal file
@ -0,0 +1,162 @@
|
||||
"TCXC" "PECI CPU"
|
||||
"TCXc" "PECI CPU"
|
||||
"TC0P" "CPU 1 Proximity"
|
||||
"TC0H" "CPU 1 Heatsink"
|
||||
"TC0D" "CPU 1 Package"
|
||||
"TC0E" "CPU 1"
|
||||
"TC0F" "CPU 1"
|
||||
"TC1C" "CPU Core 1"
|
||||
"TC2C" "CPU Core 2"
|
||||
"TC3C" "CPU Core 3"
|
||||
"TC4C" "CPU Core 4"
|
||||
"TC5C" "CPU Core 5"
|
||||
"TC6C" "CPU Core 6"
|
||||
"TC7C" "CPU Core 7"
|
||||
"TC8C" "CPU Core 8"
|
||||
"TCAH" "CPU 1 Heatsink Alt."
|
||||
"TCAD" "CPU 1 Package Alt."
|
||||
"TC1P" "CPU 2 Proximity"
|
||||
"TC1H" "CPU 2 Heatsink"
|
||||
"TC1D" "CPU 2 Package"
|
||||
"TC1E" "CPU 2"
|
||||
"TC1F" "CPU 2"
|
||||
"TCBH" "CPU 2 Heatsink Alt."
|
||||
"TCBD" "CPU 2 Package Alt."
|
||||
"TCSC" "PECI SA"
|
||||
"TCSc" "PECI SA"
|
||||
"TCSA" "PECI SA"
|
||||
"TCGC" "PECI GPU"
|
||||
"TCGc" "PECI GPU"
|
||||
"TG0P" "GPU Proximity"
|
||||
"TG0D" "GPU Die"
|
||||
"TG1D" "GPU Die"
|
||||
"TG0H" "GPU Heatsink"
|
||||
"TG1H" "GPU Heatsink"
|
||||
"Ts0S" "Memory Proximity"
|
||||
"TM0P" "Mem Bank A1"
|
||||
"TM1P" "Mem Bank A2"
|
||||
"TM8P" "Mem Bank B1"
|
||||
"TM9P" "Mem Bank B2"
|
||||
"TM0S" "Mem Module A1"
|
||||
"TM1S" "Mem Module A2"
|
||||
"TM8S" "Mem Module B1"
|
||||
"TM9S" "Mem Module B2"
|
||||
"TN0D" "Northbridge Die"
|
||||
"TN0P" "Northbridge Proximity 1"
|
||||
"TN1P" "Northbridge Proximity 2"
|
||||
"TN0C" "MCH Die"
|
||||
"TN0H" "MCH Heatsink"
|
||||
"TP0D" "PCH Die"
|
||||
"TPCD" "PCH Die"
|
||||
"TP0P" "PCH Proximity"
|
||||
"TA0P" "Airflow 1"
|
||||
"TA1P" "Airflow 2"
|
||||
"Th0H" "Heatpipe 1"
|
||||
"Th1H" "Heatpipe 2"
|
||||
"Th2H" "Heatpipe 3"
|
||||
"Tm0P" "Mainboard Proximity"
|
||||
"Tp0P" "Powerboard Proximity"
|
||||
"Ts0P" "Palm Rest"
|
||||
"Tb0P" "BLC Proximity"
|
||||
"TL0P" "LCD Proximity"
|
||||
"TW0P" "Airport Proximity"
|
||||
"TH0P" "HDD Bay 1"
|
||||
"TH1P" "HDD Bay 2"
|
||||
"TH2P" "HDD Bay 3"
|
||||
"TH3P" "HDD Bay 4"
|
||||
"TO0P" "Optical Drive"
|
||||
"TB0T" "Battery TS_MAX"
|
||||
"TB1T" "Battery 1"
|
||||
"TB2T" "Battery 2"
|
||||
"TB3T" "Battery"
|
||||
"Tp0P" "Power Supply 1"
|
||||
"Tp0C" "Power Supply 1 Alt."
|
||||
"Tp1P" "Power Supply 2"
|
||||
"Tp1C" "Power Supply 2 Alt."
|
||||
"Tp2P" "Power Supply 3"
|
||||
"Tp3P" "Power Supply 4"
|
||||
"Tp4P" "Power Supply 5"
|
||||
"Tp5P" "Power Supply 6"
|
||||
"TS0C" "Expansion Slots"
|
||||
"TA0S" "PCI Slot 1 Pos 1"
|
||||
"TA1S" "PCI Slot 1 Pos 2"
|
||||
"TA2S" "PCI Slot 2 Pos 1"
|
||||
"TA3S" "PCI Slot 2 Pos 2"
|
||||
"VC0C" "CPU Core 1"
|
||||
"VC1C" "CPU Core 2"
|
||||
"VC2C" "CPU Core 3"
|
||||
"VC3C" "CPU Core 4"
|
||||
"VC4C" "CPU Core 5"
|
||||
"VC5C" "CPU Core 6"
|
||||
"VC6C" "CPU Core 7"
|
||||
"VC7C" "CPU Core 8"
|
||||
"VV1R" "CPU VTT"
|
||||
"VG0C" "GPU Core"
|
||||
"VM0R" "Memory"
|
||||
"VN1R" "PCH"
|
||||
"VN0C" "MCH"
|
||||
"VD0R" "Mainboard S0 Rail"
|
||||
"VD5R" "Mainboard S5 Rail"
|
||||
"VP0R" "12V Rail"
|
||||
"Vp0C" "12V Vcc"
|
||||
"VV2S" "Main 3V"
|
||||
"VR3R" "Main 3.3V"
|
||||
"VV1S" "Main 5V"
|
||||
"VH05" "Main 5V"
|
||||
"VV9S" "Main 12V"
|
||||
"VD2R" "Main 12V"
|
||||
"VV7S" "Auxiliary 3V"
|
||||
"VV3S" "Standby 3V"
|
||||
"VV8S" "Standby 5V"
|
||||
"VeES" "PCIe 12V"
|
||||
"VBAT" "Battery"
|
||||
"Vb0R" "CMOS Battery"
|
||||
"IC0C" "CPU Core"
|
||||
"IC1C" "CPU VccIO"
|
||||
"IC2C" "CPU VccSA"
|
||||
"IC0R" "CPU Rail"
|
||||
"IC5R" "CPU DRAM"
|
||||
"IC8R" "CPU PLL"
|
||||
"IC0G" "CPU GFX"
|
||||
"IC0M" "CPU Memory"
|
||||
"IG0C" "GPU Rail"
|
||||
"IM0C" "Memory Controller"
|
||||
"IM0R" "Memory Rail"
|
||||
"IN0C" "MCH"
|
||||
"ID0R" "Mainboard S0 Rail"
|
||||
"ID5R" "Mainboard S5 Rail"
|
||||
"IO0R" "Misc. Rail"
|
||||
"IB0R" "Battery Rail"
|
||||
"IPBR" "Charger BMON"
|
||||
"PC0C" "CPU Core 1"
|
||||
"PC1C" "CPU Core 2"
|
||||
"PC2C" "CPU Core 3"
|
||||
"PC3C" "CPU Core 4"
|
||||
"PC4C" "CPU Core 5"
|
||||
"PC5C" "CPU Core 6"
|
||||
"PC6C" "CPU Core 7"
|
||||
"PC7C" "CPU Core 8"
|
||||
"PCPC" "CPU Cores"
|
||||
"PCPG" "CPU GFX"
|
||||
"PCPD" "CPU DRAM"
|
||||
"PCTR" "CPU Total"
|
||||
"PCPL" "CPU Total"
|
||||
"PC1R" "CPU Rail"
|
||||
"PC5R" "CPU S0 Rail"
|
||||
"PGTR" "GPU Total"
|
||||
"PG0R" "GPU Rail"
|
||||
"PM0R" "Memory Rail"
|
||||
"PN0C" "MCH"
|
||||
"PN1R" "PCH Rail"
|
||||
"PC0R" "Mainboard S0 Rail"
|
||||
"PD0R" "Mainboard S0 Rail"
|
||||
"PD5R" "Mainboard S5 Rail"
|
||||
"PH02" "Main 3.3V Rail"
|
||||
"PH05" "Main 5V Rail"
|
||||
"Pp0R" "12V Rail"
|
||||
"PD2R" "Main 12V Rail"
|
||||
"PO0R" "Misc. Rail"
|
||||
"PBLC" "Battery Rail"
|
||||
"PB0R" "Battery Rail"
|
||||
"PDTR" "DC In Total"
|
||||
"PSTR" "System Total"
|
|
@ -1,700 +0,0 @@
|
||||
/*
|
||||
* Apple System Management Controller (SMC) API from user space for Intel based
|
||||
* Macs. Works by talking to the AppleSMC.kext (kernel extension), the driver
|
||||
* for the SMC.
|
||||
*
|
||||
* smc.c
|
||||
* libsmc
|
||||
*
|
||||
* Copyright (C) 2014 beltex <https://github.com/beltex>
|
||||
*
|
||||
* Based off of fork from:
|
||||
* osx-cpu-temp <https://github.com/lavoiesl/osx-cpu-temp>
|
||||
*
|
||||
* With credits to:
|
||||
*
|
||||
* Copyright (C) 2006 devnull
|
||||
* Apple System Management Control (SMC) Tool
|
||||
*
|
||||
* Copyright (C) 2006 Hendrik Holtmann
|
||||
* smcFanControl <https://github.com/hholtmann/smcFanControl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "smc.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: MACROS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Name of the SMC IOService as seen in the IORegistry. You can view it either via
|
||||
command line with ioreg or through the IORegistryExplorer app (found on Apple's
|
||||
developer site - Hardware IO Tools for Xcode)
|
||||
*/
|
||||
#define IOSERVICE_SMC "AppleSMC"
|
||||
|
||||
|
||||
/**
|
||||
IOService for getting machine model name
|
||||
*/
|
||||
#define IOSERVICE_MODEL "IOPlatformExpertDevice"
|
||||
|
||||
|
||||
/**
|
||||
SMC data types - 4 byte multi-character constants
|
||||
|
||||
Sources: See TMP SMC keys in smc.h
|
||||
|
||||
http://stackoverflow.com/questions/22160746/fpe2-and-sp78-data-types
|
||||
*/
|
||||
#define DATA_TYPE_UINT8 "ui8 "
|
||||
#define DATA_TYPE_UINT16 "ui16"
|
||||
#define DATA_TYPE_UINT32 "ui32"
|
||||
#define DATA_TYPE_FLAG "flag"
|
||||
#define DATA_TYPE_FPE2 "fpe2"
|
||||
#define DATA_TYPE_SFDS "{fds"
|
||||
#define DATA_TYPE_SP78 "sp78"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: GLOBAL VARS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Our connection to the SMC
|
||||
*/
|
||||
static io_connect_t conn;
|
||||
|
||||
|
||||
/**
|
||||
Number of characters in an SMC key
|
||||
*/
|
||||
static const int SMC_KEY_SIZE = 4;
|
||||
|
||||
|
||||
/**
|
||||
Number of characters in a data type "key" returned from the SMC. See data type
|
||||
macros.
|
||||
*/
|
||||
static const int DATA_TYPE_SIZE = 4;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: ENUMS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Defined by AppleSMC.kext. See SMCParamStruct.
|
||||
|
||||
These are SMC specific return codes
|
||||
*/
|
||||
typedef enum {
|
||||
kSMCSuccess = 0,
|
||||
kSMCError = 1,
|
||||
kSMCKeyNotFound = 0x84
|
||||
} kSMC_t;
|
||||
|
||||
|
||||
/**
|
||||
Defined by AppleSMC.kext. See SMCParamStruct.
|
||||
|
||||
Function selectors. Used to tell the SMC which function inside it to call.
|
||||
*/
|
||||
typedef enum {
|
||||
kSMCUserClientOpen = 0,
|
||||
kSMCUserClientClose = 1,
|
||||
kSMCHandleYPCEvent = 2,
|
||||
kSMCReadKey = 5,
|
||||
kSMCWriteKey = 6,
|
||||
kSMCGetKeyCount = 7,
|
||||
kSMCGetKeyFromIndex = 8,
|
||||
kSMCGetKeyInfo = 9
|
||||
} selector_t;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: STRUCTS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Defined by AppleSMC.kext. See SMCParamStruct.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char major;
|
||||
unsigned char minor;
|
||||
unsigned char build;
|
||||
unsigned char reserved;
|
||||
unsigned short release;
|
||||
} SMCVersion;
|
||||
|
||||
|
||||
/**
|
||||
Defined by AppleSMC.kext. See SMCParamStruct.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t version;
|
||||
uint16_t length;
|
||||
uint32_t cpuPLimit;
|
||||
uint32_t gpuPLimit;
|
||||
uint32_t memPLimit;
|
||||
} SMCPLimitData;
|
||||
|
||||
|
||||
/**
|
||||
Defined by AppleSMC.kext. See SMCParamStruct.
|
||||
|
||||
- dataSize : How many values written to SMCParamStruct.bytes
|
||||
- dataType : Type of data written to SMCParamStruct.bytes. This lets us know how
|
||||
to interpret it (translate it to human readable)
|
||||
*/
|
||||
typedef struct {
|
||||
IOByteCount dataSize;
|
||||
uint32_t dataType;
|
||||
uint8_t dataColors;
|
||||
} SMCKeyInfoData;
|
||||
|
||||
|
||||
/**
|
||||
Defined by AppleSMC.kext.
|
||||
|
||||
This is the predefined struct that must be passed to communicate with the
|
||||
AppleSMC driver. While the driver is closed source, the definition of this
|
||||
struct happened to appear in the Apple PowerManagement project at around
|
||||
version 211, and soon after disappeared. It can be seen in the PrivateLib.c
|
||||
file under pmconfigd.
|
||||
|
||||
https://www.opensource.apple.com/source/PowerManagement/PowerManagement-211/
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t key;
|
||||
SMCVersion vers;
|
||||
SMCPLimitData pLimitData;
|
||||
SMCKeyInfoData keyInfo;
|
||||
uint8_t result;
|
||||
uint8_t status;
|
||||
uint8_t data8;
|
||||
uint32_t data32;
|
||||
uint8_t bytes[32];
|
||||
} SMCParamStruct;
|
||||
|
||||
|
||||
/**
|
||||
Used for returning data from the SMC.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t data[32];
|
||||
uint32_t dataType;
|
||||
uint32_t dataSize;
|
||||
kSMC_t kSMC;
|
||||
} smc_return_t;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: HELPERS - TYPE CONVERSION
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Convert data from SMC of fpe2 type to human readable.
|
||||
|
||||
:param: data Data from the SMC to be converted. Assumed data size of 2.
|
||||
:returns: Converted data
|
||||
*/
|
||||
static unsigned int from_fpe2(uint8_t data[32])
|
||||
{
|
||||
unsigned int ans = 0;
|
||||
|
||||
// Data type for fan calls - fpe2
|
||||
// This is assumend to mean floating point, with 2 exponent bits
|
||||
// http://stackoverflow.com/questions/22160746/fpe2-and-sp78-data-types
|
||||
ans += data[0] << 6;
|
||||
ans += data[1] << 2;
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert to fpe2 data type to be passed to SMC.
|
||||
|
||||
:param: val Value to convert
|
||||
:param: data Pointer to data array to place result
|
||||
*/
|
||||
static void to_fpe2(unsigned int val, uint8_t *data)
|
||||
{
|
||||
data[0] = val >> 6;
|
||||
data[1] = (val << 2) ^ (data[0] << 8);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert SMC key to uint32_t. This must be done to pass it to the SMC.
|
||||
|
||||
:param: key The SMC key to convert
|
||||
:returns: uint32_t translation.
|
||||
Returns zero if key is not 4 characters in length.
|
||||
*/
|
||||
static uint32_t to_uint32_t(char *key)
|
||||
{
|
||||
uint32_t ans = 0;
|
||||
uint32_t shift = 24;
|
||||
|
||||
// SMC key is expected to be 4 bytes - thus 4 chars
|
||||
if (strlen(key) != SMC_KEY_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SMC_KEY_SIZE; i++) {
|
||||
ans += key[i] << shift;
|
||||
shift -= 8;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
For converting the dataType return from the SMC to human readable 4 byte
|
||||
multi-character constant.
|
||||
*/
|
||||
static void to_string(uint32_t val, char *dataType)
|
||||
{
|
||||
int shift = 24;
|
||||
|
||||
for (int i = 0; i < DATA_TYPE_SIZE; i++) {
|
||||
// To get each char, we shift it into the lower 8 bits, and then & by
|
||||
// 255 to insolate it
|
||||
dataType[i] = (val >> shift) & 0xff;
|
||||
shift -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: HELPERS - TMP CONVERSION
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Celsius to Fahrenheit
|
||||
*/
|
||||
static double to_fahrenheit(double tmp)
|
||||
{
|
||||
// http://en.wikipedia.org/wiki/Fahrenheit#Definition_and_conversions
|
||||
return (tmp * 1.8) + 32;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Celsius to Kelvin
|
||||
*/
|
||||
static double to_kelvin(double tmp)
|
||||
{
|
||||
// http://en.wikipedia.org/wiki/Kelvin
|
||||
return tmp + 273.15;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: "PRIVATE" FUNCTIONS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Make a call to the SMC
|
||||
|
||||
:param: inputStruct Struct that holds data telling the SMC what you want
|
||||
:param: outputStruct Struct holding the SMC's response
|
||||
:returns: I/O Kit return code
|
||||
*/
|
||||
static kern_return_t call_smc(SMCParamStruct *inputStruct,
|
||||
SMCParamStruct *outputStruct)
|
||||
{
|
||||
kern_return_t result;
|
||||
size_t inputStructCnt = sizeof(SMCParamStruct);
|
||||
size_t outputStructCnt = sizeof(SMCParamStruct);
|
||||
|
||||
result = IOConnectCallStructMethod(conn, kSMCHandleYPCEvent,
|
||||
inputStruct,
|
||||
inputStructCnt,
|
||||
outputStruct,
|
||||
&outputStructCnt);
|
||||
|
||||
if (result != kIOReturnSuccess) {
|
||||
// IOReturn error code lookup. See "Accessing Hardware From Applications
|
||||
// -> Handling Errors" Apple doc
|
||||
result = err_get_code(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from the SMC
|
||||
|
||||
:param: key The SMC key
|
||||
*/
|
||||
static kern_return_t read_smc(char *key, smc_return_t *result_smc)
|
||||
{
|
||||
kern_return_t result;
|
||||
SMCParamStruct inputStruct;
|
||||
SMCParamStruct outputStruct;
|
||||
|
||||
memset(&inputStruct, 0, sizeof(SMCParamStruct));
|
||||
memset(&outputStruct, 0, sizeof(SMCParamStruct));
|
||||
memset(result_smc, 0, sizeof(smc_return_t));
|
||||
|
||||
// First call to AppleSMC - get key info
|
||||
inputStruct.key = to_uint32_t(key);
|
||||
inputStruct.data8 = kSMCGetKeyInfo;
|
||||
|
||||
result = call_smc(&inputStruct, &outputStruct);
|
||||
result_smc->kSMC = outputStruct.result;
|
||||
|
||||
if (result != kIOReturnSuccess || outputStruct.result != kSMCSuccess) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Store data for return
|
||||
result_smc->dataSize = outputStruct.keyInfo.dataSize;
|
||||
result_smc->dataType = outputStruct.keyInfo.dataType;
|
||||
|
||||
|
||||
// Second call to AppleSMC - now we can get the data
|
||||
inputStruct.keyInfo.dataSize = outputStruct.keyInfo.dataSize;
|
||||
inputStruct.data8 = kSMCReadKey;
|
||||
|
||||
result = call_smc(&inputStruct, &outputStruct);
|
||||
result_smc->kSMC = outputStruct.result;
|
||||
|
||||
if (result != kIOReturnSuccess || outputStruct.result != kSMCSuccess) {
|
||||
return result;
|
||||
}
|
||||
|
||||
memcpy(result_smc->data, outputStruct.bytes, sizeof(outputStruct.bytes));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write data to the SMC.
|
||||
|
||||
:returns: IOReturn IOKit return code
|
||||
*/
|
||||
static kern_return_t write_smc(char *key, smc_return_t *result_smc)
|
||||
{
|
||||
kern_return_t result;
|
||||
SMCParamStruct inputStruct;
|
||||
SMCParamStruct outputStruct;
|
||||
|
||||
memset(&inputStruct, 0, sizeof(SMCParamStruct));
|
||||
memset(&outputStruct, 0, sizeof(SMCParamStruct));
|
||||
|
||||
// First call to AppleSMC - get key info
|
||||
inputStruct.key = to_uint32_t(key);
|
||||
inputStruct.data8 = kSMCGetKeyInfo;
|
||||
|
||||
result = call_smc(&inputStruct, &outputStruct);
|
||||
result_smc->kSMC = outputStruct.result;
|
||||
|
||||
if (result != kIOReturnSuccess || outputStruct.result != kSMCSuccess) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check data is correct
|
||||
if (result_smc->dataSize != outputStruct.keyInfo.dataSize ||
|
||||
result_smc->dataType != outputStruct.keyInfo.dataType) {
|
||||
return kIOReturnBadArgument;
|
||||
}
|
||||
|
||||
// Second call to AppleSMC - now we can write the data
|
||||
inputStruct.data8 = kSMCWriteKey;
|
||||
inputStruct.keyInfo.dataSize = outputStruct.keyInfo.dataSize;
|
||||
|
||||
// Set data to write
|
||||
memcpy(inputStruct.bytes, result_smc->data, sizeof(result_smc->data));
|
||||
|
||||
result = call_smc(&inputStruct, &outputStruct);
|
||||
result_smc->kSMC = outputStruct.result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the model name of the machine.
|
||||
*/
|
||||
static kern_return_t get_machine_model(io_name_t model)
|
||||
{
|
||||
io_service_t service;
|
||||
kern_return_t result;
|
||||
|
||||
service = IOServiceGetMatchingService(kIOMasterPortDefault,
|
||||
IOServiceMatching(IOSERVICE_MODEL));
|
||||
|
||||
if (service == 0) {
|
||||
printf("ERROR: %s NOT FOUND\n", IOSERVICE_MODEL);
|
||||
return kIOReturnError;
|
||||
}
|
||||
|
||||
// Get the model name
|
||||
result = IORegistryEntryGetName(service, model);
|
||||
IOObjectRelease(service);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: "PUBLIC" FUNCTIONS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
kern_return_t open_smc(void)
|
||||
{
|
||||
kern_return_t result;
|
||||
io_service_t service;
|
||||
|
||||
service = IOServiceGetMatchingService(kIOMasterPortDefault,
|
||||
IOServiceMatching(IOSERVICE_SMC));
|
||||
|
||||
if (service == 0) {
|
||||
// NOTE: IOServiceMatching documents 0 on failure
|
||||
printf("ERROR: %s NOT FOUND\n", IOSERVICE_SMC);
|
||||
return kIOReturnError;
|
||||
}
|
||||
|
||||
result = IOServiceOpen(service, mach_task_self(), 0, &conn);
|
||||
IOObjectRelease(service);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
kern_return_t close_smc(void)
|
||||
{
|
||||
return IOServiceClose(conn);
|
||||
}
|
||||
|
||||
|
||||
bool is_key_valid(char *key)
|
||||
{
|
||||
bool ans = false;
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
if (strlen(key) != SMC_KEY_SIZE) {
|
||||
printf("ERROR: Invalid key size - must be 4 chars\n");
|
||||
return ans;
|
||||
}
|
||||
|
||||
// Try a read and see if it succeeds
|
||||
result = read_smc(key, &result_smc);
|
||||
|
||||
if (result == kIOReturnSuccess && result_smc.kSMC == kSMCSuccess) {
|
||||
ans = true;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
double get_tmp(char *key, tmp_unit_t unit)
|
||||
{
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
result = read_smc(key, &result_smc);
|
||||
|
||||
if (!(result == kIOReturnSuccess &&
|
||||
result_smc.dataSize == 2 &&
|
||||
result_smc.dataType == to_uint32_t(DATA_TYPE_SP78))) {
|
||||
// Error
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// TODO: Create from_sp78() convert function
|
||||
double tmp = result_smc.data[0];
|
||||
|
||||
switch (unit) {
|
||||
case CELSIUS:
|
||||
break;
|
||||
case FAHRENHEIT:
|
||||
tmp = to_fahrenheit(tmp);
|
||||
break;
|
||||
case KELVIN:
|
||||
tmp = to_kelvin(tmp);
|
||||
break;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
bool is_battery_powered(void)
|
||||
{
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
result = read_smc(BATT_PWR, &result_smc);
|
||||
|
||||
if (!(result == kIOReturnSuccess &&
|
||||
result_smc.dataSize == 1 &&
|
||||
result_smc.dataType == to_uint32_t(DATA_TYPE_FLAG))) {
|
||||
// Error
|
||||
return false;
|
||||
}
|
||||
|
||||
return result_smc.data[0];
|
||||
}
|
||||
|
||||
|
||||
bool is_optical_disk_drive_full(void)
|
||||
{
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
result = read_smc(ODD_FULL, &result_smc);
|
||||
|
||||
if (!(result == kIOReturnSuccess &&
|
||||
result_smc.dataSize == 1 &&
|
||||
result_smc.dataType == to_uint32_t(DATA_TYPE_FLAG))) {
|
||||
// Error
|
||||
return false;
|
||||
}
|
||||
|
||||
return result_smc.data[0];
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: FAN FUNCTIONS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
bool get_fan_name(unsigned int fan_num, fan_name_t name)
|
||||
{
|
||||
char key[5];
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
sprintf(key, "F%dID", fan_num);
|
||||
result = read_smc(key, &result_smc);
|
||||
|
||||
if (!(result == kIOReturnSuccess &&
|
||||
result_smc.dataSize == 16 &&
|
||||
result_smc.dataType == to_uint32_t(DATA_TYPE_SFDS))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
We know the data size is 16 bytes and the type is "{fds", a custom
|
||||
struct defined by the AppleSMC.kext. See TMP enum sources for the
|
||||
struct.
|
||||
|
||||
The last 12 bytes contain the name of the fan, an array of chars, hence
|
||||
the loop range.
|
||||
*/
|
||||
int index = 0;
|
||||
for (int i = 4; i < 16; i++) {
|
||||
// Check if at the end (name may not be full 12 bytes)
|
||||
// Could check for 0 (null), but instead we check for 32 (space). This
|
||||
// is a hack to remove whitespace. :)
|
||||
if (result_smc.data[i] == 32) {
|
||||
break;
|
||||
}
|
||||
|
||||
name[index] = result_smc.data[i];
|
||||
index++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int get_num_fans(void)
|
||||
{
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
result = read_smc(NUM_FANS, &result_smc);
|
||||
|
||||
if (!(result == kIOReturnSuccess &&
|
||||
result_smc.dataSize == 1 &&
|
||||
result_smc.dataType == to_uint32_t(DATA_TYPE_UINT8))) {
|
||||
// Error
|
||||
return -1;
|
||||
}
|
||||
|
||||
return result_smc.data[0];
|
||||
}
|
||||
|
||||
|
||||
unsigned int get_fan_rpm(unsigned int fan_num)
|
||||
{
|
||||
char key[5];
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
sprintf(key, "F%dAc", fan_num);
|
||||
result = read_smc(key, &result_smc);
|
||||
|
||||
if (!(result == kIOReturnSuccess &&
|
||||
result_smc.dataSize == 2 &&
|
||||
result_smc.dataType == to_uint32_t(DATA_TYPE_FPE2))) {
|
||||
// Error
|
||||
return 0;
|
||||
}
|
||||
|
||||
return from_fpe2(result_smc.data);
|
||||
}
|
||||
|
||||
|
||||
bool set_fan_min_rpm(unsigned int fan_num, unsigned int rpm, bool auth)
|
||||
{
|
||||
// TODO: Add rpm val safety check
|
||||
char key[5];
|
||||
bool ans = false;
|
||||
kern_return_t result;
|
||||
smc_return_t result_smc;
|
||||
|
||||
memset(&result_smc, 0, sizeof(smc_return_t));
|
||||
|
||||
// TODO: Don't use magic number
|
||||
result_smc.dataSize = 2;
|
||||
result_smc.dataType = to_uint32_t(DATA_TYPE_FPE2);
|
||||
to_fpe2(rpm, result_smc.data);
|
||||
|
||||
sprintf(key, "F%dMn", fan_num);
|
||||
result = write_smc(key, &result_smc);
|
||||
|
||||
if (result == kIOReturnSuccess && result_smc.kSMC == kSMCSuccess) {
|
||||
ans = true;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Apple System Management Controller (SMC) API from user space for Intel based
|
||||
* Macs. Works by talking to the AppleSMC.kext (kernel extension), the driver
|
||||
* for the SMC.
|
||||
*
|
||||
* smc.h
|
||||
* libsmc
|
||||
*
|
||||
* Copyright (C) 2014 beltex <https://github.com/beltex>
|
||||
*
|
||||
* Based off of fork from:
|
||||
* osx-cpu-temp <https://github.com/lavoiesl/osx-cpu-temp>
|
||||
*
|
||||
* With credits to:
|
||||
*
|
||||
* Copyright (C) 2006 devnull
|
||||
* Apple System Management Control (SMC) Tool
|
||||
*
|
||||
* Copyright (C) 2006 Hendrik Holtmann
|
||||
* smcFanControl <https://github.com/hholtmann/smcFanControl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: MACROS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
SMC keys for temperature sensors - 4 byte multi-character constants
|
||||
|
||||
Not applicable to all Mac's of course. In adition, the definition of the codes
|
||||
may not be 100% accurate necessarily. Finally, list is incomplete.
|
||||
|
||||
Presumed letter translations:
|
||||
|
||||
- T = Temperature (if first char)
|
||||
- C = CPU
|
||||
- G = GPU
|
||||
- P = Proximity
|
||||
- D = Diode
|
||||
- H = Heatsink
|
||||
|
||||
Sources:
|
||||
|
||||
- https://www.apple.com/downloads/dashboard/status/istatpro.html
|
||||
- https://github.com/hholtmann/smcFanControl
|
||||
- https://github.com/jedda/OSX-Monitoring-Tools
|
||||
- http://www.parhelia.ch/blog/statics/k3_keys.html
|
||||
*/
|
||||
#define AMBIENT_AIR_0 "TA0P"
|
||||
#define AMBIENT_AIR_1 "TA1P"
|
||||
#define CPU_0_DIODE "TC0D"
|
||||
#define CPU_0_HEATSINK "TC0H"
|
||||
#define CPU_0_PROXIMITY "TC0P"
|
||||
#define ENCLOSURE_BASE_0 "TB0T"
|
||||
#define ENCLOSURE_BASE_1 "TB1T"
|
||||
#define ENCLOSURE_BASE_2 "TB2T"
|
||||
#define ENCLOSURE_BASE_3 "TB3T"
|
||||
#define GPU_0_DIODE "TG0D"
|
||||
#define GPU_0_HEATSINK "TG0H"
|
||||
#define GPU_0_PROXIMITY "TG0P"
|
||||
#define HARD_DRIVE_BAY "TH0P"
|
||||
#define MEMORY_SLOT_0 "TM0S"
|
||||
#define MEMORY_SLOTS_PROXIMITY "TM0P"
|
||||
#define NORTHBRIDGE "TN0H"
|
||||
#define NORTHBRIDGE_DIODE "TN0D"
|
||||
#define NORTHBRIDGE_PROXIMITY "TN0P"
|
||||
#define THUNDERBOLT_0 "TI0P"
|
||||
#define THUNDERBOLT_1 "TI1P"
|
||||
#define WIRELESS_MODULE "TW0P"
|
||||
|
||||
|
||||
/**
|
||||
SMC keys for fans - 4 byte multi-character constants
|
||||
|
||||
Number of fans on Macs vary of course, thus not all keys will be applicable.
|
||||
|
||||
Presumed letter translations:
|
||||
|
||||
- F = Fan
|
||||
- Ac = Acutal
|
||||
- Mn = Min
|
||||
- Mx = Max
|
||||
- Sf = Safe
|
||||
- Tg = Target
|
||||
|
||||
Sources: See TMP SMC keys
|
||||
*/
|
||||
#define FAN_0 "F0Ac"
|
||||
#define FAN_0_MIN_RPM "F0Mn"
|
||||
#define FAN_0_MAX_RPM "F0Mx"
|
||||
#define FAN_0_SAFE_RPM "F0Sf"
|
||||
#define FAN_0_TARGET_RPM "F0Tg"
|
||||
#define FAN_1 "F1Ac"
|
||||
#define FAN_1_MIN_RPM "F1Mn"
|
||||
#define FAN_1_MAX_RPM "F1Mx"
|
||||
#define FAN_1_SAFE_RPM "F1Sf"
|
||||
#define FAN_1_TARGET_RPM "F1Tg"
|
||||
#define FAN_2 "F2Ac"
|
||||
#define FAN_2_MIN_RPM "F2Mn"
|
||||
#define FAN_2_MAX_RPM "F2Mx"
|
||||
#define FAN_2_SAFE_RPM "F2Sf"
|
||||
#define FAN_2_TARGET_RPM "F2Tg"
|
||||
#define NUM_FANS "FNum"
|
||||
#define FORCE_BITS "FS! "
|
||||
|
||||
|
||||
/**
|
||||
Misc SMC keys - 4 byte multi-character constants
|
||||
|
||||
Sources: See TMP SMC keys
|
||||
*/
|
||||
#define BATT_PWR "BATP"
|
||||
#define NUM_KEYS "#KEY"
|
||||
#define ODD_FULL "MSDI"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: TYPES
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
typedef char fan_name_t[13];
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: ENUMS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
typedef enum {
|
||||
CELSIUS,
|
||||
FAHRENHEIT,
|
||||
KELVIN
|
||||
} tmp_unit_t;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: PROTOTYPES
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
Open a connection to the SMC
|
||||
|
||||
:returns: kIOReturnSuccess on successful connection to the SMC.
|
||||
*/
|
||||
kern_return_t open_smc(void);
|
||||
|
||||
|
||||
/**
|
||||
Close connection to the SMC
|
||||
|
||||
:returns: kIOReturnSuccess on successful close of connection to the SMC.
|
||||
*/
|
||||
kern_return_t close_smc(void);
|
||||
|
||||
|
||||
/**
|
||||
Check if an SMC key is valid. Useful for determining if a certain machine has
|
||||
particular sensor or fan for example.
|
||||
|
||||
:param: key The SMC key to check. 4 byte multi-character constant. Must be 4
|
||||
characters in length.
|
||||
:returns: True if the key is found, false otherwise
|
||||
*/
|
||||
bool is_key_valid(char *key);
|
||||
|
||||
|
||||
/**
|
||||
Get the current temperature from a sensor
|
||||
|
||||
:param: key The temperature sensor to read from
|
||||
:param: unit The unit for the temperature value.
|
||||
:returns: Temperature of sensor. If the sensor is not found, or an error
|
||||
occurs, return will be zero
|
||||
*/
|
||||
double get_tmp(char *key, tmp_unit_t unit);
|
||||
|
||||
|
||||
/**
|
||||
Is the machine being powered by the battery?
|
||||
|
||||
:returns: True if it is, false otherwise
|
||||
*/
|
||||
bool is_battery_powered(void);
|
||||
|
||||
|
||||
/**
|
||||
Is there a CD in the optical disk drive (ODD)?
|
||||
|
||||
:returns: True if there is, false otherwise
|
||||
*/
|
||||
bool is_optical_disk_drive_full(void);
|
||||
|
||||
|
||||
/**
|
||||
Get the name of a fan.
|
||||
|
||||
:param: fanNum The number of the fan to check
|
||||
:param: name The name of the fan. Return will be empty on error.
|
||||
:returns: True if successful, false otherwise.
|
||||
*/
|
||||
bool get_fan_name(unsigned int fan_num, fan_name_t name);
|
||||
|
||||
|
||||
/**
|
||||
Get the number of fans on this machine.
|
||||
|
||||
:returns: The number of fans. If an error occurs, return will be -1.
|
||||
*/
|
||||
int get_num_fans(void);
|
||||
|
||||
|
||||
/**
|
||||
Get the current speed (RPM - revolutions per minute) of a fan.
|
||||
|
||||
:param: fan_num The number of the fan to check
|
||||
:returns: The fan RPM. If the fan is not found, or an error occurs, return
|
||||
will be zero
|
||||
*/
|
||||
UInt get_fan_rpm(UInt fan_num);
|
||||
|
||||
|
||||
/**
|
||||
Set the minimum speed (RPM - revolutions per minute) of a fan. This method
|
||||
requires root privileges. By minimum we mean that OS X can interject and
|
||||
raise the fan speed if needed, however it will not go below this.
|
||||
|
||||
WARNING: You are playing with hardware here, BE CAREFUL.
|
||||
|
||||
:param: fan_num The number of the fan to set
|
||||
:param: rpm The speed you would like to set the fan to.
|
||||
:param: auth Should the function do authentication?
|
||||
:return: True if successful, false otherwise
|
||||
*/
|
||||
bool set_fan_min_rpm(unsigned int fan_num, unsigned int rpm, bool auth);
|
235
devices/smc.go
Normal file
235
devices/smc.go
Normal file
@ -0,0 +1,235 @@
|
||||
// Code generated by go-bindata.
|
||||
// sources:
|
||||
// data/smc.tsv
|
||||
// DO NOT EDIT!
|
||||
|
||||
package devices
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func bindataRead(data []byte, name string) ([]byte, error) {
|
||||
gz, err := gzip.NewReader(bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Read %q: %v", name, err)
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
_, err = io.Copy(&buf, gz)
|
||||
clErr := gz.Close()
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Read %q: %v", name, err)
|
||||
}
|
||||
if clErr != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
type asset struct {
|
||||
bytes []byte
|
||||
info os.FileInfo
|
||||
}
|
||||
|
||||
type bindataFileInfo struct {
|
||||
name string
|
||||
size int64
|
||||
mode os.FileMode
|
||||
modTime time.Time
|
||||
}
|
||||
|
||||
func (fi bindataFileInfo) Name() string {
|
||||
return fi.name
|
||||
}
|
||||
func (fi bindataFileInfo) Size() int64 {
|
||||
return fi.size
|
||||
}
|
||||
func (fi bindataFileInfo) Mode() os.FileMode {
|
||||
return fi.mode
|
||||
}
|
||||
func (fi bindataFileInfo) ModTime() time.Time {
|
||||
return fi.modTime
|
||||
}
|
||||
func (fi bindataFileInfo) IsDir() bool {
|
||||
return false
|
||||
}
|
||||
func (fi bindataFileInfo) Sys() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
var _smcTsv = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x95\xc1\x72\xab\x3a\x0f\xc7\xd7\x3d\x4f\xc1\xf0\x00\x1d\x4c\x92\x36\x67\x09\xa6\x05\x66\x42\xa2\x09\x29\x5f\x77\xdf\x10\xca\x6d\x99\x43\x02\x03\xf4\x9e\xe6\xed\xef\x58\xc6\xc6\x36\x64\xe9\x9f\x24\xdb\x92\xfe\xb2\xed\x13\x7d\xa7\xf6\x83\x0d\x2f\x34\xb6\x28\xbc\xd9\xbf\x18\x29\x4c\xe2\x80\xfd\x60\x53\x78\xb3\x88\x05\x5d\xf3\x53\x5d\xaa\xe1\xc6\x0d\x91\x34\x44\x65\x3e\xf4\xd5\xf5\x0f\xe7\xc1\x14\x90\x17\x7f\xf2\xcf\x92\xe3\x17\x81\xf9\xf2\x55\x5b\x12\x3a\x2e\x69\xd3\x95\x23\x73\x35\xe6\x22\x5b\x69\x6c\x85\x6c\xad\xb1\x35\xb2\x8d\xc6\x36\xc8\x9e\x34\xf6\x84\xec\x59\x63\xcf\xc8\xb6\x1a\xdb\x22\xf3\xe6\xc9\x5a\x5e\x3d\x3c\x72\xe3\x2c\xe3\xc9\x46\x44\xf9\x5c\xa3\x7c\x24\x92\x06\xad\x7c\x24\x98\x02\x94\xf2\x11\x51\x3e\x5e\x07\xf2\xaa\x2d\xfd\xf9\x66\xd3\x15\xfc\xd9\x8e\x93\x2d\x95\x0a\x48\x3d\x0e\x0a\x13\x78\x06\x08\x65\x48\x38\x4a\x24\x2c\x0c\x12\xa2\x68\x42\x78\xd3\x73\x0e\x51\x1a\x0c\x07\x15\x66\x15\x12\x13\xa0\xa8\x18\x50\x6b\x12\x92\x25\xda\x3b\xa9\xfd\x60\x27\xe5\xa5\xe9\x6e\xfa\x39\x09\x1e\x9f\x94\x17\xcb\xcf\x59\x21\x50\x4e\x09\xd1\x21\x16\x2e\xd9\x6a\xd0\xe7\x9e\xbf\x75\xc8\x3d\xc5\x69\x56\xd2\x7c\x7c\xd7\xa5\xdc\xd5\xc4\xe3\xbe\x06\x16\x3b\x9b\x18\xbd\xf7\x58\x97\x7d\xd3\x0d\x5f\xe7\xae\xfa\xf8\x2c\x45\x39\xf6\x98\x88\x6a\x90\x79\xf2\x19\xd9\x93\xfb\x0e\xe3\xd6\xac\x5b\x09\x8d\xa6\x2d\xa3\x11\xa8\xb5\x04\xbc\x01\x4c\x6e\x40\x4d\x80\x57\x61\x40\x2b\xb5\x87\xd8\xab\xba\x7f\xea\xe6\x2f\xbf\x93\x47\x54\x84\xb7\xf8\xc2\x43\xd9\x81\x6d\xd5\x8e\xe3\xfd\x45\x34\xc6\xfd\x5c\x8d\xe1\x78\x5f\x78\x33\xf3\xea\x7a\x6e\xf2\xee\x43\x3f\xbe\xe5\xb7\x6a\xfe\x96\xdd\x82\xb5\xe7\xd6\xbc\xbe\x58\xc7\xb2\x1f\x18\x3a\x23\xf2\x77\x54\xf7\xdc\x21\xde\xd1\x40\xc7\xff\x13\xd9\xb5\x4d\x37\xe8\xa6\x08\x4d\x51\x10\x58\x7e\x3e\x36\x23\x22\x2a\xc2\x84\x22\x57\x45\x98\x4f\xb4\x52\x11\xbe\x56\x07\xdc\xeb\xd0\x0e\x55\x91\xd7\x56\xd0\x55\xff\x62\xc9\x7d\xe7\xc4\xee\x9a\x0f\x43\xd9\xdd\xac\x53\xfa\xff\xc4\x7b\x47\x4e\x54\x8e\x47\xfb\xae\x8a\xf0\x68\x7f\xa5\x20\xa3\x56\x56\xfa\xdd\xb6\xf5\x18\xdb\xa2\x44\x74\x2e\x1f\x88\x96\xcc\x82\x5c\xce\x67\x41\xee\x14\xe4\xce\x82\x30\xf5\x76\x35\xe3\x98\x7f\xbb\x9e\x71\x7c\xb1\xdb\xcd\x8c\xe3\xab\x9d\xe2\x8d\x5f\x7e\xda\xfc\xda\x57\xcd\xd5\x4a\xeb\x66\xe8\xb9\x1a\x53\x14\x69\x8c\x88\x3d\xc7\x4d\x2f\x44\xb9\x60\xc1\x4c\x3c\x57\xb3\xb8\x4a\xcc\x6a\xc1\xc2\x62\x32\xea\xcc\xbe\xab\xcc\xf8\xc2\xb8\x9f\x3b\xfb\xae\x32\xe3\x0b\x5b\x23\x5b\xcf\xbe\xab\xcc\xf8\xc2\x9e\x90\x3d\xcd\xbe\xab\xcc\xf8\xc2\xd8\x77\x95\x65\xe4\x38\xb2\xec\x74\x62\x20\xc4\x0b\x87\xa3\x13\x23\x89\x73\x94\xaf\x27\x5b\xef\x31\x04\x68\x84\x0b\xf1\x6a\xb0\x45\xc0\x3d\xe5\x00\xa6\x8e\x75\xcc\xab\x1a\x4d\x1b\xc3\xb4\x91\x26\xc0\x28\xe2\x66\x92\x70\x9d\x31\x92\x15\x05\xde\x12\x2b\xcf\xa2\xad\x55\xc6\xc0\x71\x75\x94\xe0\x91\xa3\x8c\x48\x9f\x0d\x82\xc8\xd9\xe8\x20\xfb\x2d\x3d\x88\x8b\x24\x70\x8f\x06\xc9\x9e\x99\x8f\xf7\xfd\x53\xd5\x55\xde\xdd\xc6\xe3\x32\xec\x6f\x3a\xe4\xd7\x8f\xb3\x64\x5b\x95\xf1\x13\xca\x97\x51\x07\xa5\xd8\xcf\xf7\xf4\xd9\xca\xce\x98\x2d\x4d\x0e\xa9\x35\xd1\x58\x97\x09\x12\x29\x92\xac\x28\xe2\x03\x22\x57\x41\xf8\xc5\xc6\xd4\x11\xed\x1b\x6b\x17\xd3\x8d\x20\xc1\xd1\x4b\x90\x6c\x05\x81\xdd\x8e\x07\x85\x23\x08\x5f\xdf\x39\x48\x46\x20\xbb\x1c\x4f\x3a\x10\x3b\x27\xbc\xd5\xfc\x17\xa5\xcd\x75\xe8\x9a\xba\x2e\x3b\x6e\x9a\x24\x22\xfd\x55\x69\xc4\xf7\xa5\x11\xdf\x97\x46\x7c\xe0\x51\x55\x5f\x3c\x4a\xe6\x23\x13\x0f\x98\xa0\xe0\x63\x92\x5f\x79\xf7\x59\x76\x96\x9f\x1c\xf6\xf6\x2f\x1b\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x16\xa6\x0f\x28\xa8\xac\xe7\x48\x6f\x0e\x50\x08\xf4\x86\x02\x3d\x89\x86\x9e\x9a\x21\xaf\xb9\xd3\x6e\x86\x88\x21\x0d\x98\xa4\x31\x55\x1f\x42\xdc\x2c\x54\x23\x43\xe7\xa8\xb7\x1e\x96\xfa\x0b\x6a\x7f\x41\x3e\x0a\xd3\x69\x77\x3b\x0e\xf7\xc5\x00\xf7\xc5\x00\x91\xe3\xaa\x33\xaf\x70\x65\xce\x25\x6d\xcd\x57\x05\xf4\x61\x97\x78\x41\x63\xe0\xef\xe8\x5c\x63\xb0\xa8\x3c\x08\xb0\x80\x01\xb5\xe2\xeb\x54\xc2\x14\x61\x7a\xeb\x87\xf2\x22\xe8\x7f\x01\x00\x00\xff\xff\x1d\x32\xff\xb6\x46\x0d\x00\x00")
|
||||
|
||||
func smcTsvBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
_smcTsv,
|
||||
"smc.tsv",
|
||||
)
|
||||
}
|
||||
|
||||
func smcTsv() (*asset, error) {
|
||||
bytes, err := smcTsvBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "smc.tsv", size: 3398, mode: os.FileMode(420), modTime: time.Unix(1591711965, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// Asset loads and returns the asset for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func Asset(name string) ([]byte, error) {
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[cannonicalName]; ok {
|
||||
a, err := f()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
|
||||
}
|
||||
return a.bytes, nil
|
||||
}
|
||||
return nil, fmt.Errorf("Asset %s not found", name)
|
||||
}
|
||||
|
||||
// MustAsset is like Asset but panics when Asset would return an error.
|
||||
// It simplifies safe initialization of global variables.
|
||||
func MustAsset(name string) []byte {
|
||||
a, err := Asset(name)
|
||||
if err != nil {
|
||||
panic("asset: Asset(" + name + "): " + err.Error())
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// AssetInfo loads and returns the asset info for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func AssetInfo(name string) (os.FileInfo, error) {
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[cannonicalName]; ok {
|
||||
a, err := f()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
|
||||
}
|
||||
return a.info, nil
|
||||
}
|
||||
return nil, fmt.Errorf("AssetInfo %s not found", name)
|
||||
}
|
||||
|
||||
// AssetNames returns the names of the assets.
|
||||
func AssetNames() []string {
|
||||
names := make([]string, 0, len(_bindata))
|
||||
for name := range _bindata {
|
||||
names = append(names, name)
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
var _bindata = map[string]func() (*asset, error){
|
||||
"smc.tsv": smcTsv,
|
||||
}
|
||||
|
||||
// AssetDir returns the file names below a certain
|
||||
// directory embedded in the file by go-bindata.
|
||||
// For example if you run go-bindata on data/... and data contains the
|
||||
// following hierarchy:
|
||||
// data/
|
||||
// foo.txt
|
||||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
// then AssetDir("data") would return []string{"foo.txt", "img"}
|
||||
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
||||
// AssetDir("") will return []string{"data"}.
|
||||
func AssetDir(name string) ([]string, error) {
|
||||
node := _bintree
|
||||
if len(name) != 0 {
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
pathList := strings.Split(cannonicalName, "/")
|
||||
for _, p := range pathList {
|
||||
node = node.Children[p]
|
||||
if node == nil {
|
||||
return nil, fmt.Errorf("Asset %s not found", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
if node.Func != nil {
|
||||
return nil, fmt.Errorf("Asset %s not found", name)
|
||||
}
|
||||
rv := make([]string, 0, len(node.Children))
|
||||
for childName := range node.Children {
|
||||
rv = append(rv, childName)
|
||||
}
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
type bintree struct {
|
||||
Func func() (*asset, error)
|
||||
Children map[string]*bintree
|
||||
}
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"smc.tsv": &bintree{smcTsv, map[string]*bintree{}},
|
||||
}}
|
||||
|
||||
// RestoreAsset restores an asset under the given directory
|
||||
func RestoreAsset(dir, name string) error {
|
||||
data, err := Asset(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info, err := AssetInfo(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RestoreAssets restores an asset under the given directory recursively
|
||||
func RestoreAssets(dir, name string) error {
|
||||
children, err := AssetDir(name)
|
||||
// File
|
||||
if err != nil {
|
||||
return RestoreAsset(dir, name)
|
||||
}
|
||||
// Dir
|
||||
for _, child := range children {
|
||||
err = RestoreAssets(dir, filepath.Join(name, child))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func _filePath(dir, name string) string {
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package devices
|
||||
|
||||
//go:generate go-bindata -pkg devices -prefix data -o smc.go data
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
// TODO add thermal history graph. Update when something changes?
|
||||
|
||||
var tempUpdates []func(map[string]int) map[string]error
|
||||
|
||||
func RegisterTemp(update func(map[string]int) map[string]error) {
|
||||
|
@ -2,44 +2,74 @@
|
||||
|
||||
package devices
|
||||
|
||||
import smc "github.com/xxxserxxx/iSMC"
|
||||
|
||||
func init() {
|
||||
RegisterTemp(update)
|
||||
RegisterDeviceList(Temperatures, devs, defs)
|
||||
ts = make(map[string]float32)
|
||||
}
|
||||
|
||||
var ts map[string]float32
|
||||
|
||||
func update(temps map[string]int) map[string]error {
|
||||
err := smc.GetTemp(ts)
|
||||
if err != nil {
|
||||
return map[string]error{"temps": err}
|
||||
}
|
||||
for k, v := range ts {
|
||||
if _, ok := temps[k]; ok {
|
||||
temps[k] = int(v + 0.5)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/csv"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
"io"
|
||||
)
|
||||
|
||||
// All possible thermometers
|
||||
func devs() []string {
|
||||
rv := make([]string, len(smc.AppleTemp))
|
||||
for i, v := range smc.AppleTemp {
|
||||
rv[i] = v.Desc
|
||||
// Did we already populate the sensorMap?
|
||||
if sensorMap != nil {
|
||||
return defs()
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
||||
func defs() []string {
|
||||
// CPU 0 CPU 1 GPU Memory Disk
|
||||
ids := map[string]bool{"TC0P": true, "TC1P": true, "TG0P": true, "Ts0S": true, "TH0P": true}
|
||||
rv := make([]string, 0, len(ids))
|
||||
for _, v := range smc.AppleTemp {
|
||||
if ids[v.Key] {
|
||||
rv = append(rv, v.Desc)
|
||||
// Otherwise, get the sensor data from the system & filter it
|
||||
ids := loadIDs()
|
||||
sensors, err := host.SensorsTemperatures()
|
||||
if err != nil {
|
||||
// FIXME log an error here
|
||||
return []string{}
|
||||
}
|
||||
rv := make([]string, 0, len(sensors))
|
||||
sensorMap = make(map[string]string)
|
||||
for _, sensor := range sensors {
|
||||
// 0-value sensors are not implemented
|
||||
if sensor.Temperature == 0 {
|
||||
continue
|
||||
}
|
||||
if label, ok := ids[sensor.SensorKey]; ok {
|
||||
sensorMap[sensor.SensorKey] = label
|
||||
rv = append(rv, label)
|
||||
}
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
||||
// Only the ones filtered
|
||||
func defs() []string {
|
||||
rv := make([]string, 0, len(sensorMap))
|
||||
for _, val := range sensorMap {
|
||||
rv = append(rv, val)
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
||||
// loadIDs parses the embedded smc.tsv data that maps Darwin SMC
|
||||
// sensor IDs to their human-readable labels into an array and returns the
|
||||
// array. The array keys are the 4-letter sensor keys; the values are the
|
||||
// human labels.
|
||||
func loadIDs() map[string]string {
|
||||
rv := make(map[string]string)
|
||||
data, err := Asset("smc.tsv")
|
||||
parser := csv.NewReader(bytes.NewReader(data))
|
||||
parser.Comma = '\t'
|
||||
var line []string
|
||||
for {
|
||||
if line, err = parser.Read(); err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
// FIXME log an error here
|
||||
break
|
||||
}
|
||||
// The line is malformed if len(line) != 2, but because the asset is static
|
||||
// it makes no sense to report the error to downstream users. This must be
|
||||
// tested at/around compile time.
|
||||
// FIXME assert all lines in smc.tsv have 2 columns during unit tests
|
||||
if len(line) == 2 {
|
||||
rv[line[0]] = line[1]
|
||||
}
|
||||
}
|
||||
return rv
|
||||
|
45
devices/temp_darwin_test.go
Normal file
45
devices/temp_darwin_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
// +build darwin
|
||||
|
||||
package devices
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_loadIDs(t *testing.T) {
|
||||
tests := []struct {
|
||||
key string
|
||||
want string
|
||||
}{
|
||||
{"TCAD", "CPU 1 Package Alt."},
|
||||
{"TC1P", "CPU 2 Proximity"},
|
||||
{"TC1H", "CPU 2 Heatsink"},
|
||||
{"TC1D", "CPU 2 Package"},
|
||||
{"TC1E", "CPU 2"},
|
||||
{"TC1F", "CPU 2"},
|
||||
{"TCBH", "CPU 2 Heatsink Alt."},
|
||||
{"TCBD", "CPU 2 Package Alt."},
|
||||
{"TG0P", "GPU Proximity"},
|
||||
{"TG1D", "GPU Die"},
|
||||
{"TG0H", "GPU Heatsink"},
|
||||
{"TG1H", "GPU Heatsink"},
|
||||
{"Ts0S", "Memory Proximity"},
|
||||
{"TM0P", "Mem Bank A1"},
|
||||
{"TM9P", "Mem Bank B2"},
|
||||
{"TCXC", "PECI CPU"},
|
||||
{"PSTR", "System Total"},
|
||||
}
|
||||
ids := loadIDs()
|
||||
L := 161
|
||||
if len(ids) != L {
|
||||
t.Errorf("len(loadIDs) = %d, want %d", len(ids), L)
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run("contents", func(t *testing.T) {
|
||||
got := ids[tt.key]
|
||||
if got != tt.want {
|
||||
t.Errorf("ids[%s] = %v, want %v", tt.key, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
package devices
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -11,6 +12,10 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
if len(devs()) == 0 {
|
||||
log.Println("temp: no thermal sensors found")
|
||||
return
|
||||
}
|
||||
RegisterTemp(update)
|
||||
RegisterDeviceList(Temperatures, devs, devs)
|
||||
}
|
||||
@ -50,8 +55,19 @@ func update(temps map[string]int) map[string]error {
|
||||
|
||||
func devs() []string {
|
||||
rv := make([]string, 0, len(sensorOIDS))
|
||||
// Check that thermal sensors are really available; they aren't in VMs
|
||||
bs, err := exec.Command("sysctl", "-a").Output()
|
||||
if err != nil {
|
||||
log.Printf("temp: failure to get system information %s", err.Error())
|
||||
return []string{}
|
||||
}
|
||||
for k, _ := range sensorOIDS {
|
||||
rv = append(rv, k)
|
||||
idx := strings.Index(string(bs), k)
|
||||
if idx < 0 {
|
||||
log.Printf("temp: no device %s found", k)
|
||||
} else {
|
||||
rv = append(rv, k)
|
||||
}
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
@ -5,37 +5,15 @@ package devices
|
||||
import (
|
||||
"strings"
|
||||
|
||||
psHost "github.com/shirou/gopsutil/host"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
)
|
||||
|
||||
func init() {
|
||||
devs() // Populate the sensorMap
|
||||
RegisterTemp(getTemps)
|
||||
RegisterDeviceList(Temperatures, devs, defs)
|
||||
}
|
||||
|
||||
func getTemps(temps map[string]int) map[string]error {
|
||||
sensors, err := psHost.SensorsTemperatures()
|
||||
if err != nil {
|
||||
return map[string]error{"psHost": err}
|
||||
}
|
||||
for _, sensor := range sensors {
|
||||
label := sensorMap[sensor.SensorKey]
|
||||
if _, ok := temps[label]; ok {
|
||||
temps[label] = int(sensor.Temperature)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Optimization to avoid string manipulation every update
|
||||
var sensorMap map[string]string
|
||||
|
||||
// All possible thermometers
|
||||
func devs() []string {
|
||||
if sensorMap == nil {
|
||||
sensorMap = make(map[string]string)
|
||||
}
|
||||
sensors, err := psHost.SensorsTemperatures()
|
||||
sensors, err := host.SensorsTemperatures()
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
|
30
devices/temp_nix.go
Normal file
30
devices/temp_nix.go
Normal file
@ -0,0 +1,30 @@
|
||||
// +build linux darwin
|
||||
|
||||
package devices
|
||||
|
||||
import (
|
||||
"github.com/shirou/gopsutil/host"
|
||||
)
|
||||
|
||||
func init() {
|
||||
devs() // Populate the sensorMap
|
||||
RegisterTemp(getTemps)
|
||||
RegisterDeviceList(Temperatures, devs, defs)
|
||||
}
|
||||
|
||||
func getTemps(temps map[string]int) map[string]error {
|
||||
sensors, err := host.SensorsTemperatures()
|
||||
if err != nil {
|
||||
return map[string]error{"gopsutil host": err}
|
||||
}
|
||||
for _, sensor := range sensors {
|
||||
label := sensorMap[sensor.SensorKey]
|
||||
if _, ok := temps[label]; ok {
|
||||
temps[label] = int(sensor.Temperature)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Optimization to avoid string manipulation every update
|
||||
var sensorMap map[string]string
|
7
docs/bashtop.md
Normal file
7
docs/bashtop.md
Normal file
@ -0,0 +1,7 @@
|
||||
# A comment about bashtop
|
||||
|
||||
Among tops, bashtop deserves extra recognition. It's one of the most impressive pieces of work I've encountered, on a couple of levels. For one, it is full of interesting, uncommon, and *useful* features. For another, it was accomplished with pure bash. In other words, it does far more with a far less sophisticated tool than it's peers. bashtop has a thoughtful and intelligent design of how information is presented. It has an attractive interface, with features like greyscale coloring in the process list that draw your eye to the heaviest processes. It's a beautiful, pleasant terminal UI, and I haven't yet seen anything as good, even among GUIs with all of the tools at their disposal.
|
||||
|
||||
bashtop is also utterly insane. It is a single, 140KB, 3,508-line bash script. The author claims to be doing a rewrite in Python, but that will never undo the admiration I have for what he accomplished with bash. Respect, Aristocratos.
|
||||
|
||||
If bashtop is so great, then why am I maintaining gotop? Two reasons. First, because I can't contribute to bashtop. I'm not that good with bash - not at the astronomic level Aristocratos is working at - and I really don't *want* to be that good. I've been there, and bash -- while universal, very useful, and probably my go-to scripting tool -- is hell to maintain at any scale. 3,500 lines of bash is a headache, no matter how you slice it. And second, because it's relatively heavy on the CPU for a tool that's supposed to sit off to the side and be glanced at occasionally. But it is an inspiration, and I sincerely believe we all -- all of us developers -- can learn something about good UI design from bashtop.
|
12
docs/colorschemes.md
Normal file
12
docs/colorschemes.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Colorschemes
|
||||
|
||||
gotop ships with a few colorschemes which can be set with the `-c` flag followed by the name of one. You can find all the colorschemes in the [colorschemes folder](./colorschemes).
|
||||
|
||||
To make a custom colorscheme, check out the [template](./colorschemes/template.go) for instructions and then use [default.json](./colorschemes/default.json) as a starter. Then put the file at `~/.config/gotop/<name>.json` and load it with `gotop -c <name>`. Colorschemes PR's are welcome!
|
||||
|
||||
To list all built-in color schemes, call:
|
||||
|
||||
```
|
||||
gotop --list colorschemes
|
||||
```
|
||||
|
12
docs/configuration.md
Normal file
12
docs/configuration.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Config file
|
||||
|
||||
Most command-line settings can be persisted into a configuration file. The config file is named `gotop.conf` and can be located in several places. The first place gotop will look is in the current directory; after this, the locations depend on the OS and distribution. On Linux using XDG, for instance, the home location of `~/.config/gotop/gotop.conf` is the second location. The last location is a system-wide global location, such as `/etc/gotop/gotop.conf`. The `-h` help command will print out all of the locations, in order. Command-line options override values in any config files, and only the first config file found is loaded.
|
||||
|
||||
A configuration file can be created using the `--write-config` command-line argument. This will try to place the config file in the home config directory (the second location), but if it's unable to do so it'll write a file to the current directory.
|
||||
|
||||
Config file changes can be made by combining command-line arguments with `--write-config`. For example, to persist the `solarized` theme, call:
|
||||
|
||||
```
|
||||
gotop -c solarized --write-config
|
||||
```
|
||||
|
37
docs/devices.md
Normal file
37
docs/devices.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Device filtering
|
||||
|
||||
Some devices have quite a number of data points; on OSX, for instance, there are dozens of temperature readings. These can be filtered through a configuration file. There is no command-line argument for this filter.
|
||||
|
||||
The list will grow, but for now the only device that supports filtering is the temperature widget. The configuration entry is called `temperature`, and it contains an exact-match list of comma-separated values with no spaces. To see the list of valid values, run gotop with the `--list devices` command. Gotop will print out the type of device and the legal values. For example, on Linux:
|
||||
|
||||
```
|
||||
$ gotop --list devices
|
||||
Temperatures:
|
||||
acpitz
|
||||
nvme_composite
|
||||
nvme_sensor1
|
||||
nvme_sensor2
|
||||
pch_cannonlake
|
||||
coretemp_packageid0
|
||||
coretemp_core0
|
||||
coretemp_core1
|
||||
coretemp_core2
|
||||
coretemp_core3
|
||||
ath10k_hwmon
|
||||
```
|
||||
You might then add the following line to the config file. First, find where gotop looks for config files:
|
||||
```
|
||||
➜ gotop --list paths
|
||||
Loadable colorschemes & layouts, and the config file, are searched for, in order:
|
||||
/home/ser/workspace/gotop.d/gotop
|
||||
/home/ser/.config/gotop
|
||||
/etc/xdg/gotop
|
||||
|
||||
The log file is in /home/ser/.cache/gotop/errors.log
|
||||
```
|
||||
So you might use `${HOME}/.config/gotop/gotop.conf`, and add (or modify) this line:
|
||||
```
|
||||
temperatures=acpitz,coretemp_core0,ath10k_hwmon
|
||||
```
|
||||
This will cause the temp widget to show only four of the eleven temps.
|
||||
|
79
docs/layouts.md
Normal file
79
docs/layouts.md
Normal file
@ -0,0 +1,79 @@
|
||||
# Layouts
|
||||
|
||||
gotop can parse and render layouts from a specification file. The format is
|
||||
intentionally simple. The amount of nesting levels is limited. Some examples
|
||||
are in the `layouts` directory; you can try each of these with, e.g.,
|
||||
`gotop --layout-file layouts/procs`. If you stick your layouts in
|
||||
`$XDG_CONFIG_HOME/gotop`, you can reference them on the command line with the
|
||||
`-l` argument, e.g. `gotop -l procs`.
|
||||
|
||||
The syntax for each widget in a row is:
|
||||
```
|
||||
(rowspan:)?widget(/weight)?
|
||||
```
|
||||
and these are separated by spaces.
|
||||
|
||||
1. Each line is a row
|
||||
2. Empty lines are skipped
|
||||
3. Spaces are compressed (so you can do limited visual formatting)
|
||||
4. Legal widget names are: cpu, disk, mem, temp, batt, net, procs
|
||||
5. Widget names are not case sensitive
|
||||
4. The simplest row is a single widget, by name, e.g. `cpu`
|
||||
5. **Weights**
|
||||
1. Widgets with no weights have a weight of 1.
|
||||
2. If multiple widgets are put on a row with no weights, they will all have
|
||||
the same width.
|
||||
3. Weights are integers
|
||||
4. A widget will have a width proportional to its weight divided by the
|
||||
total weight count of the row. E.g.,
|
||||
|
||||
```
|
||||
cpu net
|
||||
disk/2 mem/4
|
||||
```
|
||||
|
||||
The first row will have two widgets: the CPU and network widgets; each
|
||||
will be 50% of the total width wide. The second row will have two
|
||||
widgets: disk and memory; the first will be 2/6 ~= 33% wide, and the
|
||||
second will be 5/7 ~= 67% wide (or, memory will be twice as wide as disk).
|
||||
9. If prefixed by a number and colon, the widget will span that number of
|
||||
rows downward. E.g.
|
||||
|
||||
```
|
||||
mem 2:cpu
|
||||
net
|
||||
```
|
||||
|
||||
Here, memory and network will be in the same row as CPU, one over the other,
|
||||
and each half as high as CPU; it'll look like this:
|
||||
|
||||
```
|
||||
+------+------+
|
||||
| Mem | |
|
||||
+------+ CPU |
|
||||
| Net | |
|
||||
+------+------+
|
||||
```
|
||||
|
||||
10. Negative, 0, or non-integer weights will be recorded as "1". Same for row
|
||||
spans.
|
||||
11. Unrecognized widget names will cause the application to abort.
|
||||
12. In rows with multi-row spanning widgets **and** weights, weights in
|
||||
lower rows are ignored. Put the weight on the widgets in that row, not
|
||||
in later (spanned) rows.
|
||||
13. Widgets are filled in top down, left-to-right order.
|
||||
14. The larges row span in a row defines the top-level row span; all smaller
|
||||
row spans constitude sub-rows in the row. For example, `cpu mem/3 net/5`
|
||||
means that net/5 will be 5 rows tall overall, and mem will compose 3 of
|
||||
them. If following rows do not have enough widgets to fill the gaps,
|
||||
spacers will be used.
|
||||
|
||||
Yes, you're clever enough to break the layout algorithm, but if you try to
|
||||
build massive edifices, you're in for disappointment.
|
||||
|
||||
To list all built-in color schemes, call:
|
||||
|
||||
```
|
||||
gotop --list layouts
|
||||
```
|
||||
|
@ -1,23 +1,29 @@
|
||||
Current steps for a release:
|
||||
# Current steps for a release
|
||||
|
||||
### gotop
|
||||
1. Update Version in main.go
|
||||
2. Update CHANGELOG.md
|
||||
3. Tag
|
||||
4. Push everything
|
||||
5. When the github workflows complete, finish the draft release and publish.
|
||||
6. Wait for the [Homebrew](https://github.com/xxxserxxx/homebrew-gotop) and [AUR](https://github.com/xxxserxxx/gotop-linux] projects to finish building.
|
||||
1. check out gotop-linux and run `aurpublish aur` and `aurpublish aur-bin`
|
||||
2. update the hashes in the Nix package (see below), test build, push a pull request
|
||||
3. notify Homebrew
|
||||
5. Wait for the github workflows to complete
|
||||
6. Download and verify the correct version of one of the binaries
|
||||
7. Finish the draft release and publish.
|
||||
8. Check gotop-builder for a successful everything build; if successful, publish.
|
||||
10. Wait for the [AUR](https://github.com/xxxserxxx/gotop-linux] project to finish building.
|
||||
1. update arch (gotop-linux) and run `aurpublish gotop` and `aurpublish gotop-bin`
|
||||
2. Test install `gotop` and `gotop-bin` with running & version check
|
||||
11. Notify Nix
|
||||
12. ~~Notify Homebrew~~ Automated now.
|
||||
|
||||
Homebrew is automatically updated. The AUR project still needs secret
|
||||
credentials to aurpublish to the AUR repository, so the final publish step is
|
||||
still currently manual.
|
||||
The AUR project still needs secret credentials to aurpublish to the AUR
|
||||
repository, so the final publish step is still currently manual.
|
||||
|
||||
Oh, what a tangled web.
|
||||
|
||||
|
||||
## Nix
|
||||
|
||||
I haven't yet figured this out, so currently just file a ticket and hope somebody on that end updates the package.
|
||||
|
||||
Nix adds new and interesting complexities to the release.
|
||||
|
||||
0. Download the gotop src package; run sha256 on it to get the hash
|
||||
@ -27,11 +33,4 @@ Nix adds new and interesting complexities to the release.
|
||||
3. `cd /mnt`
|
||||
8. install & run vgo2nix to update deps.nix
|
||||
7. `nix-build -A gotop`
|
||||
8. When it fails, copy the hash and update the
|
||||
|
||||
|
||||
For plugin development:
|
||||
```
|
||||
V=$(git show -s --format=%cI HEAD | cut -b -19 | tr -cd '[:digit:]')-$(git rev-parse HEAD | cut -b -12)
|
||||
go build -ldflags "-X main.Version=$V" -o gotop ./cmd/gotop
|
||||
```
|
||||
8. When it fails, ...
|
||||
|
20
go.mod
20
go.mod
@ -1,27 +1,21 @@
|
||||
module github.com/xxxserxxx/gotop/v4
|
||||
|
||||
require (
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
|
||||
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
|
||||
github.com/VictoriaMetrics/metrics v1.11.2
|
||||
github.com/distatus/battery v0.9.0
|
||||
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815
|
||||
github.com/gizak/termui/v3 v3.0.0
|
||||
github.com/go-ole/go-ole v1.2.1 // indirect
|
||||
github.com/gizak/termui/v3 v3.1.0
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.4
|
||||
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.4.1
|
||||
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1
|
||||
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
|
||||
github.com/shirou/gopsutil v2.20.3+incompatible
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/xxxserxxx/iSMC v1.0.1
|
||||
github.com/xxxserxxx/lingo v1.0.1
|
||||
github.com/xxxserxxx/opflag v1.0.5
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
|
||||
golang.org/x/tools v0.0.0-20200425043458-8463f397d07c // indirect
|
||||
golang.org/x/tools/gopls v0.4.0 // indirect
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
|
||||
mvdan.cc/xurls/v2 v2.2.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0
|
||||
howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 // indirect
|
||||
)
|
||||
|
||||
go 1.14
|
||||
|
180
go.sum
180
go.sum
@ -1,196 +1,50 @@
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
github.com/VictoriaMetrics/metrics v1.11.2 h1:t/ceLP6SvagUqypCKU7cI7+tQn54+TIV/tGoxihHvx8=
|
||||
github.com/VictoriaMetrics/metrics v1.11.2/go.mod h1:LU2j9qq7xqZYXz8tF3/RQnB2z2MbZms5TDiIg9/NHiQ=
|
||||
github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd h1:XtfPmj9tQRilnrEmI1HjQhxXWRhEM+m8CACtaMJE/kM=
|
||||
github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd/go.mod h1:vjcQJUZJYD3MeVGhtZXSMnCHfUNZxsyYzJt90eCYxK4=
|
||||
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:Yg2hDs4b13Evkpj42FU2idX2cVXVFqQSheXYKM86Qsk=
|
||||
github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:MgJyK38wkzZbiZSKeIeFankxxSA8gayko/nr5x5bgBA=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/distatus/battery v0.9.0 h1:8NS5o00/j3Oh2xgocA6pQROTp5guoR+s8CZlWzHC4QM=
|
||||
github.com/distatus/battery v0.9.0/go.mod h1:gGO7GxHTi1zlRT+cAj8uGG0/8HFiqAeH0TJvoipnuPs=
|
||||
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815 h1:HMAfwOa33y82IaQEKQDfUCiwNlxtM1iw7HLM9ru0RNc=
|
||||
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:l7JNRynTRuqe45tpIyItHNqZWTxywYjp87MWTOnU5cg=
|
||||
github.com/gizak/termui/v3 v3.0.0 h1:NYTUG6ig/sJK05O5FyhWemwlVPO8ilNpvS/PgRtrKAE=
|
||||
github.com/gizak/termui/v3 v3.0.0/go.mod h1:uinu2dMdtMI+FTIdEFUJQT5y+KShnhQRshvPblXq3lY=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
|
||||
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/jdkeke142/lingo-toml v0.0.0-20181017194727-b6051718cb18 h1:LBrIpegfXvxuUKys1QUbjkStyoQgOMocUu2MFcKXHek=
|
||||
github.com/jdkeke142/lingo-toml v0.0.0-20181017194727-b6051718cb18/go.mod h1:jOyiHA3tuXflvGIObzfVCShTPCceouP/e6aTo6fvi3s=
|
||||
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc=
|
||||
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY=
|
||||
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
|
||||
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
|
||||
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||
github.com/panotza/gosmc v0.0.0-20190601191911-810267459a2a h1:P0QSyHOubLI2e6hccBBEjVX0vPWXoXui5QCAVNWdJSk=
|
||||
github.com/panotza/gosmc v0.0.0-20190601191911-810267459a2a/go.mod h1:u8Q8dpnMAam0MElxP2KjEROzXMk9G8X168RTpAZ9tPc=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1 h1:lh3PyZvY+B9nFliSGTn5uFuqQQJGuNrD0MLCokv09ag=
|
||||
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.4.1 h1:FFSuS004yOQEtDdTq+TAOLP5xUq63KqAFYyOi8zA+Y8=
|
||||
github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1fOy4Ee11vHhUFHQNpHhrBneOCNHVXS5w=
|
||||
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
|
||||
github.com/shirou/gopsutil v2.18.11+incompatible h1:PMFTKnFTr/YTRW5rbLK4vWALV3a+IGXse5nvhSjztmg=
|
||||
github.com/shirou/gopsutil v2.18.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shirou/gopsutil v2.20.3+incompatible h1:0JVooMPsT7A7HqEYdydp/OfjSOYSjhXV7w1hkKj/NPQ=
|
||||
github.com/shirou/gopsutil v2.20.3+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/xxxserxxx/gotop v0.0.0-20200228201131-d16cf1c6d2b9 h1:Sn+TuKkfF+CVaJjm4oVmeADtrOaHtrWpgqVLtsMpUqg=
|
||||
github.com/xxxserxxx/gotop/v3 v3.5.1 h1:aBf++Oxg7qCZpKqYpPPnXKFOxT1KYLPtiEXRh57ywu0=
|
||||
github.com/xxxserxxx/gotop/v3 v3.5.1/go.mod h1:DGPTiAmUhqE21xvokK64BuMxW+EmnOptaxpdOlqiH6s=
|
||||
github.com/xxxserxxx/iSMC v1.0.1 h1:M9Gkwnnkl+evvnugoB5yRYrbUP+cRIVOPM+xrHZc3Hs=
|
||||
github.com/xxxserxxx/iSMC v1.0.1/go.mod h1:TGgNjU7BF2DZSuxiTft+BdzxzcujFJYqFfMCzcTl/aY=
|
||||
github.com/valyala/fastrand v1.0.0 h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2ObdkI=
|
||||
github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
|
||||
github.com/valyala/histogram v1.0.1 h1:FzA7n2Tz/wKRMejgu3PV1vw3htAklTjjuoI6z3d4KDg=
|
||||
github.com/valyala/histogram v1.0.1/go.mod h1:lQy0xA4wUz2+IUnf97SivorsJIp8FxsnRd6x25q7Mto=
|
||||
github.com/xxxserxxx/lingo v1.0.1 h1:lPexOb0HEqYB50EaJdjaYFNATT8JhTcXljbQmCuXygE=
|
||||
github.com/xxxserxxx/lingo v1.0.1/go.mod h1:C2teIFiBLAmEhpLzRkwk7wP5R0eOoveXVYqD+5KOkAs=
|
||||
github.com/xxxserxxx/lingo-toml v0.0.0-20181017194727-b6051718cb18 h1:e00RDq5Gm5m22IuDG9/A7yF6AjAzoKbmQ+viQw5MUmI=
|
||||
github.com/xxxserxxx/lingo-toml v0.0.0-20181017194727-b6051718cb18/go.mod h1:QStBWvZx2oKk5HLYs3xrxAFvCdn8poBdB4uhZTF6yrw=
|
||||
github.com/xxxserxxx/opflag v1.0.0 h1:NabxbubvejqcdzQUHnsU8pBMAiWM+a/Rh2IJe56moiU=
|
||||
github.com/xxxserxxx/opflag v1.0.0/go.mod h1:Zf9bGkOcA35ypGfN25KX0iujVpZB5XwauEFjcfSKcBo=
|
||||
github.com/xxxserxxx/opflag v1.0.2 h1:TanW4Ck/RNal4fP2VVAvhEu7eBq4z+9hhGq9Q8OTq68=
|
||||
github.com/xxxserxxx/opflag v1.0.2/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4=
|
||||
github.com/xxxserxxx/opflag v1.0.3 h1:ugsBWZtSXUaMLEjPLW0WKGjq/gsrc0GpZYbCJY6ZHVY=
|
||||
github.com/xxxserxxx/opflag v1.0.3/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4=
|
||||
github.com/xxxserxxx/opflag v1.0.4 h1:g979b8oReAERfDKFTTwdvAYIarFxpVYOzYrHa/hMvNs=
|
||||
github.com/xxxserxxx/opflag v1.0.4/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4=
|
||||
github.com/xxxserxxx/opflag v1.0.5 h1:2H4Qtl1qe+dSkEcGt+fBe2mQ8z14MgkWPqcLaoa6k90=
|
||||
github.com/xxxserxxx/opflag v1.0.5/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200407041343-bf15fae40dea h1:DUwLyMDMUauGMd9kSLIlhhYJNELm06HuxeBdkFkeax4=
|
||||
golang.org/x/tools v0.0.0-20200407041343-bf15fae40dea/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200425043458-8463f397d07c h1:iHhCR0b26amDCiiO+kBguKZom9aMF+NrFxh9zeKR/XU=
|
||||
golang.org/x/tools v0.0.0-20200425043458-8463f397d07c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools/gopls v0.4.0 h1:G4+YP9kaV4dJb79J5MobyApxX493Qa6VoiTceUmxqik=
|
||||
golang.org/x/tools/gopls v0.4.0/go.mod h1:fdOZ8zb6nqlePvfek79JCskQXI4W+i2e1xT+xOPKMcY=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 h1:4Khi5GeNOkZS5DqSBRn4Sy7BE6GuxwOqARPqfurkdNk=
|
||||
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
|
||||
mvdan.cc/xurls/v2 v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=
|
||||
mvdan.cc/xurls/v2 v2.1.0/go.mod h1:5GrSd9rOnKOpZaji1OZLYL/yeAAtGDlo/cFe+8K5n8E=
|
||||
mvdan.cc/xurls/v2 v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
|
||||
mvdan.cc/xurls/v2 v2.2.0/go.mod h1:EV1RMtya9D6G5DMYPGD8zTQzaHet6Jh8gFlRgGRJeO8=
|
||||
howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
|
||||
|
@ -15,6 +15,10 @@ const (
|
||||
LOGFILE = "errors.log"
|
||||
)
|
||||
|
||||
// New creates a new logger in the default cache directory; the returned
|
||||
// WriteCloser should be closed when the program exits. If an error is
|
||||
// encountered during file creation, a nil WriteCloser and appropriate
|
||||
// error are returned.
|
||||
func New(c gotop.Config) (io.WriteCloser, error) {
|
||||
// create the log directory
|
||||
cache := c.ConfigDir.QueryCacheFolder()
|
||||
|
@ -1,4 +1,4 @@
|
||||
// +build arm64
|
||||
// +build !freebsd,arm64
|
||||
|
||||
package logging
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
// +build linux openbsd freebsd darwin
|
||||
// +build !arm64
|
||||
// +build linux,!arm64 openbsd,!arm64 freebsd darwin,!arm64
|
||||
|
||||
package logging
|
||||
|
||||
|
@ -2,22 +2,21 @@ package logging
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
//"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/shibukawa/configdir"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/xxxserxxx/gotop/v4"
|
||||
gotop "github.com/xxxserxxx/gotop/v4"
|
||||
)
|
||||
|
||||
func TestLogging(t *testing.T) {
|
||||
tdn := "testdir"
|
||||
path, err := filepath.Abs(tdn)
|
||||
c := gotop.NewConfig()
|
||||
c.ConfigDir = configdir.New("", "gotoptest")
|
||||
c.MaxLogSize = 300
|
||||
path := c.ConfigDir.QueryCacheFolder().Path
|
||||
var err error
|
||||
defer os.RemoveAll(path)
|
||||
c := gotop.Config{
|
||||
MaxLogSize: 300,
|
||||
}
|
||||
wc, err := New(c)
|
||||
assert.NoError(t, err)
|
||||
if err != nil {
|
||||
|
45
scripts/install_without_root.sh
Executable file
45
scripts/install_without_root.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Builds the gotop executable on machines where Go isn't installed,
|
||||
# or is the wrong version, and you don't have root access to upgrade or
|
||||
# install Go.
|
||||
#
|
||||
# You can run this without cloning the entire gotop repository (the script
|
||||
# will do this for you.)
|
||||
|
||||
set -x
|
||||
|
||||
VERSION='1.14.2' # Go version needed to build
|
||||
OS='linux'
|
||||
ARCH='amd64'
|
||||
BUILDDIR=/tmp/gotop-build
|
||||
INSTALLDIR=${HOME}/bin
|
||||
|
||||
GO_NAME=go${VERSION}.${OS}-${ARCH}
|
||||
|
||||
mkdir -p $BUILDDIR
|
||||
cd $BUILDDIR
|
||||
|
||||
curl https://dl.google.com/go/${GO_NAME}.tar.gz --output ./${GO_NAME}.tar.gz
|
||||
|
||||
tar -vxzf ${GO_NAME}.tar.gz
|
||||
rm ${GO_NAME}.tar.gz
|
||||
|
||||
PATH=$BUILDDIR/go/bin:$PATH
|
||||
|
||||
go env -w GOPATH=$BUILDDIR # otherwise go would create a directory in $HOME
|
||||
|
||||
rm -rf ./gotop
|
||||
git clone https://github.com/xxxserxxx/gotop.git
|
||||
cd ./gotop
|
||||
go build -o gotop ./cmd/gotop
|
||||
|
||||
go clean -modcache # otherwise $BUILDDIR/pkg would need sudo permissions to remove
|
||||
|
||||
mkdir -p $INSTALLDIR
|
||||
mv gotop ${INSTALLDIR}/gotop
|
||||
|
||||
rm -rf $BUILDDIR
|
||||
|
||||
printf "gotop installed in ${INSTALLDIR}/gotop\n"
|
||||
|
8
scripts/quality.sh
Executable file
8
scripts/quality.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
go test -covermode=count -coverprofile=docs/coverage.out ./...
|
||||
go tool cover -html=docs/coverage.out -o docs/quality.html
|
||||
|
||||
revive -config .revive.toml ./... > docs/lint.txt
|
||||
|
||||
abcgo -path . -sort -no-test | sed 's%^/home/ser/workspace/gotop.d/gotop/%%' > docs/abcgo.txt
|
26
scripts/size.sh
Executable file
26
scripts/size.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# size.sh is used to bisect the repository and find changes that negatively
|
||||
# impacted the gotop binary size. It does this by building gotop and exiting
|
||||
# successfully if the binary size is under a defined amount.
|
||||
#
|
||||
# Example:
|
||||
# ```
|
||||
# git bisect start
|
||||
# git bisect bad master
|
||||
# git bisect good 755037d211cc8e58e9ce43ee74a95a3036053dee
|
||||
# git bisect run ./size
|
||||
# ```
|
||||
|
||||
GOODSIZE=6000000
|
||||
|
||||
# Caleb's directory structure was different from the current structure, so
|
||||
# we have to find the main package first.
|
||||
pt=$(dirname $(find . -name main.go))
|
||||
# Give the executable a unique-ish name
|
||||
fn=gotop_$(git rev-list -1 HEAD)
|
||||
go build -o $fn $pt
|
||||
sz=$(ls -l $fn | awk '{print $5}')
|
||||
git checkout -- .
|
||||
[[ $sz -gt $GOODSIZE ]] && exit 1
|
||||
exit 0
|
@ -8,11 +8,18 @@ import (
|
||||
drawille "github.com/xxxserxxx/gotop/v4/termui/drawille-go"
|
||||
)
|
||||
|
||||
// LineGraph implements a line graph of data points.
|
||||
// LineGraph draws a graph like this ⣀⡠⠤⠔⣁ of data points.
|
||||
type LineGraph struct {
|
||||
*Block
|
||||
|
||||
Data map[string][]float64
|
||||
// Data is a size-managed data set for the graph. Each entry is a line;
|
||||
// each sub-array are points in the line. The maximum size of the
|
||||
// sub-arrays is controlled by the size of the canvas. This
|
||||
// array is **not** thread-safe. Do not modify this array, or it's
|
||||
// sub-arrays in threads different than the thread that calls `Draw()`
|
||||
Data map[string][]float64
|
||||
// The labels drawn on the graph for each of the lines; the key is shared
|
||||
// by Data; the value is the text that will be rendered.
|
||||
Labels map[string]string
|
||||
|
||||
HorizontalScale int
|
||||
@ -67,8 +74,9 @@ func (self *LineGraph) Draw(buf *Buffer) {
|
||||
// coordinates of last point
|
||||
lastY, lastX := -1, -1
|
||||
// assign colors to `colors` and lines/points to the canvas
|
||||
dx := self.Inner.Dx()
|
||||
for i := len(seriesData) - 1; i >= 0; i-- {
|
||||
x := ((self.Inner.Dx() + 1) * 2) - 1 - (((len(seriesData) - 1) - i) * self.HorizontalScale)
|
||||
x := ((dx + 1) * 2) - 1 - (((len(seriesData) - 1) - i) * self.HorizontalScale)
|
||||
y := ((self.Inner.Dy() + 1) * 4) - 1 - int((float64((self.Inner.Dy())*4)-1)*(seriesData[i]/100))
|
||||
if x < 0 {
|
||||
// render the line to the last point up to the wall
|
||||
@ -80,6 +88,9 @@ func (self *LineGraph) Draw(buf *Buffer) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(seriesData) > 4*dx {
|
||||
self.Data[seriesName] = seriesData[dx-1:]
|
||||
}
|
||||
break
|
||||
}
|
||||
if lastY == -1 { // if this is the first point
|
||||
|
@ -98,5 +98,9 @@ func (self *SparklineGroup) Draw(buf *Buffer) {
|
||||
image.Pt(self.Inner.Min.X+x-1, self.Inner.Min.Y+sparkY-1),
|
||||
)
|
||||
}
|
||||
dx := self.Inner.Dx()
|
||||
if len(line.Data) > 4*dx {
|
||||
line.Data = line.Data[dx-1:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
"github.com/distatus/battery"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
ui "github.com/xxxserxxx/gotop/v4/termui"
|
||||
)
|
||||
@ -16,7 +16,6 @@ import (
|
||||
type BatteryWidget struct {
|
||||
*ui.LineGraph
|
||||
updateInterval time.Duration
|
||||
metric []prometheus.Gauge
|
||||
}
|
||||
|
||||
func NewBatteryWidget(horizontalScale int) *BatteryWidget {
|
||||
@ -49,16 +48,14 @@ func (b *BatteryWidget) EnableMetric() {
|
||||
log.Printf(tr.Value("error.metricsetup", "batt", err.Error()))
|
||||
return
|
||||
}
|
||||
b.metric = make([]prometheus.Gauge, len(bats))
|
||||
for i, bat := range bats {
|
||||
gauge := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "battery",
|
||||
Name: fmt.Sprintf("%d", i),
|
||||
for i, _ := range bats {
|
||||
id := makeID(i)
|
||||
metrics.NewGauge(makeName("battery", i), func() float64 {
|
||||
if ds, ok := b.Data[id]; ok {
|
||||
return ds[len(ds)-1]
|
||||
}
|
||||
return 0.0
|
||||
})
|
||||
gauge.Set(bat.Current / bat.Full)
|
||||
b.metric[i] = gauge
|
||||
prometheus.MustRegister(gauge)
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,10 +94,8 @@ func (b *BatteryWidget) update() {
|
||||
id := makeID(i)
|
||||
perc := battery.Current / battery.Full
|
||||
percentFull := math.Abs(perc) * 100.0
|
||||
// TODO: look into this sort of thing; doesn't the array grow forever? Is the widget library truncating it?
|
||||
b.Data[id] = append(b.Data[id], percentFull)
|
||||
b.Labels[id] = fmt.Sprintf("%3.0f%% %.0f/%.0f", percentFull, math.Abs(battery.Current), math.Abs(battery.Full))
|
||||
if b.metric != nil {
|
||||
b.metric[i].Set(perc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,14 @@ import (
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
"github.com/distatus/battery"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/xxxserxxx/gotop/v4/termui"
|
||||
)
|
||||
|
||||
type BatteryGauge struct {
|
||||
*termui.Gauge
|
||||
metric prometheus.Gauge
|
||||
}
|
||||
|
||||
func NewBatteryGauge() *BatteryGauge {
|
||||
@ -35,32 +34,21 @@ func NewBatteryGauge() *BatteryGauge {
|
||||
}
|
||||
|
||||
func (b *BatteryGauge) EnableMetric() {
|
||||
bats, err := battery.GetAll()
|
||||
if err != nil {
|
||||
log.Printf(tr.Value("error.metricsetup", "power", err.Error()))
|
||||
return
|
||||
}
|
||||
mx := 0.0
|
||||
cu := 0.0
|
||||
for _, bat := range bats {
|
||||
mx += bat.Full
|
||||
cu += bat.Current
|
||||
gauge := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "battery",
|
||||
Name: "total",
|
||||
})
|
||||
gauge.Set(cu / mx)
|
||||
b.metric = gauge
|
||||
prometheus.MustRegister(gauge)
|
||||
}
|
||||
metrics.NewGauge(makeName("battery", "total"), func() float64 {
|
||||
return float64(b.Percent)
|
||||
})
|
||||
}
|
||||
|
||||
// Only report battery errors once.
|
||||
var errLogged = false
|
||||
|
||||
func (b *BatteryGauge) update() {
|
||||
// FIXME: Getting a lot of these in the logs
|
||||
bats, err := battery.GetAll()
|
||||
if err != nil {
|
||||
log.Printf(tr.Value("error.setup", "power", err.Error()))
|
||||
if !errLogged {
|
||||
log.Printf("error setting up batteries: %v", err)
|
||||
errLogged = true
|
||||
}
|
||||
return
|
||||
}
|
||||
mx := 0.0
|
||||
@ -81,7 +69,4 @@ func (b *BatteryGauge) update() {
|
||||
d, _ := time.ParseDuration(fmt.Sprintf("%fh", tn))
|
||||
b.Percent = int((cu / mx) * 100.0)
|
||||
b.Label = fmt.Sprintf(charging, b.Percent, d.Truncate(time.Minute))
|
||||
if b.metric != nil {
|
||||
b.metric.Set(cu / mx)
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,10 @@ package widgets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
"github.com/xxxserxxx/gotop/v4/devices"
|
||||
|
||||
ui "github.com/xxxserxxx/gotop/v4/termui"
|
||||
@ -19,7 +18,7 @@ type CPUWidget struct {
|
||||
ShowPerCPULoad bool
|
||||
updateInterval time.Duration
|
||||
updateLock sync.Mutex
|
||||
metric map[string]prometheus.Gauge
|
||||
cpuLoads map[string]float64
|
||||
}
|
||||
|
||||
var cpuLabels []string
|
||||
@ -31,6 +30,7 @@ func NewCPUWidget(updateInterval time.Duration, horizontalScale int, showAverage
|
||||
updateInterval: updateInterval,
|
||||
ShowAverageLoad: showAverageLoad,
|
||||
ShowPerCPULoad: showPerCPULoad,
|
||||
cpuLoads: make(map[string]float64),
|
||||
}
|
||||
self.Title = tr.Value("cpu")
|
||||
self.HorizontalScale = horizontalScale
|
||||
@ -66,26 +66,22 @@ func NewCPUWidget(updateInterval time.Duration, horizontalScale int, showAverage
|
||||
return self
|
||||
}
|
||||
|
||||
const AVRG = "AVRG"
|
||||
|
||||
func (cpu *CPUWidget) EnableMetric() {
|
||||
if cpu.ShowAverageLoad {
|
||||
cpu.metric = make(map[string]prometheus.Gauge)
|
||||
cpu.metric["AVRG"] = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Subsystem: "cpu",
|
||||
Name: "avg",
|
||||
metrics.NewGauge(makeName("cpu", " avg"), func() float64 {
|
||||
return cpu.cpuLoads[AVRG]
|
||||
})
|
||||
} else {
|
||||
cpus := make(map[string]int)
|
||||
devices.UpdateCPU(cpus, cpu.updateInterval, cpu.ShowPerCPULoad)
|
||||
cpu.metric = make(map[string]prometheus.Gauge)
|
||||
for key, perc := range cpus {
|
||||
gauge := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "cpu",
|
||||
Name: key,
|
||||
kc := key
|
||||
cpu.cpuLoads[key] = float64(perc)
|
||||
metrics.NewGauge(makeName("cpu", key), func() float64 {
|
||||
return cpu.cpuLoads[kc]
|
||||
})
|
||||
gauge.Set(float64(perc))
|
||||
prometheus.MustRegister(gauge)
|
||||
cpu.metric[key] = gauge
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,11 +104,9 @@ func (cpu *CPUWidget) update() {
|
||||
val = float64(v)
|
||||
break
|
||||
}
|
||||
cpu.Data["AVRG"] = append(cpu.Data["AVRG"], val)
|
||||
cpu.Labels["AVRG"] = fmt.Sprintf("%3.0f%%", val)
|
||||
if cpu.metric != nil {
|
||||
cpu.metric["AVRG"].Set(val)
|
||||
}
|
||||
cpu.Data[AVRG] = append(cpu.Data[AVRG], val)
|
||||
cpu.Labels[AVRG] = fmt.Sprintf("%3.0f%%", val)
|
||||
cpu.cpuLoads[AVRG] = val
|
||||
}()
|
||||
}
|
||||
|
||||
@ -127,13 +121,7 @@ func (cpu *CPUWidget) update() {
|
||||
for key, percent := range cpus {
|
||||
cpu.Data[key] = append(cpu.Data[key], float64(percent))
|
||||
cpu.Labels[key] = fmt.Sprintf("%d%%", percent)
|
||||
if cpu.metric != nil {
|
||||
if cpu.metric[key] == nil {
|
||||
log.Printf(tr.Value("error.nometrics", "cpu", key))
|
||||
} else {
|
||||
cpu.metric[key].Set(float64(percent))
|
||||
}
|
||||
}
|
||||
cpu.cpuLoads[key] = float64(percent)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
psDisk "github.com/shirou/gopsutil/disk"
|
||||
|
||||
ui "github.com/xxxserxxx/gotop/v4/termui"
|
||||
@ -29,7 +29,6 @@ type DiskWidget struct {
|
||||
*ui.Table
|
||||
updateInterval time.Duration
|
||||
Partitions map[string]*Partition
|
||||
metric map[string]prometheus.Gauge
|
||||
}
|
||||
|
||||
func NewDiskWidget() *DiskWidget {
|
||||
@ -63,17 +62,11 @@ func NewDiskWidget() *DiskWidget {
|
||||
}
|
||||
|
||||
func (disk *DiskWidget) EnableMetric() {
|
||||
disk.metric = make(map[string]prometheus.Gauge)
|
||||
for key, part := range disk.Partitions {
|
||||
gauge := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "disk",
|
||||
Name: strings.ReplaceAll(key, "/", ":"),
|
||||
//Name: strings.Replace(strings.Replace(part.Device, "/dev/", "", -1), "mapper/", "", -1),
|
||||
pc := part
|
||||
metrics.NewGauge(makeName("disk", strings.ReplaceAll(key, "/", ":")), func() float64 {
|
||||
return float64(pc.UsedPercent) / 100.0
|
||||
})
|
||||
gauge.Set(float64(part.UsedPercent) / 100.0)
|
||||
prometheus.MustRegister(gauge)
|
||||
disk.metric[key] = gauge
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,12 +167,5 @@ func (disk *DiskWidget) update() {
|
||||
disk.Rows[i][3] = partition.Free
|
||||
disk.Rows[i][4] = partition.BytesReadRecently
|
||||
disk.Rows[i][5] = partition.BytesWrittenRecently
|
||||
if disk.metric != nil {
|
||||
if disk.metric[key] == nil {
|
||||
log.Printf(tr.Value("error.nometrics", "disk", key))
|
||||
} else {
|
||||
disk.metric[key].Set(float64(partition.UsedPercent) / 100.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
|
||||
"github.com/xxxserxxx/gotop/v4/devices"
|
||||
ui "github.com/xxxserxxx/gotop/v4/termui"
|
||||
@ -14,52 +14,47 @@ import (
|
||||
type MemWidget struct {
|
||||
*ui.LineGraph
|
||||
updateInterval time.Duration
|
||||
metrics map[string]prometheus.Gauge
|
||||
}
|
||||
|
||||
func NewMemWidget(updateInterval time.Duration, horizontalScale int) *MemWidget {
|
||||
self := &MemWidget{
|
||||
widg := &MemWidget{
|
||||
LineGraph: ui.NewLineGraph(),
|
||||
updateInterval: updateInterval,
|
||||
}
|
||||
self.Title = " Memory Usage "
|
||||
self.HorizontalScale = horizontalScale
|
||||
widg.Title = " Memory Usage "
|
||||
widg.HorizontalScale = horizontalScale
|
||||
mems := make(map[string]devices.MemoryInfo)
|
||||
devices.UpdateMem(mems)
|
||||
for name, mem := range mems {
|
||||
self.Data[name] = []float64{0}
|
||||
self.renderMemInfo(name, mem)
|
||||
widg.Data[name] = []float64{0}
|
||||
widg.renderMemInfo(name, mem)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for range time.NewTicker(self.updateInterval).C {
|
||||
self.Lock()
|
||||
for range time.NewTicker(widg.updateInterval).C {
|
||||
widg.Lock()
|
||||
devices.UpdateMem(mems)
|
||||
for label, mi := range mems {
|
||||
self.renderMemInfo(label, mi)
|
||||
if self.metrics != nil && self.metrics[label] != nil {
|
||||
self.metrics[label].Set(mi.UsedPercent)
|
||||
}
|
||||
widg.renderMemInfo(label, mi)
|
||||
}
|
||||
self.Unlock()
|
||||
widg.Unlock()
|
||||
}
|
||||
}()
|
||||
|
||||
return self
|
||||
return widg
|
||||
}
|
||||
|
||||
func (mem *MemWidget) EnableMetric() {
|
||||
mem.metrics = make(map[string]prometheus.Gauge)
|
||||
mems := make(map[string]devices.MemoryInfo)
|
||||
devices.UpdateMem(mems)
|
||||
for l, m := range mems {
|
||||
mem.metrics[l] = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "memory",
|
||||
Name: l,
|
||||
for l, _ := range mems {
|
||||
lc := l
|
||||
metrics.NewGauge(makeName("memory", l), func() float64 {
|
||||
if ds, ok := mem.Data[lc]; ok {
|
||||
return ds[len(ds)-1]
|
||||
}
|
||||
return 0.0
|
||||
})
|
||||
mem.metrics[l].Set(m.UsedPercent)
|
||||
prometheus.MustRegister(mem.metrics[l])
|
||||
}
|
||||
}
|
||||
|
||||
|
19
widgets/metrics.go
Normal file
19
widgets/metrics.go
Normal file
@ -0,0 +1,19 @@
|
||||
package widgets
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// makeName creates a prometheus metric name in the gotop space
|
||||
// This function doesn't have to be very efficient because it's only
|
||||
// called at init time, and only a few dozen times... and it isn't
|
||||
// (very efficient).
|
||||
func makeName(parts ...interface{}) string {
|
||||
args := make([]string, len(parts)+1)
|
||||
args[0] = "gotop"
|
||||
for i, v := range parts {
|
||||
args[i+1] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
return strings.Join(args, "_")
|
||||
}
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
psNet "github.com/shirou/gopsutil/net"
|
||||
|
||||
ui "github.com/xxxserxxx/gotop/v4/termui"
|
||||
@ -28,8 +28,8 @@ type NetWidget struct {
|
||||
totalBytesRecv uint64
|
||||
totalBytesSent uint64
|
||||
NetInterface []string
|
||||
sentMetric prometheus.Counter
|
||||
recvMetric prometheus.Counter
|
||||
sentMetric *metrics.Counter
|
||||
recvMetric *metrics.Counter
|
||||
Mbps bool
|
||||
}
|
||||
|
||||
@ -66,19 +66,8 @@ func NewNetWidget(netInterface string) *NetWidget {
|
||||
}
|
||||
|
||||
func (net *NetWidget) EnableMetric() {
|
||||
net.recvMetric = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "net",
|
||||
Name: "recv",
|
||||
})
|
||||
prometheus.MustRegister(net.recvMetric)
|
||||
|
||||
net.sentMetric = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "net",
|
||||
Name: "sent",
|
||||
})
|
||||
prometheus.MustRegister(net.sentMetric)
|
||||
net.recvMetric = metrics.NewCounter(makeName("net", "recv"))
|
||||
net.sentMetric = metrics.NewCounter(makeName("net", "sent"))
|
||||
}
|
||||
|
||||
func (net *NetWidget) update() {
|
||||
@ -138,8 +127,8 @@ func (net *NetWidget) update() {
|
||||
net.Lines[0].Data = append(net.Lines[0].Data, int(recentBytesRecv))
|
||||
net.Lines[1].Data = append(net.Lines[1].Data, int(recentBytesSent))
|
||||
if net.sentMetric != nil {
|
||||
net.sentMetric.Add(float64(recentBytesSent))
|
||||
net.recvMetric.Add(float64(recentBytesRecv))
|
||||
net.sentMetric.Add(int(recentBytesSent))
|
||||
net.recvMetric.Add(int(recentBytesRecv))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/metrics"
|
||||
ui "github.com/gizak/termui/v3"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/xxxserxxx/gotop/v4/devices"
|
||||
"github.com/xxxserxxx/gotop/v4/utils"
|
||||
@ -28,7 +28,7 @@ type TempWidget struct {
|
||||
TempLowColor ui.Color
|
||||
TempHighColor ui.Color
|
||||
TempScale TempScale
|
||||
tempsMetric map[string]prometheus.Gauge
|
||||
temps map[string]float64
|
||||
}
|
||||
|
||||
func NewTempWidget(tempScale TempScale, filter []string) *TempWidget {
|
||||
@ -68,16 +68,12 @@ func NewTempWidget(tempScale TempScale, filter []string) *TempWidget {
|
||||
}
|
||||
|
||||
func (temp *TempWidget) EnableMetric() {
|
||||
temp.tempsMetric = make(map[string]prometheus.Gauge)
|
||||
for k, v := range temp.Data {
|
||||
gauge := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "gotop",
|
||||
Subsystem: "temp",
|
||||
Name: k,
|
||||
temp.temps = make(map[string]float64)
|
||||
for k, _ := range temp.Data {
|
||||
kc := k
|
||||
metrics.NewGauge(makeName("temp", k), func() float64 {
|
||||
return float64(temp.Data[kc])
|
||||
})
|
||||
gauge.Set(float64(v))
|
||||
prometheus.MustRegister(gauge)
|
||||
temp.tempsMetric[k] = gauge
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,9 +105,6 @@ func (temp *TempWidget) Draw(buf *ui.Buffer) {
|
||||
image.Pt(temp.Inner.Min.X, temp.Inner.Min.Y+y),
|
||||
)
|
||||
|
||||
if temp.tempsMetric != nil {
|
||||
temp.tempsMetric[key].Set(float64(temp.Data[key]))
|
||||
}
|
||||
temperature := fmt.Sprintf("%3d°%c", temp.Data[key], temp.TempScale)
|
||||
|
||||
buf.SetString(
|
||||
|
Loading…
x
Reference in New Issue
Block a user