How to retrieve NoMachine statistics from command line on server side
Its's possible to retrieve NoMachine statistics (total or partial) for a running session by sending a USR1 or a USR2 signal to the nxnode process to dump statistics in the user's session directory, on server side.
Sending a USR1 signal produces total statistics, i.e. statistics starting from the beginning of the session.
By sending a USR2 signal, you will obtain partial statistics, i.e. statistics starting from the last time a USR2 signal was delivered.
Statistics data are stored in the stats file placed in the session directory in the userhome/.nx/node/ directory on the NoMachine server (or on the Terminal Server Node host if you're gathering statistics on the node of a multi-node environment).
The suggested procedure to gather statistics for a specific session of a given user (let's call him 'nxtest') is below.
1) Disable the automatic cleanup of session directories. Set in node.cfg:
SessionLogClean 0
2) Identify the running session of the given user, in our case nxtest:
/etc/NX/nxserver --list --user nxtest
| Display | Username | Remote IP | Session ID | Node |
| 1002 | nxtest | 192.168.100.25 | A69C316B818F99391413F84BCD4983EC | localhost:4000 |
The running session for user nxtest has id: A69C316B818F99391413F84BCD4983EC.
This means that the stats file will be saved in the corresponding session directory in userhome/.nx/node/. If the session is still running, the directory will be named like: userhome/.nx/node/C-testsetup-1002-A69C316B818F99391413F84BCD4983EC (testsetup is the hostname).If the session is terminated after getting the statistics, the session directory will be prefixed with a T- instead of C-.
3) Let's retrieve the pid of the nxnode process correspondent to that session:
ps -U nxtest | grep nxnode
13154 ? 00:00:19 nxnode.bin
The pid of nxnode is 13154.
4) Send a USR1 signal to nxnode to dump statistics:
kill -USR1 13154
Statistics will be dumped to the userhome/.nx/node/C-testsetup-1002-A69C316B818F99391413F84BCD4983EC/stats file.
