How to get memory usage of a Minecraft server?
I am creating a Minecraft control panel at the moment and having trouble by getting the memory usage of the process.
My current process:
- launch the server in a screen
- get the pid of the screen
- fetch amount of ram with command
ps -p <pid> -o %mem
The error is, that it is always showing me a usage of 0.0 KB
I'm using Debian Linux.
Any ideas?
31 Answer
That's because the pid that you're searching is the pid of screen. The minecraft jar should have a ppid (parent pid) of the screen, so run:
ps -el | grep <pid of screen>you should get something like:
root@ubuntu:~# ps -el | grep 26270
5 S 0 26270 1 0 80 0 - 6797 poll_s ? 00:00:00 screen
4 S 0 26271 26270 49 80 0 - 1026274 futex_ pts/0 00:00:15 javawhere 26271 is the pid of the process inside of the screen