Skip to content

I wrote a better version of top for shared hosting

General Discussion by larryjeong 2 replies 151 views
11 #1

Spent $0 on this. Just needed to see my procs on a $3/yr cpanel box without getting killed by oom. Its called ltop. Reads /proc directly. No ncurses. Outputs plain text you can grep.

The whole thing is 180 lines of c. Uses 40kb rss. Shows cpu mem and elapsed time per user. Skips system procs so you only see your own stuff.

I run it on 6 hosts now. Definitely beats waiting 30 seconds for regular top to draw on a oversold node.

Source is on my gitea. No license do what u want

$3/year. 128MB RAM. Pure happiness.
#2

Fun little project larry, it actually works

Tried it on my Kimsufi box from OVHcloud and it compiled clean with just gcc and musl. Had to tweak the uid detection for the openvz container though, the /proc ownership is weird there

--- ltop.c.orig 2025-05-27 12:00:00.000000000 +0000
+++ ltop.c      2025-05-27 14:33:00.000000000 +0000
@@ -45,7 +45,7 @@
         if (ent->d_type != DT_DIR) continue;
         int pid = atoi(ent->d_name);
         if (pid <= 0) continue;
-        snprintf(path, sizeof(path), "/proc/%d/status", pid);
+        snprintf(path, sizeof(path), "/proc/%d/status", pid);
         // check Uid: line against getuid()

The openvz patch is basically just handling missing fields gracefully. Want me to pr this or just drop it here?

works on my bench ¯\_(ツ)_/¯
#3

Oh man this takes me back to when I was running a dozen shared hosting accounts across three different providers (all dead now obviously) and the one thing that always killed me was not being able to see what the neighbor processes were doing to the node because of course they hide all that from you (and for good reason I suppose since you dont want people seeing each others paths and command lines and database names and whatnot) but the problem is you end up completely blind to whether your own site is slow because of your own code or because some other tenant is mining monero again (it happened twice on two different hosts both times the provider took days to notice) so having something lightweight that just shows your own slice without the overhead of the full top with all its sorting and colors and interactive refresh is actually a really elegant solution and I think the real genius

Post a reply

You need an account to reply. Log in or register to join the conversation.

Post reply Preview Save draft