Skip to content

Commit 45b32dd

Browse files
Update list_hosts.py
1 parent 6c88014 commit 45b32dd

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

examples/list_hosts.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#!/usr/bin/env python
22
#
3-
# This script shows how to leverage sysdig's data query API to obtain the list
4-
# of the instrumented hosts that have been seen in the last 5 minutes.
5-
# Updated 1/24/2019 - Dale J. Rodriguez
6-
# This script will also show the container count in addition to the hostnames in a from like this: host.name 12
3+
## This script shows how to leverage sysdig's data query API to obtain the list
4+
# of the instrumented hosts that have been seen in the last hour (`duration` variable).
5+
# The output will show the container count (`container.count` metric) in addition to the hostnames (`host.hostName` tag) in a from like this:
6+
#
7+
# host-1 12
8+
# host-2 4
9+
#
10+
# host-1 12
11+
# host-2 4
12+
#his: host.name 12
713
# Where 12 is the container count and host.name is the host
814
#
915
import getopt
@@ -34,8 +40,13 @@ def usage():
3440
print_json = True
3541
sdc_token = args[0]
3642
#
37-
# Instantiate the SDC client
3843
#
44+
# Prepare the query's metrics list.
45+
# In this case, we have one tag (used for segmentation) and one metric::
46+
# host.hostName. This is a tag, to identify each item of the output.
47+
# container.count: This is the metric
48+
#
49+
# Instantiate the SDC client
3950
sdclient = SdcClient(sdc_token)
4051
metrics = [{"id": "host.hostName"}, {"id": "container.count","aggregations":{"time":"avg","group":"avg"}}]
4152
res = sdclient.get_data(

0 commit comments

Comments
 (0)