Giter Club home page Giter Club logo

portop's Introduction

emerge_monitor

Monitor system status during Gentoo emerge. This is likely a bit system-specific and some things may not work out-of-the-box. This will probably mostly mean the CPU temperature display. A setup-agnostic implementation of that is hoped for at some point.

Requires root to read portage logs. Might even work with sudo -u portage. The second option should be more secure, or less likely to break something.

Demo Output

Output of the monitor in action as of commit c6ca17b. If that commit is no longer current, this output may not be current. I will keep updated between large revisions, otherwise this is just a general feel of the monitor.

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                    gentoo                                                     ││                                                 System Status                                                 │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                                Portage Status                                                 ││                                          Load average:0.58 0.42 0.38                                          │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│                                 !!! Error: no working merge found.                                            ││                                              cpu MHz : 2675.633                                               │
│                  (the -c option only works if there is an ongoing compilation, see manpage)                   ││                                              cpu MHz : 2397.806                                               │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│                                              cpu MHz : 3129.755                                               │
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│                                              cpu MHz : 2440.836                                               │
│                                                  emerge.log                                                   │├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤│                                               Core 0: +100.4°                                                 │
│ 1584815435:  >>> AUTOCLEAN: dev-vcs/gh-bin:0                                                                  ││                                                Core 1: +98.6°                                                 │
│ 1584815437:  === (1 of 1) Updating world file (dev-vcs/gh-bin-0.6.2)                                          ││                                               Core 2: +114.8°                                                 │
│ 1584815437:  === (1 of 1) Post-Build Cleaning (dev-vcs/gh-bin-0.6.2::/var/db/repos/p6nc/dev-vcs/gh-bin/gh-bin-││                                               Core 3: +102.2°                                                 │
│ 1584815437:  ::: completed emerge (1 of 1) dev-vcs/gh-bin-0.6.2 to /                                          │└───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
│ 1584815437:  *** Finished. Cleaning up...                                                                     │┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ 1584815437:  *** exiting successfully.                                                                        ││                                               emerge-fetch.log                                                │
│ 1584815437:  *** terminating.                                                                                 │├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│                                                                                                               │
                                                                                                                 │      0K ........                                              100% 57.6M=0s                                   │
                                                                                                                 │                                                                                                               │
                                                                                                                 │ 2020-03-20 21:34:47 (57.6 MB/s) - ‘/var/cache/distfiles/LWP-UserAgent-Cached-0.06.tar.gz.__download__’ save   │
                                                                                                                 │                                                                                                               │
                                                                                                                 │  * LWP-UserAgent-Cached-0.06.tar.gz BLAKE2B SHA512 size ;-) ...          [ ok ]                               │
                                                                                                                 │  * 0.0.2.tar.gz size ;-) ...                                             [ ok ]                               │
                                                                                                                 └───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Usage & Requirements

No special setup required for this one. However, a Bash-compatible shell, genlop, lm_sensors, and of course emerge are required to exist on the system. This will only work on Linux systems with the Portage package manager installed. Geared towards Gentoo Linux, it may work Bedrock, Mandrake, or derivatives.

Clone the repo: git clone --recurse https://github.com/ncdulo/portop
cd into it: cd portop
Run as root: sudo ./portop
Or if you'd rather run it as portage: sudo -u portage ./portop

portop's People

Contributors

ncdulo avatar phate6660 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

phate6660

portop's Issues

[BUG] `portop` kills the terminal cursor

Describe the bug
Currently, there are no hotkeys, keybinds, or way to properly exit portop. This is currently handled by sending the SIGINT signal to portop via Ctrl-c into the terminal where the program is running. There is a greater than zero chance that upon exiting portop in that fashion, the terminal cursor glyph will no longer be visible.

To Reproduce

  1. sudo portop
  2. From main dashboard view -- Ctrl-c
  3. Check for visibility of terminal cursor glyph on the prompt which appears in the bottom of the terminal after portop exits.

Note: The current workaround to make the cursor glyph visible again is to simply start another program which plays with the cursor, then exit it. This can be any number of commands from git {diff,log} to man man. It seems that any program which may hide the cursor, or use curses-style interfaces in the terminal may be able to 'reset' our cursor glyph, allowing it to become visible again.

Expected behavior
At the very minimum, portop should capture the SIGINT signal, and act upon it. I believe there is a bashsimplecurses function which is intended to be called as the program exits so that the terminal can be properly restored. For some reason, I did not add this in initially. Now that I see it is actually fairly important (I feel I should have known that from the start), we must add it in.

System
Gentoo Linux 17.1 Desktop profile
Linux 5.4.24 with Gentoo & CK patches
URxvt v9.22
ZSH 5.8 + OhMyZSH
Bash 4.4_p23-r1

[$] [0] <> uname -prm  
5.4.24-ck-x86_64 x86_64 Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz

Additional context
This may require further testing on various distro, terminal, shell setups. If you have tested, or are able to test, I would love a comment with your results -- pass or fail. Please include any relevant information such as shell, terminal, and kernel versions.

[FEATURE] Run as portage support

Is your feature request related to a problem? Please describe.
To be a little more secure, or less likely to break the system, we may not necessarily need to run as root. So long as the commands, or files in question are owned in some capacity by portage, we should be alright to sudo -u portage when running this program.

Describe the solution you'd like
Update the if block to include a check for (effective user id == 0) OR (effective user id == 250). Group 250 should always refer to portage on Gentoo systems by default. There may also be a way to determine the number automatically. Automatic detection is likely preferred, I think.

Describe alternatives you've considered
Run as root, always. This works just fine. But requires the user have permission to sudo as root. Most cases this is just fine but let's give the option to the user. Running with as few permissions as necessary is always a sensible choice.

Additional context
I had attempted to implement this from the start without results. Simply put, my bash-fu is not up to par at the moment. We'll get it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.