|
|
|
|
|
by Nitrado
2994 days ago
|
|
ClickHouse ships with a command line tool which does this (without the actual database server): ps aux | tail -n +2 | awk '{ printf("%s\t%s\n", $1, $4) }' | \
clickhouse-local -S "user String, mem Float64" \
-q "SELECT user, round(sum(mem), 2) as memTotal FROM table GROUP BY user ORDER BY memTotal DESC FORMAT Pretty"
┏━━━━━━━━━━┳━━━━━━━━━━┓
┃ user ┃ memTotal ┃
┡━━━━━━━━━━╇━━━━━━━━━━┩
│ clickho+ │ 0.7 │
├──────────┼──────────┤
│ root │ 0.2 │
├──────────┼──────────┤
│ netdata │ 0.1 │
├──────────┼──────────┤
│ ntp │ 0 │
├──────────┼──────────┤
│ dbus │ 0 │
├──────────┼──────────┤
│ nginx │ 0 │
├──────────┼──────────┤
│ polkitd │ 0 │
├──────────┼──────────┤
│ nscd │ 0 │
├──────────┼──────────┤
│ postfix │ 0 │
└──────────┴──────────┘
Has the advantage of being really fast. |
|