Skip to content

Commit

Permalink
feat: add hatop
Browse files Browse the repository at this point in the history
hatop: interactive ncurses client for haproxy

Log: add hatop
Issue:
deepin-community/sig-deepin-sysdev-team#376
  • Loading branch information
liushanyang12138 committed Jul 12, 2023
1 parent 6b83c18 commit eda0644
Show file tree
Hide file tree
Showing 61 changed files with 5,024 additions and 37 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scripts/tmp/*
scripts/deb_custom_control
*.py[co]
*.swp
*.tmp
*.~
.DS_Store
144 changes: 144 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
*********
Changelog
*********

This is a brief overview of the changes introduced by each version.


HATop 0.8
=========

HATop is now compatible with Python 3.

James Hunt has officially taken over maintainership of this project.
Work will continue on GitHub at https://github.com/jhunt/hatop.


HATop 0.8.2
-----------

:Date: May 21, 2022

- Bugfix: in CLI mode, pressing the down arrow no longer crashes Python 2.x


HATop 0.8.1
-----------

:Date: Apr 14, 2021

- Feature: F1/F2 hot keys now affect ALL backends

- Feature: New F9/F10 hot keys implement legacy F1/F2 behavior


HATop 0.8.0
-----------

:Date: Jul 30, 2020

- Feature: Support for Python3

- Feature: Bump max services from 100 -> 1000

- Feature: Support for connecting to HAProxy via a TCP socket.
(Andrew Hayworth)


HATop 0.7
=========

This is the first public series after reaching a feature complete state.


HATop 0.7.7
-----------

:Date: Oct 05, 2010

- Feature: Display hotkey footer when pressing ENTER on selected service.

- Feature: Use string identifier ("pxname/svname") instead of numerical
identifier ("#iid/#sid") for hotkey actions.

- Bugfix: Display cursor and focus input if started in CLI mode.

- Bugfix: Reload stat data if number of proxies or services has changed.

- Bugfix: Prevent infinite size sync if screen size is larger than supported.
(Jérémy Bonnet)

- Docs: Add notes to INSTALL for the man page. (James Briggs)

- Docs: Fix hatop(1) man page and document the new hotkey footer.


HATop 0.7.6
-----------

:Date: Aug 20, 2010

- Bugfix: Support terminals lacking different cursor visibilities.
(Matt Behrens)

- Bugfix: Handle empty or incomplete info and stat data.

- Bugfix: Handle unknown proxy names with the -p / --proxy filter options.

- Docs: Add initial hatop(1) man page


HATop 0.7.5
-----------

:Date: Aug 18, 2010

- Bugfix: Pressing ENTER on the embedded CLI could result in display
corruption. (Cyril Bonté)

- Docs: Add common packaging files CHANGES and INSTALL

- Docs: Add keybind reference in KEYBINDS


HATop 0.7.4
-----------

:Date: Aug 16, 2010

- Bugfix: Fix the expected stat CSV format. (Jim Riggs)


HATop 0.7.3
-----------

:Date: Aug 16, 2010

- Bugfix: Restore compatibility with Python 2.4 and 2.5.


HATop 0.7.2
-----------

:Date: Aug 16, 2010

- Bugfix: Handle socket connections to incompatible HAProxy versions.


HATop 0.7.1
-----------

:Date: Aug 16, 2010

- Bugfix: Prevent timeout changes to the internal interactive session used to
query for stats.


HATop 0.7.0
-----------

:Date: Aug 15, 2010

- The first public and feature complete version.

.. vim: tw=78
88 changes: 88 additions & 0 deletions HACKING
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright (C) 2011 John Feuerstein <[email protected]>
# HATop hacking...

Development: https://github.com/jhunt/hatop

Git: git clone https://github.com/jhunt/hatop.git



*** Screen coordinates:

xmin (0) xmax (>=78)
| |
| | stat
ymin ----+------------------ header ---------------------| idx
(0) | |
| | 0
| info display | [..]
| | 42
| | 43
hpos ----|------------------ columns --------------------| 44
| | 45
= smin ====|= 0.- cmin ===================================|==== 46 = vmin
^ | 1 \ | 47
| | 2 | | 48
| | 3 | | 49
| | 4 |-> screen lines | 50
|-> span | 5 | | 51
| | 6 | | 52
| | 7 | stat display | 53
| | 8 | | 54
| | 9 | | 55
| | 10 | | 56
| cpos ----|- 11 | ------------ cursor --------------------|---- 57 - vpos
| | 12 | | 58
| | 13 | | 59
| | 14 | | 60
| | 15 / | 61
= smax ====|= 16'- cmax ===================================|==== 62 - vmax
| | 63
ymax ----+------------------- footer --------------------' [..]
(>=20)


Smin/max = Screen position
Cmin/max/pos = Curser position
Vmin/max/pos = Virtual position


Dynamic positions:

smin = hpos + 2
smax = ymax - 2
cmax = smax - smin (or last stat slice from vmin to end of list)
vpos = vmin + cpos
vmax = vmin + cmax
span = smax - smin

- stat lines represent the whole set of parsed service stats
- screen lines represent a subset of stat lines which are on screen



*** ScreenCLI INPUT coordinates:

screen.xmin screen.xmax
. .
. .
| |
| |
| |<---------------- ispan ------------------>| |
| | | |
|imin ipos imax|
| | | | |
| [*****************|*************************]-----> input line
| | | | | (at screen.smax)
+-|-----------------|-------------------------|-+
| | |
[..., ..., .|., ..., ..., ...,|..., ..., ..., ..., ..., |.., ..., ...] ibuf
| | | | |
| ibmin ibpos ibmax |
| |
|<--------------------------- iblen -------------------------------->|


Imin/max/pos = Input position (*on screen*)
IBmin/pos/max = Input buffer position

48 changes: 48 additions & 0 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
************
Installation
************

HATop is written as a single executable python script file called ``hatop``.

This allows easy distribution and installation.

:Package maintainers:

Please use "hatop" for the final package and executable name.

This allows users on different platforms to find it easily.


Requirements
============

**HATop is written in pure Python and has no external dependencies!**

* `Python 2.4 <http://python.org/>`_ or later (no Python 3 support planned yet)
* `HAProxy 1.4 <http://haproxy.1wt.eu/>`_ or later


Installation
============

The installation is simple::

$ install -m 755 bin/hatop /usr/local/bin

$ install -m 644 man/hatop.1 /usr/local/share/man/man1
$ gzip /usr/local/share/man/man1/hatop.1


Permissions
===========

HATop itself can be used by any system user.

The permission to connect to a given HAProxy instance is controlled
by the file permission of the unix socket file.

HATop needs ``read`` and ``write`` access (``chmod +rw``) on the socket file.

The initial socket file permissions can be configured in haproxy.conf using
the ``user``, ``group`` and ``mode`` parameters of the ``stats socket`` option.

60 changes: 60 additions & 0 deletions KEYBINDS
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
*****************
Keybind Reference
*****************

Global keybinds
===============
::

Key Action

Hh? Display this help screen
CTRL-C / Qq Quit

TAB Cycle mode forwards
SHIFT-TAB Cycle mode backwards
ALT-n / ESC-n Switch to mode n, where n is the numeric mode id
ESC-ESC Jump to previous mode

ENTER Display hotkey menu for selected service
SPACE Copy and paste selected service identifier to the CLI

You can scroll the stat views using UP / DOWN / PGUP / PGDOWN / HOME / END.


Hotkeys for common administrative actions
=========================================
::

Hotkey Action

F4 Restore initial server weight

F5 Decrease server weight: - 10
F6 Decrease server weight: - 1
F7 Increase server weight: + 1
F8 Increase server weight: + 10

F9 Enable server (return from maintenance mode)
F10 Disable server (put into maintenance mode)

Hotkey actions and server responses are logged on the CLI viewport.


Keybinds for the command line interface
=======================================
::

Key Action

ALT-n / ESC-n escape the shell and display given viewport

ENTER execute cmdline or display marker if input empty

UP / DOWN scroll input history up or down
LEFT / RIGHT move input cursor one character to the left or right
HOME / END move input cursor to the beginning or end of line
BACKSPACE / DEL delete one character backwards or forwards

PGUP / PGDOWN scroll output history up or down

Loading

0 comments on commit eda0644

Please sign in to comment.