sqshq / sampler

Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.
https://sampler.dev
GNU General Public License v3.0
12.59k stars 549 forks source link

Macos ssh pty error #114

Open celestial-30 opened 2 years ago

celestial-30 commented 2 years ago

Running sampler on darwin. Installed via homebrew.

Attempting to include a box that connects to local server via ssh. Copied config from github page as follows.

textboxes:
  - title: SSH
    pty: true
    init: ssh -i ~/.ssh/id_rsa username@server.local
    sample: top

With the server address replaced with the appropriate username and address.

This returns the error:

┌──────────────────────────────────────────────────────────────────┐     │
│     │                         SAMPLING FAILURE                         │     │
│     │    fork/exec /bin/sh: Setctty set but Ctty not valid in child    │     │
│     └──────────────────────────────────────────────────────────────────┘panic: runtime error: invalid memory address or nil pointer dereference              │
[signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x102505a98]     │
│                                                                              │
goroutine 37 [running]:                                                        │
io.WriteString(0x0, 0x0, 0x140001c4098, 0x5, 0x0, 0x140001c4098, 0x5)──────────┘
    /opt/homebrew/Cellar/go/1.15.6/libexec/src/io/io.go:311 +0xa8
github.com/sqshq/sampler/data.(*PtyInteractiveShell).execute(0x140001dc190, 0x0, 0x0, 0x0, 0x0)
    /private/tmp/sampler-20201225-38055-jays8r/sampler-1.1.0/data/int_pty.go:70 +0xdc
github.com/sqshq/sampler/data.(*Item).nextValue(0x14000192080, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)config.ymlet alerts   (<->) selection   (p) pause   (q) quit
    /private/tmp/sampler-20201225-38055-jays8r/sampler-1.1.0/data/item.go:57 +0x58
github.com/sqshq/sampler/data.(*Sampler).sample(0x140000bc7e0, 0x14000192080, 0x140000a0720, 0x0, 0x0, 0x0, 0x0)
    /private/tmp/sampler-20201225-38055-jays8r/sampler-1.1.0/data/sampler.go:59 +0x44
created by github.com/sqshq/sampler/data.NewSampler.func1
    /private/tmp/sampler-20201225-38055-jays8r/sampler-1.1.0/data/sampler.go:35 +0x78

My terminal also does not accept scrolling or clicking after this error, instead writing the codes for those actions to the prompt. This continues until I reload or switch my shell.

This error does not occur if i remove pty: true, however, if i do so it instead brings up the wake text of the server.

I believe this is caused by some issue with the pseudoterminal, But I am not experienced enough on that subject to provide any more meaningful analysis. If you need any more information please let me know.

celestial-30 commented 2 years ago

I do not know if sampler produces logs, if it does, does anyone know where to find them?

EsEnZeT commented 2 years ago

I confirm having exact same issue.

oversize commented 2 years ago

I can also confirm this exact error. Installed via brew and tried to run the ssh example..

gregfr commented 2 years ago

I've having the same issue, but on Ubuntu (however also installed with Brew). The term is messed up until I type "reset".

zliebersbach commented 1 year ago

Same bug here! Would love this for monitoring my dev environment but sadly is unusable without PTY feature for me.

sikmir commented 11 months ago

I have the same problem on macos and linux(

bebsworthy commented 9 months ago

Proposed fix here: https://github.com/sqshq/sampler/pull/134. The issue seems to have been fixed in creak/pty but sampler is using an older fork kr/pty. The pr change the dependency to the upstream project creak/pty. It solves the issue for me.

sikmir commented 8 months ago

Proposed fix here: #134. The issue seems to have been fixed in creak/pty but sampler is using an older fork kr/pty. The pr change the dependency to the upstream project creak/pty. It solves the issue for me.

It works for me!