News for hackers. Stuff that matters.
Re:Ctop – commandline monitoring for containers by __jal on Thursday March 09, 2017 @04:52PM (#13834091)
Demonstrating once again that 99% of software development is reimplementation with another layer of indirection.

(Not that I'm complaining; this is a needed tool.)

Re:Ctop – commandline monitoring for containers by digi_owl on Thursday March 09, 2017 @05:53PM (#13834607)
And one that the world has basically been through once already. But the first time it happened in the insular world of corporate and university mainframes.
Re:Ctop – commandline monitoring for containers by amorphid on Thursday March 09, 2017 @09:05PM (#13835738)
When we start writing web browsers in WebAssembly, we shall have gone too far.
Re:Ctop – commandline monitoring for containers by colordrops on Thursday March 09, 2017 @11:13PM (#13836317)
WebAssembly is much better than JavaScript and XUL, which were/are both used to build browsers. Furthermore WebAssembly VMs are distinct entities from browsers.

I know you were joking, but the joke shows old biases that should just go away.

Re:Ctop – commandline monitoring for containers by ygjb on Friday March 10, 2017 @12:55AM (#13836694)
Given that webkit.js uses emscripten to build webkit for JS, and emscripten can target the wasm backend, ummm.. this is largely already done :)

Obligatory reference: https://www.youtube.com/watch?v=9nazm3_OXac

I think it is going to be very cool to see exactly how powerful and flexible this sort thing will become - how long til you demo a new tool by launching a linux container built on a webassembly vm that allows you to experiment with a new app with zero deploy effort.

Re:Ctop – commandline monitoring for containers by qznc on Friday March 10, 2017 @03:43AM (#13837214)
The effort is to visit a url.

An alternative possible today: `docker run -it rockstar:testbed newtool`

Even older, Java Web Start provided this in 2001.

Re:Ctop – commandline monitoring for containers by Spivak on Thursday March 09, 2017 @09:20PM (#13835808)
I mean sure it's weird given the history but would it actually be that weird? If WA just becomes another VM like the JVM or LLVM that people can target it wouldn't surprise me to see someone port a web browser.
Re:Ctop – commandline monitoring for containers by zodiac on Friday March 10, 2017 @02:17AM (#13836943)
Why? I could easily imagine a site you could go to to test if your own site works on IE6 or something, it would be useful for some people
Re:Ctop – commandline monitoring for containers by 0xdeadbeefbabe on Friday March 10, 2017 @11:25AM (#13839739)
Is there a network API for WebAssembly or a js API?
Re:Ctop – commandline monitoring for containers by amaranth on Thursday March 09, 2017 @04:28PM (#13833881)
Forget containers, where can I get a commandline monitoring tool this slick for regular processes? I feel like we skipped a step here.
Re:Ctop – commandline monitoring for containers by SwellJoe on Thursday March 09, 2017 @05:22PM (#13834387)
I'm oddly excited about command line tools lately. I've recently been porting all of our shell scripts to have color text output and Unicode status indicators (like a green checkmark for "OK" or red X for failure), when the terminal supports it (which, these days, is almost always). It just gives things a really polished feel that CLI tools don't always have.

I've used tools like dialog, in the past, but I've never really been a big fan; they seem like the worst of both worlds. It has the low-information density and high interaction requirements of a GUI, without actually looking really cool in the way a GUI can.

That's my long-winded way of saying, I also really like the way this looks, and I'm totally stealing some of the visual ideas here for my own tools.

Re:Ctop – commandline monitoring for containers by digi_owl on Thursday March 09, 2017 @06:02PM (#13834659)
As of late i find myself thinking that the big DEs have been a massive distraction from what made _nix so potent. While Windows and Mac had largely tried to hide or distance themselves from the CLI in favor of the GUI, the way X11 is implemented allows CLI programs to use GUI for enhancements rather than replacements.
Re:Ctop – commandline monitoring for containers by ygjb on Friday March 10, 2017 @01:04AM (#13836716)
Blending CLI and GUI is not unique to X11; at least since .net was released on Windows this has been very easy, and it's not even that hard if you want to do this from the Win32 API.

There are also a few windows "command line" applications when invoked with bad parameters will show MsgBox or Dialog boxes instead of writing errors to the console, which is super irritating when dealing with older versions of those tools in scripts.

That said, the bog standard windows command line environment is so awful that it makes doing anything useful with this blended UI less than ideal :/

Re:Ctop – commandline monitoring for containers by tutanchamun on Thursday March 09, 2017 @06:35PM (#13834909)
Yeah, from time to time I think that too when I browse /r/unixporn and see all the tiling window manager screens.
Re:Ctop – commandline monitoring for containers by drchickensalad on Thursday March 09, 2017 @07:21PM (#13835189)
How is that so?
Re:Ctop – commandline monitoring for containers by digi_owl on Thursday March 09, 2017 @08:50PM (#13835669)
https://feh.finalrewind.org/

That is a image viewer that can be operated from the command line but that then produce a GUI window (or windows) that can be manipulated by mouse and keyboard.

It has also various options for displaying image properties in the terminal.

Meaning that it could be leveraged along with existing _nix CLI tools to fine images in a large directory (or even directory tree) and then display the result, all by piping commands together.

Re:Ctop – commandline monitoring for containers by kasabali on Thursday March 09, 2017 @07:28PM (#13835239)
> I've recently been porting all of our shell scripts to have color text output and Unicode status indicators

I kinda have a similar intent of revamping user UI and user interaction of my personal scripts so I would appreciate some insights. Do you have any specific tips, helper functions or code snippets you can point me to? Do you just copy, paste and modify code snippets around when needed or have a clearly defined and reusable functions for printing, listing, displaying, prompting things etc.?

Re:Ctop – commandline monitoring for containers by SwellJoe on Thursday March 09, 2017 @08:37PM (#13835609)
I just published the colorized logging library I am using (it's a rewrite of log4bash to support POSIX shells): https://github.com/swelljoe/slog/

I also have a few other functions I'll be wrapping up into a utility function library, once I make them all work nicely across all of the shells I'd like to support.

I'm mostly working from functions I wrote years ago and haven't touched in the interim (except to make them work with POSIX/dash, when Ubuntu switched /bin/sh from bash for 6.06).

Re:Ctop – commandline monitoring for containers by kasabali on Friday March 10, 2017 @05:51AM (#13837698)
That's great, thanks! I'm keeping an eye on other functions, too.
Re:Ctop – commandline monitoring for containers by SwellJoe on Saturday March 11, 2017 @02:18PM (#13846712)
Just pushed out an asynchronous (cooperative, it requires the child process to touch a file to let the spinner know when to stop) Unicode and colorized progress spinner: https://github.com/swelljoe/spinner

I wouldn't call this one production ready yet. It needs to be in a function and needs to get its variables scoped and such. But, I was curious to see if a POSIX shell script could be coaxed into doing those super fun spinner designs with goofy shit like happy faces or peace signs or the like. And, it turns out you can. Long code points don't work, anywhere that I tried, yet...so my dream of a clock face with a moving hand is not yet possible. But, some day, it'll happen.

Re:Ctop – commandline monitoring for containers by arca_vorago on Thursday March 09, 2017 @09:45PM (#13835911)
Curious if you have tried nurses at all and what you thought? Also, any useful resources for colorizing etc? I'm the sysadmin who writes the bland scripts...
Re:Ctop – commandline monitoring for containers by SwellJoe on Thursday March 09, 2017 @11:37PM (#13836412)
I'm using tput from the ncurses package for setting colors in a terminal-aware way. You can do it with raw escape codes and most examples show it that way, but you can end up with different colors or non-functional colors on some operating systems (older macOS, among others). Using tput should smooth that out, assuming the terminal is reporting its capabilities and behavior correctly in termcap (as I understand it).

For example, I use the following to setup colors for printing log output to the display:

    readonly LOG_DEFAULT_COLOR=$(tput sgr0) # Clear colors
    readonly LOG_ERROR_COLOR=$(tput setaf 1) # Red
    readonly LOG_INFO_COLOR=$(tput sgr 0) # White
    readonly LOG_SUCCESS_COLOR=$(tput setaf 2) # Green
    readonly LOG_WARN_COLOR=$(tput setaf 3) # Yellow
    readonly LOG_DEBUG_COLOR=$(tput setaf 4) # Blue
Note that the colors are somewhat arbitrary based on the palette your terminal is using. Most palettes I've seen are kinda close to right, though green often looks olive/yellowish, and others are really washed out, in the current crop of popular palettes (like Solarized). But, it does provide color. I linked the logging library I've been using in another comment, which includes POSIX-compatible examples of using colors like this (tested on recent-ish dash, bash, zsh, and ksh).

As soon as I figure out how to reliably detect Unicode in a terminal in a POSIX compatible script, I'll publish some other utility functions that use Unicode.

The resources are pretty spread out. The tput manpage is utterly opaque, to me, as it covers a bunch of stuff that isn't relevant to "make it pretty" scripting. Mostly I've just been googling a lot. Unfortunately, the vast majority of examples on the web are for bash (also bash is easier to google for), so I'm having to trial-and-error my way to a POSIX compatible implementation.

I don't know of any way to use sh directly with ncurses itself, though there are programs like whiptail and dialog that'll harness some ncurses power for your scripts. I guess they're OK, but as I mentioned in another comment, I find dialog TUIs to be clunky. I don't want a windowing style GUI that happens to work in the CLI; I want a CLI that is traditional "run a command, get some output", but the "output" part just looks nicer, and is maybe animated in some way if it makes sense (a spinner or progress bar, e.g.).

Re:Ctop – commandline monitoring for containers by rsync on Thursday March 09, 2017 @10:45PM (#13836188)
"Curious if you have tried nurses at all and what you thought? "

Did you mean to say ncurses ? Or is there some new "nurses" thing that I don't know about ?

Re:Ctop – commandline monitoring for containers by arca_vorago on Friday March 10, 2017 @12:10AM (#13836548)
Oops, too late to edit now though.
Re:Ctop – commandline monitoring for containers by bogomipz on Thursday March 09, 2017 @07:42PM (#13835322)
>"I've recently been porting all of our shell scripts to have color text output and Unicode status indicators"

I am curious what is the upside of unicode vs plain ascii in this context?

Re:Ctop – commandline monitoring for containers by SwellJoe on Thursday March 09, 2017 @08:47PM (#13835652)
Just for fun. It makes me smile when I see stuff like that, so I'm gonna try to make my stuff more fun. My thinking is that as long as it falls back to something safe, it isn't hurting anyone.
Re:Ctop – commandline monitoring for containers by RussianCow on Thursday March 09, 2017 @07:59PM (#13835416)
Probably just access to more symbols as a substitute for proper iconography.
Re:Ctop – commandline monitoring for containers by bogomipz on Thursday March 09, 2017 @09:53PM (#13835949)
I see, makes sense. Thanks.
Re:Ctop – commandline monitoring for containers by dflock on Thursday March 09, 2017 @04:32PM (#13833915)
Re:Ctop – commandline monitoring for containers by amaranth on Thursday March 09, 2017 @05:25PM (#13834406)
htop is nice, sure, but not ctop levels of nice. Aside from the general pretty display and having network details ctop also has a really nice looking expanded view[1] that shows these over time with graphs.

[1] https://github.com/bcicen/ctop/blob/master/_docs/expanded.md

Re:Ctop – commandline monitoring for containers by digi_owl on Thursday March 09, 2017 @05:58PM (#13834633)
Dunno about pr process, but i could have sworn that graphs where a option in htop.

http://hisham.hm/htop/index.php?page=screenshots

Some of them show both 1.0 graphs and the new, unicode based ones from 2.0.

Re:Ctop – commandline monitoring for containers by Normal_gaussian on Thursday March 09, 2017 @06:17PM (#13834767)
Graphs are an option. Press F2, move to the entry you want and toggle it between Bar, Graph, Text, and LED.

However they are still not per process. And there are no network statistics.

Re:Ctop – commandline monitoring for containers by ymt123 on Thursday March 09, 2017 @06:25PM (#13834834)
Re:Ctop – commandline monitoring for containers by searchfaster on Thursday March 09, 2017 @07:16PM (#13835158)
Thank you ! Glances seems to be a good netdata + htop replacement
Re:Ctop – commandline monitoring for containers by blockloop on Friday March 10, 2017 @12:09AM (#13836545)
Glances also shows docker containers like this.
Re:Ctop – commandline monitoring for containers by gioele on Friday March 10, 2017 @02:03AM (#13836896)
A more UNIXy question is: why isn't there a generic tool that do nice and slick TUIs (textual user interfaces) so that htop, ntop, iotop, ctop and so on can all be implemented on top of it?
Re:Ctop – commandline monitoring for containers by Nelkins on Friday March 10, 2017 @05:12AM (#13837554)
I have seen some things like this before. For example, in .NET there is Console Framework[1] which allows you to define TUIs in XAML or code.

[1] https://github.com/elw00d/consoleframework

Re:Ctop – commandline monitoring for containers by sophacles on Friday March 10, 2017 @10:57AM (#13839529)
Re:Ctop – commandline monitoring for containers by mrmondo on Thursday March 09, 2017 @11:37PM (#13836414)
Re:Ctop – commandline monitoring for containers by amckinlay on Thursday March 09, 2017 @06:26PM (#13834846)
I wish when I quit top it didn't leave its interface in console scrollback.
Re:Ctop – commandline monitoring for containers by reader_1000 on Friday March 10, 2017 @11:32AM (#13839811)
atop - http://www.atoptool.nl/ Atop is a good command line monitoring tool. It also keeps historical data.
Re:Ctop – commandline monitoring for containers by chrisper on Thursday March 09, 2017 @05:11PM (#13834281)
nmon is nice too
Re:Ctop – commandline monitoring for containers by gkfasdfasdf on Thursday March 09, 2017 @04:45PM (#13834033)
Very cool...also, you can run on Docker For Windows using Docker itself:

  C:\ctop> type Dockerfile
  from buildpack-deps:jessie
  run curl -fsSL https://github.com/bcicen/ctop/releases/download/v0.4/ctop-0.4-linux-amd64 -o ctop && chmod +x ctop
  cmd ./ctop
  C:\ctop> docker build -t ctop .
  C:\ctop> docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock ctop
Re:Ctop – commandline monitoring for containers by playa1 on Thursday March 09, 2017 @07:06PM (#13835085)
This looks amazing!

Too bad that the name collides with the Ubuntu package ctop which installs https://github.com/yadutaf/ctop

Re:Ctop – commandline monitoring for containers by nicolaslem on Friday March 10, 2017 @03:42AM (#13837209)
When I saw this post I was sure it was about yadutaf's project. The name collision is indeed unfortunate since the two projects basically do the same thing.
Re:Ctop – commandline monitoring for containers by drakenot on Thursday March 09, 2017 @09:43PM (#13835902)
Yea, I just ran into this by mistakenly attempting to 'apt-get install ctop'.
Re:Ctop – commandline monitoring for containers by brunoqc on Thursday March 09, 2017 @04:26PM (#13833859)
Isn't it recommended to not make Docker listen on the TCP port?
Re:Ctop – commandline monitoring for containers by raesene9 on Thursday March 09, 2017 @05:16PM (#13834326)
From reading the docs, it looks like ctop will connect to the local UNIX socket if there's no environment variable specifying a host, so you don't need to expose a TCP port to get this working.
Re:Ctop – commandline monitoring for containers by andrewguenther on Thursday March 09, 2017 @04:51PM (#13834086)
You should always use a UNIX socket if you don't need remote access.
Re:Ctop – commandline monitoring for containers by noinsight on Thursday March 09, 2017 @07:28PM (#13835235)
SSH supports forwarding UNIX sockets...
Re:Ctop – commandline monitoring for containers by andrewguenther on Tuesday March 14, 2017 @01:30AM (#13865254)
Would not recommend
Re:Ctop – commandline monitoring for containers by zenlikethat on Thursday March 09, 2017 @07:02PM (#13835064)
Yes. Otherwise any process which can access the TCP port has full root access on the computer where Docker is installed. And root access to the entire Docker swarm cluster if swarm mode is enabled and the current node is acting as a manager.

Whether or not giving root access to a system performance tool is wise is left as an exercise to the reader.

Re:Ctop – commandline monitoring for containers by dominotw on Thursday March 09, 2017 @04:31PM (#13833907)
even if protected by tls?
Re:Ctop – commandline monitoring for containers by zenlikethat on Thursday March 09, 2017 @07:00PM (#13835057)
Not sure why you're getting down-voted, exposing the Docker API over a TCP socket using TLS is the only way to even hope to do it safely.
Re:Ctop – commandline monitoring for containers by andrewguenther on Friday March 10, 2017 @02:53PM (#13841532)
Not exposing it over TCP at all is the only way to do it safely...
Re:Ctop – commandline monitoring for containers by voldezar on Friday March 10, 2017 @01:08AM (#13836733)
You can get same output with: docker stats $(docker ps --format={{.Names}})
Re:Ctop – commandline monitoring for containers by vzaliva on Thursday March 09, 2017 @06:02PM (#13834654)
Looks cool. I am trying to avoid manually installing software, especially on production machines. It makes it difficult to maintain and upgrade. Any plans for `apt` package?
Re:Ctop – commandline monitoring for containers by nerdponx on Thursday March 09, 2017 @06:08PM (#13834707)
To be fair, it's a single binary. Couldn't you just "install" it in ~/bin?
Re:Ctop – commandline monitoring for containers by djsumdog on Thursday March 09, 2017 @08:29PM (#13835572)
I tried `go get -u github.com/bcicen/ctop` since I prefer uses the source, but there appear to be some syntax errors in master. Guess I could have added the tag, but I just used the binary.

You should check if `fpm` has support for making packages for go projects (It should. It supports Python and Ruby). Then it should be simply to create packages, sign them and put them on your company repo.

I've worked at shops where we do this and even run update scripts to tell us when new versions are available and kick of the fpm build process.

Re:Ctop – commandline monitoring for containers by icebraining on Friday March 10, 2017 @04:01AM (#13837291)
fpm can package anything, you can literally throw any old directory at it and get a .deb or .rpm out.
Re:Ctop – commandline monitoring for containers by moondev on Thursday March 09, 2017 @04:24PM (#13833835)
So awesome. Would be nice to hook this in to k8s in some way. I guess you could mount the socket and run it in a pod
Re:Ctop – commandline monitoring for containers by lirantal on Saturday March 11, 2017 @04:33AM (#13844907)
Really cool. I also wrote a similar tool - Dockly, which provides a more complete management of docker containers through the CLI.

https://github.com/lirantal/dockly

Re:Ctop – commandline monitoring for containers by israrkhan on Thursday March 09, 2017 @07:23PM (#13835200)
"docker stats" give you same information, although I have to admit this one has better ui.
Re:Ctop – commandline monitoring for containers by djsumdog on Thursday March 09, 2017 @08:31PM (#13835579)
TIL about docker stats. Hmm... it gives you the container hash instead of the name. Yea I agree, cgit is a much better interface.
Re:Ctop – commandline monitoring for containers by theta_d on Friday March 10, 2017 @09:39AM (#13838870)
docker stats $(docker ps --format={{.Names}})
Re:Ctop – commandline monitoring for containers by nicwolff on Friday March 10, 2017 @11:57AM (#13839971)
You may have missed that you can ↓ to any container and ␍ to see a detailed perf graph https://github.com/bcicen/ctop/blob/master/_docs/expanded.md
Re:Ctop – commandline monitoring for containers by zurn on Friday March 10, 2017 @10:06AM (#13839085)
Re:Ctop – commandline monitoring for containers by broodbucket on Thursday March 09, 2017 @06:22PM (#13834808)
Is there an equivalent for VMs that uses libvirt or something?
Re:Ctop – commandline monitoring for containers by ah- on Friday March 10, 2017 @03:12AM (#13837111)
Please someone port this to Kubernetes.
Re:Ctop – commandline monitoring for containers by vektorlab on Wednesday March 15, 2017 @02:10AM (#13874149)
No port necessary, an interface for connecting other container/cluster systems is already defined. Feel free to open a feature request (https://github.com/bcicen/ctop/issues) for k8s to included as a connector in future releases.
Re:Ctop – commandline monitoring for containers by vladsanchez on Thursday March 09, 2017 @04:22PM (#13833811)
Much needed tool. Instant Love! Thanks.
Re:Ctop – commandline monitoring for containers by thejosh on Thursday March 09, 2017 @04:32PM (#13833920)
kind of like sysdig.
Re:Ctop – commandline monitoring for containers by williamstein on Thursday March 09, 2017 @04:13PM (#13833707)
very cool!!