atop icon indicating copy to clipboard operation
atop copied to clipboard

Add support for json style output fot all labels

Open ShirleyFei opened this issue 3 years ago • 0 comments

Currently, atop data can only be viewed when logging into a machine. But sometimes we need to aggregate atop data of multiple machines belonging to the same cluster, such as aggregation of the same application processes, and then draw and show historical graphs for users to query and use.

Considering json is widely used in data processing, this patch will add json style output as a secondary output path. Three types of output are supported:

  1. atop -O stdio
  2. atop -O only
  3. atop -O unixsock -w /path/to/file 10 For 3, make unixsock in a non-blocking state to guarantee it will not block main engine forever. Another point is atop will try to reconnect to the server and continue to work even if the unix remote server relaunches.

Usage examples: ./atop ./atop -P ALL ./atop -O only // overwrite parseout, show json to stdio only ./atop -O stdio -P ALL // both parseout and json stdio ./atop -O stdio -w atop.log // print to stdio, as well as file ./atop -O unixsock // overwrite parseout, show json to unixsock ./atop -O unixsock -P ALL // both parseout and json unixsock ./atop -O unixsock -w atop.log // write json to unixsock and file

The detail json style output format is as follows: {"ip": "a.b.c.d", "timestamp": 1565256314, ..., "CPU": {"hertz": 100, "cpu_nums": 40, ...}, "cpu": [{"hertz": 100, "cpu_id": 3, ...}, ..., {"hertz": 100, "cpu_id": 39, ...}], "PRC": [{"pid": 1, "p_name": "(systemd)", ...}, ..., {"pid": 73, "p_name": "(migration/12)", ...}], ... }

Signed-off-by: Fei Li [email protected] Signed-off-by: zhenwei pi [email protected]

ShirleyFei avatar Nov 10 '21 09:11 ShirleyFei