HN user

lebinh

186 karma

I build new things and fix broken old things. https://github.com/lebinh

[ my public key: https://keybase.io/lebinh; my proof: https://keybase.io/lebinh/sigs/9B2jNoHnF4zRcb06uYKQe76vBRPTfiCzx4iM3rnVHCQ ]

Posts5
Comments16
View on HN

I showed ngxtop [0] about 2 years ago as a top inspired tool to quickly check the status of my nginx servers, something I created for my need. I expected some people would find it useful and shared, turned out a lot of people need something to monitor their nginx servers and it got 3k stars in a day or two. So I built a much better tool to help monitor nginx and sell it as a product, Luameter [1]. It didn't take off like the other but now making a couple hundreds a month and being used by some high-profile users, i.e. well-known companies.

[0] https://github.com/lebinh/ngxtop [1] https://luameter.com/

Measure and profile the code will always be the best thing to do but for simple 20% effort tips I think it would be:

* Don't write your own data structure, stick to the standard library or, in some rare cases, popular and well-known 3-rd party lib.

* Always prefer a Hash or a Set over anything else.

* Beware of any nested loops.

* Have some local / external caches and try memoization.

* Try parallelizing or better, non-blocking wait for all I/O operations.

Hi, I'm the author of this.

About a year ago I open sourced a tool for quick monitoring and troubleshooting Nginx, ngxtop [1], and received some very positive interests from HN community. However quite a few people are using it as a monitoring solution for their Nginx server, which is not ideal. Ngxtop was designed to be like the `top` command, you fire it up to check for at most 5-10 minutes and stop. It was not meant to be a long monitoring process that can be used to plug to your monitoring system such as Zabbix or Nagios or graphed by Graphite. Nginx has an official status module for this [2], but it requires Nginx Plus, a > $1k product. Other solutions would normally require a log processing process piping to an external system to calculate and store the metrics. While an ELK stack [3] could provide you a lot more useful data, its setup and maintenance efforts can be significant. And that's why I created Luameter.

It easier to setup, flexible to configure, and equally easy to be plugged into external system given its JSON api.

[1] https://github.com/lebinh/ngxtop [2]: http://nginx.com/products/live-activity-monitoring/ [3]: http://www.elasticsearch.org/overview/

Unfortunately most of the servers I'm working with are still on python2 by default. The latest Ubuntu LTS, 12.04, only has python2 by default so python2 is still my priority. But in this case, a port should be trivia so I'll look into python3 as soon as possible.

Yes, ncurses would be much better but I haven't had time for it yet. Clearing screen is simple enough and work pretty well for me so far so here we are :)

The performance impact really depend on your server and traffics. Currently with high traffic server it will take quite some amount of CPU if running for awhile, after 15-20 mins or so, but I'm working on reduce that. So now it mostly useful to know what's going on with your nginx at the moment but not over a long period.