Giter VIP home page Giter VIP logo

ttop's Introduction

Build GitHub release (with filter) AUR version Github All Releases

ttop

System monitoring tool with historical data service, triggers and top-like TUI

image

  • Saving historical snapshots via systemd.timer or crontab

    • It is the main diff from htop, top, btop and etc
  • Scroll via historical data

  • External triggers (for notifications or other needs)

  • Ascii graph of historical stats (via https://github.com/Yardanico/asciigraph)

    • by default you see full day on the chart, see the moment of the spike and move into it for a detailed analysis
  • TUI with critical values highlights

  • Group by program

  • Search filters: @u - user u, #d - docker d

  • Temperature via sysfs

  • User-space only, doesn't require root permissions

  • Docker-related info

  • Threads tree

  • Static build

Install

Arch/AUR

yay -S ttop             # enables systemd.timers automatically

Static binary

curl -LO https://github.com/inv2004/ttop/releases/latest/download/ttop \
&& chmod +x ttop
mv ttop ~/.local/bin/   # add into PATH if necessary
ttop --on               # Optional: enable data collector in user's systemd.timers or crontab

Uninstall

ttop --off
rm ~/.local/bin/ttop

Build from source

curl https://nim-lang.org/choosenim/init.sh -sSf | sh    # Nim setup from nim-lang.org

git clone https://github.com/inv2004/ttop
cd ttop
nimble -d:release build

Triggers / Notifications

  • stmp support was removed in prev version by the reason that static binary with ssl is more that 3Mb

From v0.8.1 you can trigger external tool, for example curl, to send notifications

image

Config example

~/.config/ttop/ttop.toml or /etc/ttop.toml

My own server's config

[[trigger]]
cmd = "$HOME/.local/bin/tel.sh"

Config with all parameters described

  • if you need it
# light = false            # set true for light term (default = false)

# docker = "/var/run/docker.sock"   # docker's socket path

# [data]
# path = "/var/log/ttop" # custom storage path (default = if exists /var/log/ttop, else ~/.cache/ttop )

# Trigger is any external script or command which receives text from ttop into stdin + some envs
[[trigger]]              # telegram example
on_alert = true          # execute trigger on alert (true if no other on_* provided)
on_info = true           # execute trigger without alert (default = false)
debug = false            # output stdout/err from cmd (default = false)
cmd = '''
read -d '' TEXT
curl -X POST \
  -H 'Content-Type: application/json' \
  -d "{\"chat_id\": $CHAT_ID, \"text\": \"$TEXT\", \"disable_notification\": $TTOP_INFO}" \
  https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
'''

# cmd receives text from stdin. The following env vars are set:
#   TTOP_ALERT (true|false) - if alert
#   TTOP_INFO  (true|false) - opposite to alert
#   TTOP_TYPE  (alert|info) - trigger type
#   TTOP_HOST               - host name
# you can find your CHAT_ID by send smth to your bot and run:
#    curl https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates

[[trigger]]               # smtp example
cmd = '''
read -d '' TEXT
TEXT="Subject: ttop $TTOP_TYPE from $TTOP_HOST

$TEXT"
echo "$TEXT" | curl --ssl-reqd \
  --url 'smtps://smtp.gmail.com:465' \
  --user 'login:password' \
  --mail-from '[email protected]' \
  --mail-rcpt '[email protected]' \
  --upload-file -
'''

ttop's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ttop's Issues

"looks like" miss

% ./ttop --on  
systemctl check 'ttop.timer' 
/bin/sh: systemctl: command not found

cmd error: Looks like ttop.timer is already running system-wide
onoff.nim(70)            cmd

[ERROR] Failed to stop ttop.timer: Unit ttop.timer not loaded.

I don't know what happened, I just was trying to stop it

ttop --off

output:

systemctl is-active --quiet / 
systemctl --user stop 'ttop.timer' 
Failed to stop ttop.timer: Unit ttop.timer not loaded.

cmd error code: 5
onoff.nim(141)           cmd

nim 1.6.14
ubuntu 20.04.01 LTS

can't run ttop. cannot read from stream

I can't run ttop static binary (or when i use nimble build).

I get:

cannot read from stream
streams.nim(426)         read

trying to build from source with nim c -r ttop.nim fails with:

/ttop-1.5.0/src/ttop/tui.nim(530, 13) Error: undeclared identifier: 'getKeyWithTimeout'

I guess due to the illwill situation.

I'm running f39

thanks

Defining triggers

No documentation on defining the triggers.

Or are they preset to something? Would be good to know.

Arch / Debian build failed

  • fixed: Error: Unsatisfied dependency: nim (>= 1.6.12)
  • illwill dep: Error: Unsatisfied dependency: nim (>= 1.6.12)

/proc/PID/stat parsing bug

Looks like you fell victim to this:

https://news.ycombinator.com/item?id=34093845

Workarounds are more complex parsing {i.e. first find the last occurrence of ')' } or using /proc/PID/status which escapes special characters in the command name (after Name:HARDTAB, that is).

High CPU usage on keypress

Not sure if it's a bug, but ttop is consuming 100% CPU (according to ttop itself) when user repeatedly press up or down arrow key. Users have to do it to scroll the list of processes.

Error parsing COMM with spaces parsing

I'm so happy that your application fixed my low hardware resources, and now my 4GB RAM machine has a 1TB memory process running. Thank you!

Jokes a side, I think there is something when parsing command with spaces for threads.

Additional info:
Tested with static version 0.3.1 in NixOS Unstable

shot-2022-12-21_12-41-09

example (htop):
shot-2022-12-21_12-42-49

Any additional info I could provide to better debug it?

Other than that, ttop is really cool 😍

Not recording historical data

Installed via the executable on Centos 8.

Ran ttop --on.

Got

systemctl daemon-reload
systemctl enable --now 'ttop.timer'

Ran that. Then running ttop again says "No historical stats found".

Sorry if I'm missing something, perhaps I missed a step.

Light terminal theme support

Discussed in #20

Originally posted by nicck March 5, 2023
I've tried to use it with light terminal theme (Alabaster) and it took me some to realize columns are not actually empty. Are colors hardcoded? Is it possible to override colors via config somehow?

image

Cannot build from source

Hi,

My specs:

  • Pop!_OS
  • Nim 2.0.2

Cloning the repository and building with nimble build, it throws:

home/user/Nim/ttop/src/ttop/tui.nim(502, 16) Error: undeclared identifier: 'getKeys'  candidates (edit distance, scope distance); see '--spellSuggest': 
 (1, 6): 'getKey'
       Tip: 12 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

    Error:  Build failed for the package: ttop

Compilation Warning

/src/ttop.nim(35, 3) Warning: The bare except clause is deprecated; use `except CatchableError:` instead [BareExcept]

Awesome app!! 🙂:+1:

Raspberry Pi build error

Hi

Specs:

  • Raspberry Pi OS x64
  • Nim 1.6.10 (tried also with Nim 2 RC1, same problem)

Trying to build, I get this error:

pi@raspberrypi:~/ttop $ nimble build
  Verifying dependencies for [email protected]
 Installing illwill@any version
Downloading https://github.com/johnnovak/illwill using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Success: illwill installed successfully.
 Installing zippy@any version
Downloading https://github.com/guzba/zippy using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Success: zippy installed successfully.
 Installing asciigraph@any version
Downloading https://github.com/Yardanico/asciigraph using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Success: asciigraph installed successfully.
   Building ttop/ttop using c backend
/home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c: In function ‘adler32_neon__OOZOOZOnimbleZpkgsZzippy4548O4948O53ZzippyZadler515095simd_63’:
/home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c:661:4: note: use ‘-flax-vector-conversions’ to permit conversions between vectors with differing element types or numbers of subparts
  661 |    T41_ = vget_low_u32(vecS1);
      |    ^~~~
/home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c:661:11: error: incompatible types when assigning to type ‘uint8x8_t’ from type ‘uint32x2_t’
  661 |    T41_ = vget_low_u32(vecS1);
      |           ^~~~~~~~~~~~
/home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c:662:11: error: incompatible types when assigning to type ‘uint8x8_t’ from type ‘uint32x2_t’
  662 |    T42_ = vget_high_u32(vecS1);
      |           ^~~~~~~~~~~~~
/home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c:663:21: error: incompatible type for argument 1 of ‘vpadd_u32’
  663 |    sum1 = vpadd_u32(T41_, T42_);
      |                     ^~~~
      |                     |
      |                     uint8x8_t
In file included from /home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c:9:
/usr/lib/gcc/aarch64-linux-gnu/10/include/arm_neon.h:23265:23: note: expected ‘uint32x2_t’ but argument is of type ‘uint8x8_t’
23265 | vpadd_u32 (uint32x2_t __a, uint32x2_t __b)
      |            ~~~~~~~~~~~^~~
compilation terminated due to -fmax-errors=3.
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3   -I/home/pi/Downloads/nim-1.6.10/lib -I/home/pi/ttop/src -o /home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c.o /home/pi/.cache/nim/ttop_d/@m..@[email protected]@[email protected]@szippy@sadler32_simd.nim.c' failed with exit code: 1


       Tip: 41 messages have been suppressed, use --verbose to show them.
     Error: Build failed for package: ttop
        ... Execution failed with exit code 1
        ... Command: /home/pi/Downloads/nim-1.6.10/bin/nim c --colors:on --noNimblePath -d:NimblePkgVersion=0.3.5 --path:/home/pi/.nimble/pkgs/illwill-0.3.0 --path:/home/pi/.nimble/pkgs/zippy-0.10.5 --path:/home/pi/.nimble/pkgs/asciigraph-0.1.2 --hints:off -o:/home/pi/ttop/ttop /home/pi/ttop/src/ttop.nim

FreeBSD support

It would be great to have this beautiful tool under FreeBSD.

RFC: Collect via sftp

  • collect via sftp
    • if remote host contains fresh ttop blog: get last snapshot from it
    • else: collect via sftp
  • local blogs storage for multiple hosts
    • back compatibility

`ttop --on` from root

systemctl --user does not work from root
if the --user is removed - it does not see service files in home dir (~root/systemd/user)

top line is hard to read for me

using adwaita-dark in xfce (f38) the top bar background is a light teal with white text making it hard on the eyes for reading.

ttop_top_bar

thanks

Error on start [AssertionDefect]

I'm having some trouble getting it to run:

nimble

[user: /tmp] $ nimble install ttop
[user: /tmp] $ ttop
fatal.nim(54)            sysFatal
Error: unhandled exception: procfs.nim(274, 14) `0 == statvfs(cstring parts[1], stat)`  [AssertionDefect]

wget

[user: /tmp] $ wget https://github.com/inv2004/ttop/releases/latest/download/ttop
[user: /tmp] $ chmod +x ttop
[user: /tmp] $ ./ttop
fatal.nim(54)            sysFatal
Error: unhandled exception: procfs.nim(274, 14) `0 == statvfs(cstring parts[1], stat)`  [AssertionDefect]

system

[user: /tmp] $ nim -v
Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2022-11-21
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f1519259f85cbdf2d5ff617c6a5534fcd2ff6942
active boot switches: -d:release

# Linux
# gcc version 12.2.0 (GCC)

Error during parsing

I get this response when running ttop:

error during parsing /proc/diskstats: procfs.nim(365, 16) `scanf(line, "$s$i $s$i $w $i $i $i $i $i $i $i $i $i $i", tmp, tmp, name, tmp,
      tmp, tmp, read, tmp, tmp, tmp, write, tmp, total)`
procfs.nim(124)          diskInfo

This is on Arch 6.2.7. Let me know if you need more info or if I can help.

Error on start [AssertionDefect]

I'm having some trouble getting it to run:

nimble

[user: /tmp] $ nimble install ttop
[user: /tmp] $ ttop
fatal.nim(54)            sysFatal
Error: unhandled exception: procfs.nim(274, 14) `0 == statvfs(cstring parts[1], stat)`  [AssertionDefect]

wget

[user: /tmp] $ wget https://github.com/inv2004/ttop/releases/latest/download/ttop
[user: /tmp] $ chmod +x ttop
[user: /tmp] $ ./ttop
fatal.nim(54)            sysFatal
Error: unhandled exception: procfs.nim(274, 14) `0 == statvfs(cstring parts[1], stat)`  [AssertionDefect]

nim

[user: /tmp] $ nim -v
Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2022-11-21
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: f1519259f85cbdf2d5ff617c6a5534fcd2ff6942
active boot switches: -d:release

System

Linux, Manjaro

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.