Skip to content

Commit

Permalink
Update to version v1.3.0! (#111)
Browse files Browse the repository at this point in the history
* Update install instructions in README

* Add binary compile script

* Moved compile script to scripts directory

* Add license to compile.sh

* add bin/ to gitignore

* Optimize struct memory usage

* reorder struct fields

* Updated config.yml

* Updated config.yml

* remove field align check from CI

* add check existence of fieldalignment command

* Update README.md

* remove xml mention from README

* Tidied go.mod

* Add apt update to ci scripts

* Add Container metric functionality (#102)

* Add overall metrics collection

* Replace net and blk slices with structs

* Init UI for containers

* Replace tick with NewTicker

* Add help page for overallContainer

* Format container UI

* Modify container about

* Add container table fit and resize

* Removed redundant helper

* Resize list content according to table widths

* Auto Resize Disk chart

* Replace tick with NewTicker and fix container table alignment issues

* Add License

* Remove empty file

* Missing license fix

* Add auto resize for cpu info table

* Add basic UI for per container metrics

* Fix per cpu value error

* Add table scroll functionality for per container UI

* Remove invalid test file

* Fix dot imports, use of "self" and ineffective break

* Cleanup container metrics and document code

* Migrate overallcontainer list to table and add cursor colours

* Add error art functionality for containers

* Add checks for empty precpu metrics

* Replace one shot container stats fetch

* Handle docker not running error

* Add docker alias for `grofer container`

* Add host ip in port map list

* Add getCPUPercent functions and tests for funcs

* Add missing license

* Replace cpu percent calculation with new func in overall.go

* Add test for RoundValues with inBytes

* Add details for exported container metrics structs

* Minor comments added to explain TickUntilDone

* Fix incorrect timestamps (#105)

* Fix incorrect timestamps

* Update tests

* A bunch of refactors (#103)

* Add table to grofer proc

* Re Add proc kill functionality

* Add table for per proc child procs

* Add % symbol to cpuinfo

* Add cleaner network graph and remove nettext chart

* Tidy go mod

* Add missing license and ctx.Done() to UI

* Update README

* Add CPU table for overall when numCores > 8

* Add CPU table for --cpuinfo when numCores > 8

* Add extra tests to CI

* Removed unused NetTable widget

* Sort procs on Timestamp

* Update src/utils/lineGraph.go

Co-authored-by: Madhav Jivrajani <madhav.jiv@gmail.com>

* Readme and CI config update

* Add credit and cocument exported function

* Remove -race from CI tests

* Remove default sort

Co-authored-by: Madhav Jivrajani <madhav.jiv@gmail.com>

* Add Sort functionality to overall process and container tables (#109)

* Add sort functionality to all procs

* Restructure switch cases

* Add  sort for container table

* Update keybindings for sort

* Explain kill confirmation in keybindings

* Restructure sorts

* Minor comment changes to sort.go

* Add tests for sortData

* Add missing license to test file

* Add Container Actions! (#110)

* Add container pause action

* Add global cli, cliMutex and container restart action

* Remove cliMutex, add check for mem 0/0 error and container stop functionality

* Add `--all` flag for `grofer container`

* Add container kill and remove actions

* add error screen for container

* Add containerWait

* Add cursor selectin colour after error

* Update help keybindings

* Add leybindings, recover() to utils wrapper and close chans

* Add --all flag for refresh after container action

* use ct.Done as stop chan

* Add comment for ContainerWait()

* Add stats.Body.Close() and removed close of chan on receiver

Co-authored-by: Madhav Jivrajani <madhav.jiv@gmail.com>

* Add missing ctx.Done() for serve data functions

Co-authored-by: Madhav Jivrajani <madhav.jiv@gmail.com>
Co-authored-by: Sparsh Temani <sparshtemani31415@gmail.com>
  • Loading branch information
3 people committed May 12, 2021
1 parent c730b28 commit b48a37c
Show file tree
Hide file tree
Showing 50 changed files with 4,063 additions and 578 deletions.
6 changes: 2 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
Expand All @@ -16,6 +13,7 @@ jobs:
- run: go get -v
- run: bash ./scripts/fmt.sh
- run: bash ./scripts/build.sh
- run: sudo apt update
- run: sudo apt install python3 -y
- run: python3 ./scripts/license_check.py
- run: go test -v -race $(go list ./src/utils | grep -v vendor)
- run: go test ./...
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ bin
grofer
main
grofer_profile
bin/
Vagrantfile
*.log
.vagrant
255 changes: 184 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ A clean and modern system and resource monitor written purely in golang using [t

Currently compatible with Linux only.

Currently compatible with Linux only.

Installation
------------
============

Using go get:

Expand All @@ -21,7 +19,7 @@ go get -u github.com/pesos/grofer
As an executable:

```
curl -sSL https://github.com/pesos/grofer/releases/download/<version tag>/grofer --output grofer
curl -sSL https://github.com/pesos/grofer/releases/download/<version tag>/grofer_<architecture> --output grofer
chmod +x grofer
```
`architecture`: underlying system architecture on which grofer will be run
Expand All @@ -30,6 +28,12 @@ chmod +x grofer
- grofer_arm
- grofer_arm64

`architecture`: underlying system architecture on which grofer will be run
- grofer_386
- grofer_amd64
- grofer_arm
- grofer_arm64

For system wide usage, install `grofer` to a location on `$PATH`, e.g. `/usr/local/bin`

```
Expand All @@ -46,90 +50,116 @@ go build grofer.go

---

Shell Completions
-----------------

`grofer` includes a subcommand to generate shell completion scripts to get autocompletion for subcommands and flags
Usage
=====

### Bash
```
grofer is a system and resource monitor written in golang.
To get completions for current session only,
While using a TUI based command, press ? to get information about key bindings (if any) for that command.
```sh
source <(grofer completion bash)
```
Usage:
grofer [flags]
grofer [command]
To load completions for each session, the generated script must be moved to the completions directory. Take a look at the third question [here](https://github.com/scop/bash-completion/blob/master/README.md#faq) to find out the right place to put the script
Available Commands:
about about is a command that gives information about the project in a cute way
completion Generate completion script
container container command is used to get information related to docker containers
export Used to export profiled data.
help Help about any command
proc proc command is used to get per-process information
### Zsh
Flags:
--config string config file (default is $HOME/.grofer.yaml)
-c, --cpuinfo Info about the CPU Load over all CPUs
-h, --help help for grofer
-r, --refresh uint Overall stats UI refreshes rate in milliseconds greater than 1000 (default 1000)
If shell completion is not already enabled in your environment you will need to enable it. You can execute the following once:
Use "grofer [command] --help" for more information about a command.
```sh
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

To load completions for each session, the generated script must be placed in a directory in your [fpath](http://zsh.sourceforge.net/Doc/Release/Functions.html). For a quick-and-dirty solution, run once:
Display Overall Metrics
-----------------------

```sh
grofer completion zsh > "${fpath[1]}/_grofer"
grofer [FLAGS]
```

You will need to start a new shell for this setup to take effect.
The command displays the default root page which provides verall CPU, Memory, Network and Disk Metrics.

### Fish
Optional flags:

To get completions for current session only,
- `-c | --cpuinfo`: Enabling this flag provides detailed information about CPU loads.

- `-h | --help`: Provides help information about grofer.

- `-r | --refresh UINT`: Sets the UI refresh rate in milliseconds. The number (UINT) provided must be greater than 1000

Display Process Metrics
-----------------------

```sh
grofer completion fish | source
grofer proc [FLAGS]
```

To load completions for each session, the generated script must be moved to the completions directory
This command displays a table with information about all running processes. Additionally, it can be used to kill a running process too. Key-bindings for navigation and available process actions can be found by pressing `?` in the UI.

Optional flags:

- `-h | --help`: Provides help details for `grofer proc`.

- `-p | --pid INT32`: Provides in depth metrics about process identified by given PID.

- `-r | --refresh UINT`: Sets the UI refresh rate in milliseconds. Much like the root command, this value must be greater than 1000.

Display Container Metrics
-------------------------

```sh
grofer completion fish > ~/.config/fish/completions/grofer.fish
grofer container [FLAGS]
```

Usage
-----
This command displays information about all existing containers. Key-bindings for navigation and available container actions can be found by pressing `?` in the UI.

Optional flags:

- `-h | --help`: Provides help details for `grofer container`.

- `-c | --container-id STRING`: Provides in depth metrics about the container identified by given ID.

- `-r | --refresh UINT`: Sets the UI refresh rate in milliseconds. Much like the root command, this value must be greater than 1000.

Export Metrics
--------------

```sh
grofer export [FLAGS]
```
grofer is a system and resource monitor written in golang.

While using a TUI based command, press ? to get information about key bindings (if any) for that command.
This command exports collected information to a specifc file format.

Usage:
grofer [flags]
grofer [command]
Optional flags:

Available Commands:
about about is a command that gives information about the project in a cute way
completion Generate completion script
export Used to export profiled data.
help Help about any command
proc proc command is used to get per-process information
- `-h | --help`: Provides help details for `grofer export`.

Flags:
--config string config file (default is $HOME/.grofer.yaml)
-c, --cpuinfo Info about the CPU Load over all CPUs
-h, --help help for grofer
-r, --refresh uint Overall stats UI refreshes rate in milliseconds greater than 1000 (default 1000)
-t, --toggle Help message for toggle
- `-i | --iter UINT32`: Set the number of iterations to fetch data.

Use "grofer [command] --help" for more information about a command.
- `-p | --pid INT32`: Specify the PID of the process to profile. If not set, all processes are are measured.

```
- `-t | --type STRING`: Specify the export file format. Defaults to LJSON.

---
- `-f | --filename STRING`: Specify the file to store the exported data in. Defaults to `grofer_profile`.

Examples
--------
- `-r | --refresh UINT`: Specify frequency of data fetch in milliseconds. default value taken as 1000.

`grofer [-r refreshRate] [-c]`
------------------------------
Examples
========

This gives overall utilization stats refreshed every `refreshRate` milliseconds. Default and minimum value of the refresh rate is `1000 ms`.
```
grofer
```

![grofer](images/README/grofer.png)

Expand All @@ -139,6 +169,12 @@ Information provided:
- Network usage
- Disk storage

---

```
grofer --cpuinfo
```

The `-c, --cpuinfo` flag displays finer details about the CPU load such as percentage of the time spent servicing software interrupts, hardware interrupts, etc.

![grofer-cpu](images/README/cpuload.png)
Expand All @@ -150,25 +186,24 @@ Information provided:
- Idle : % of time CPU was idle.
- Nice : % of time spent by CPU executing user level processes with a nice priority.
- Iowait: % of time spent by CPU waiting for an outstanding disk I/O.
- Soft : % of time spent by the CPU servicing software interrupts.
- Steal : % of time spent in involuntary waiting by logical CPUs.
- Soft : % of time spent by the CPU servicing software interrupts.
- Steal : % of time spent in involuntary waiting by logical CPUs.

---

`grofer proc [-p PID] [-r refreshRate]`
---------------------------------------

If the `-r` flag is specified then the UI will refresh and display new information every `refreshRate` milliseconds. The minimum and default value for `refreshRate` is `1000 ms`.

### `grofer proc`
```
grofer proc
```

This lists all running processes and relevant information.

![grofer-proc](images/README/grofer-proc.png)

---

### `grofer proc -p PID`
```
grofer proc -p PID
```

This gives information specific to a process, specified by a valid PID.

Expand All @@ -188,20 +223,98 @@ Information provided:

- Memory usage (RSS, Data, Stack, Swap)

### `grofer export [-i Iterations] [-f File] [-r refreshRate] [-t type] [-p PID]`
---

```
grofer container
```

This provides overall container metrics.

This allows exporting of profiled data either of system usage or data particular to that of a process. Data format is JSON by default, but XML support exists too!
![grofer-container](Images/../images/README/grofer-container.png)

The flags are explained as follows:
---

- `-i, --iter`: Number of iterations to profile for.
```
grofer container -c CID
```

- `-f, --filename`: Name of output file (exported data).
This provides per container metrics.

- `-r, --refresh`: Refresh rate, time interval between iterations (in milliseconds).
![grofer-container-cid](Images/../images/README/grofer-container-cid.png)

- `-t, --type`: Specify the output data format (JSON by default). Types supported are:
Information provided:

- JSON: Specifically, LJSON, where each line consists of one JSON object which contain nested fields and values.
- CPU and Per CPU utilization %

- `-p, --pid`: Specify PID of process to profile.
- Memory utilization %

- Container processes

- Volume Mounts

- Attached Networks

- Block and Network I/O

- Metadata (Image, Name, ID, Status, State, PID)

---

```
grofer export -i 1 -p 1
```

This allows exporting of profiled data either of system usage or data particular to that of a process. Data format is JSON by default.

![grofer-export](images/README/grofer-export.png)

---

Shell Completions
=================

`grofer` includes a subcommand to generate shell completion scripts to get autocompletion for subcommands and flags

Bash
----

To get completions for current session only,

```sh
source <(grofer completion bash)
```

To load completions for each session, the generated script must be moved to the completions directory. Take a look at the third question [here](https://github.com/scop/bash-completion/blob/master/README.md#faq) to find out the right place to put the script

Zsh
---

If shell completion is not already enabled in your environment you will need to enable it. You can execute the following once:

```sh
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

To load completions for each session, the generated script must be placed in a directory in your [fpath](http://zsh.sourceforge.net/Doc/Release/Functions.html). For a quick-and-dirty solution, run once:

```sh
grofer completion zsh > "${fpath[1]}/_grofer"
```

You will need to start a new shell for this setup to take effect.

Fish
----

To get completions for current session only,

```sh
grofer completion fish | source
```

To load completions for each session, the generated script must be moved to the completions directory

```sh
grofer completion fish > ~/.config/fish/completions/grofer.fish
```
3 changes: 2 additions & 1 deletion cmd/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ var aboutCmd = &cobra.Command{
"Made with [♥](fg:red) by [PES Open Source](fg:green)\n\n"

uiEvents := ui.PollEvents()
tick := time.Tick(100 * time.Millisecond)
t := time.NewTicker(100 * time.Millisecond)
tick := t.C

for {
select {
Expand Down
Loading

0 comments on commit b48a37c

Please sign in to comment.