Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for json style output fot all labels #176

Closed
wants to merge 1 commit into from

Conversation

ShirleyFei
Copy link
Contributor

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 lifei.shirley@bytedance.com
Signed-off-by: zhenwei pi pizhenwei@bytedance.com

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 <lifei.shirley@bytedance.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
@Atoptool
Copy link
Owner

This pull request has already been implemented by pull request #214.

@Atoptool Atoptool closed this Dec 24, 2022
@ShirleyFei ShirleyFei deleted the add-json-style-output branch December 30, 2022 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants