pytbox 0.0.7__py3-none-any.whl → 0.3.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pytbox might be problematic. Click here for more details.

Files changed (55) hide show
  1. pytbox/alert/alert_handler.py +27 -7
  2. pytbox/alert/ping.py +0 -1
  3. pytbox/alicloud/sls.py +9 -6
  4. pytbox/base.py +74 -1
  5. pytbox/categraf/build_config.py +95 -32
  6. pytbox/categraf/instances.toml +39 -0
  7. pytbox/categraf/jinja2/__init__.py +6 -0
  8. pytbox/categraf/jinja2/input.cpu/cpu.toml.j2 +5 -0
  9. pytbox/categraf/jinja2/input.disk/disk.toml.j2 +11 -0
  10. pytbox/categraf/jinja2/input.diskio/diskio.toml.j2 +6 -0
  11. pytbox/categraf/jinja2/input.dns_query/dns_query.toml.j2 +12 -0
  12. pytbox/categraf/jinja2/input.http_response/http_response.toml.j2 +9 -0
  13. pytbox/categraf/jinja2/input.mem/mem.toml.j2 +5 -0
  14. pytbox/categraf/jinja2/input.net/net.toml.j2 +11 -0
  15. pytbox/categraf/jinja2/input.net_response/net_response.toml.j2 +9 -0
  16. pytbox/categraf/jinja2/input.ping/ping.toml.j2 +11 -0
  17. pytbox/categraf/jinja2/input.prometheus/prometheus.toml.j2 +12 -0
  18. pytbox/categraf/jinja2/input.snmp/cisco_interface.toml.j2 +96 -0
  19. pytbox/categraf/jinja2/input.snmp/cisco_system.toml.j2 +41 -0
  20. pytbox/categraf/jinja2/input.snmp/h3c_interface.toml.j2 +96 -0
  21. pytbox/categraf/jinja2/input.snmp/h3c_system.toml.j2 +41 -0
  22. pytbox/categraf/jinja2/input.snmp/huawei_interface.toml.j2 +96 -0
  23. pytbox/categraf/jinja2/input.snmp/huawei_system.toml.j2 +41 -0
  24. pytbox/categraf/jinja2/input.snmp/ruijie_interface.toml.j2 +96 -0
  25. pytbox/categraf/jinja2/input.snmp/ruijie_system.toml.j2 +41 -0
  26. pytbox/categraf/jinja2/input.vsphere/vsphere.toml.j2 +211 -0
  27. pytbox/cli/commands/vm.py +22 -0
  28. pytbox/cli/main.py +2 -0
  29. pytbox/database/mongo.py +1 -1
  30. pytbox/database/victoriametrics.py +331 -40
  31. pytbox/excel.py +64 -0
  32. pytbox/feishu/endpoints.py +6 -6
  33. pytbox/log/logger.py +33 -13
  34. pytbox/mail/alimail.py +142 -0
  35. pytbox/mail/client.py +171 -0
  36. pytbox/mail/mail_detail.py +30 -0
  37. pytbox/mingdao.py +164 -0
  38. pytbox/network/meraki.py +537 -0
  39. pytbox/notion.py +731 -0
  40. pytbox/pyjira.py +612 -0
  41. pytbox/utils/cronjob.py +79 -0
  42. pytbox/utils/env.py +2 -2
  43. pytbox/utils/load_config.py +67 -21
  44. pytbox/utils/load_vm_devfile.py +45 -0
  45. pytbox/utils/richutils.py +11 -1
  46. pytbox/utils/timeutils.py +15 -57
  47. pytbox/vmware.py +120 -0
  48. pytbox/win/ad.py +30 -0
  49. {pytbox-0.0.7.dist-info → pytbox-0.3.2.dist-info}/METADATA +7 -4
  50. pytbox-0.3.2.dist-info/RECORD +72 -0
  51. pytbox/utils/ping_checker.py +0 -1
  52. pytbox-0.0.7.dist-info/RECORD +0 -39
  53. {pytbox-0.0.7.dist-info → pytbox-0.3.2.dist-info}/WHEEL +0 -0
  54. {pytbox-0.0.7.dist-info → pytbox-0.3.2.dist-info}/entry_points.txt +0 -0
  55. {pytbox-0.0.7.dist-info → pytbox-0.3.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,41 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.field]]
32
+ oid = "1.3.6.1.2.1.1.1.0"
33
+ name = "sysDescr"
34
+ is_tag = true
35
+
36
+ [[instances.field]]
37
+ oid = "1.3.6.1.2.1.1.3.0"
38
+ name = "sysUpTime"
39
+ conversion = "float(2)"
40
+ {% endfor %}
41
+ {% endfor %}
@@ -0,0 +1,96 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.table]]
32
+ name = "interface"
33
+ inherit_tags = ["sysName"]
34
+ index_as_tag = true
35
+
36
+ [[instances.table.field]]
37
+ name = "ifIndex"
38
+ oid = "1.3.6.1.2.1.2.2.1.1"
39
+ is_tag = true
40
+
41
+ [[instances.table.field]]
42
+ name = "ifName"
43
+ oid = "1.3.6.1.2.1.31.1.1.1.1"
44
+ is_tag = true
45
+
46
+ [[instances.table.field]]
47
+ name = "ifDescr"
48
+ oid = "1.3.6.1.2.1.2.2.1.2"
49
+ is_tag = true
50
+
51
+ [[instances.table.field]]
52
+ name = "ifSpeed"
53
+ oid = "1.3.6.1.2.1.2.2.1.5"
54
+ # is_tag = true
55
+
56
+ [[instances.table.field]]
57
+ name = "ifAdminStatus"
58
+ oid = "1.3.6.1.2.1.2.2.1.7"
59
+ # is_tag = true
60
+
61
+ [[instances.table.field]]
62
+ name = "ifOperStatus"
63
+ oid = "1.3.6.1.2.1.2.2.1.8"
64
+ # is_tag = true
65
+
66
+ [[instances.table.field]]
67
+ name = "ifInDiscards"
68
+ oid = "1.3.6.1.2.1.2.2.1.13"
69
+
70
+ [[instances.table.field]]
71
+ name = "ifInErrors"
72
+ oid = "1.3.6.1.2.1.2.2.1.14"
73
+
74
+ [[instances.table.field]]
75
+ name = "ifOutDiscards"
76
+ oid = "1.3.6.1.2.1.2.2.1.19"
77
+
78
+ [[instances.table.field]]
79
+ name = "ifOutErrors"
80
+ oid = "1.3.6.1.2.1.2.2.1.20"
81
+
82
+ [[instances.table.field]]
83
+ name = "ifAlias"
84
+ oid = "1.3.6.1.2.1.31.1.1.1.18"
85
+ is_tag = true
86
+
87
+ [[instances.table.field]]
88
+ name = "ifHCInOctets"
89
+ oid = "1.3.6.1.2.1.31.1.1.1.6"
90
+
91
+ [[instances.table.field]]
92
+ name = "ifHCOutOctets"
93
+ oid = "1.3.6.1.2.1.31.1.1.1.10"
94
+
95
+ {% endfor %}
96
+ {% endfor %}
@@ -0,0 +1,41 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.field]]
32
+ oid = "1.3.6.1.2.1.1.1.0"
33
+ name = "sysDescr"
34
+ is_tag = true
35
+
36
+ [[instances.field]]
37
+ oid = "1.3.6.1.2.1.1.3.0"
38
+ name = "sysUpTime"
39
+ conversion = "float(2)"
40
+ {% endfor %}
41
+ {% endfor %}
@@ -0,0 +1,96 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.table]]
32
+ name = "interface"
33
+ inherit_tags = ["sysName"]
34
+ index_as_tag = true
35
+
36
+ [[instances.table.field]]
37
+ name = "ifIndex"
38
+ oid = "1.3.6.1.2.1.2.2.1.1"
39
+ is_tag = true
40
+
41
+ [[instances.table.field]]
42
+ name = "ifName"
43
+ oid = "1.3.6.1.2.1.31.1.1.1.1"
44
+ is_tag = true
45
+
46
+ [[instances.table.field]]
47
+ name = "ifDescr"
48
+ oid = "1.3.6.1.2.1.2.2.1.2"
49
+ is_tag = true
50
+
51
+ [[instances.table.field]]
52
+ name = "ifSpeed"
53
+ oid = "1.3.6.1.2.1.2.2.1.5"
54
+ # is_tag = true
55
+
56
+ [[instances.table.field]]
57
+ name = "ifAdminStatus"
58
+ oid = "1.3.6.1.2.1.2.2.1.7"
59
+ # is_tag = true
60
+
61
+ [[instances.table.field]]
62
+ name = "ifOperStatus"
63
+ oid = "1.3.6.1.2.1.2.2.1.8"
64
+ # is_tag = true
65
+
66
+ [[instances.table.field]]
67
+ name = "ifInDiscards"
68
+ oid = "1.3.6.1.2.1.2.2.1.13"
69
+
70
+ [[instances.table.field]]
71
+ name = "ifInErrors"
72
+ oid = "1.3.6.1.2.1.2.2.1.14"
73
+
74
+ [[instances.table.field]]
75
+ name = "ifOutDiscards"
76
+ oid = "1.3.6.1.2.1.2.2.1.19"
77
+
78
+ [[instances.table.field]]
79
+ name = "ifOutErrors"
80
+ oid = "1.3.6.1.2.1.2.2.1.20"
81
+
82
+ [[instances.table.field]]
83
+ name = "ifAlias"
84
+ oid = "1.3.6.1.2.1.31.1.1.1.18"
85
+ is_tag = true
86
+
87
+ [[instances.table.field]]
88
+ name = "ifHCInOctets"
89
+ oid = "1.3.6.1.2.1.31.1.1.1.6"
90
+
91
+ [[instances.table.field]]
92
+ name = "ifHCOutOctets"
93
+ oid = "1.3.6.1.2.1.31.1.1.1.10"
94
+
95
+ {% endfor %}
96
+ {% endfor %}
@@ -0,0 +1,41 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.field]]
32
+ oid = "1.3.6.1.2.1.1.1.0"
33
+ name = "sysDescr"
34
+ is_tag = true
35
+
36
+ [[instances.field]]
37
+ oid = "1.3.6.1.2.1.1.3.0"
38
+ name = "sysUpTime"
39
+ conversion = "float(2)"
40
+ {% endfor %}
41
+ {% endfor %}
@@ -0,0 +1,96 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.table]]
32
+ name = "interface"
33
+ inherit_tags = ["sysName"]
34
+ index_as_tag = true
35
+
36
+ [[instances.table.field]]
37
+ name = "ifIndex"
38
+ oid = "1.3.6.1.2.1.2.2.1.1"
39
+ is_tag = true
40
+
41
+ [[instances.table.field]]
42
+ name = "ifName"
43
+ oid = "1.3.6.1.2.1.31.1.1.1.1"
44
+ is_tag = true
45
+
46
+ [[instances.table.field]]
47
+ name = "ifDescr"
48
+ oid = "1.3.6.1.2.1.2.2.1.2"
49
+ is_tag = true
50
+
51
+ [[instances.table.field]]
52
+ name = "ifSpeed"
53
+ oid = "1.3.6.1.2.1.2.2.1.5"
54
+ # is_tag = true
55
+
56
+ [[instances.table.field]]
57
+ name = "ifAdminStatus"
58
+ oid = "1.3.6.1.2.1.2.2.1.7"
59
+ # is_tag = true
60
+
61
+ [[instances.table.field]]
62
+ name = "ifOperStatus"
63
+ oid = "1.3.6.1.2.1.2.2.1.8"
64
+ # is_tag = true
65
+
66
+ [[instances.table.field]]
67
+ name = "ifInDiscards"
68
+ oid = "1.3.6.1.2.1.2.2.1.13"
69
+
70
+ [[instances.table.field]]
71
+ name = "ifInErrors"
72
+ oid = "1.3.6.1.2.1.2.2.1.14"
73
+
74
+ [[instances.table.field]]
75
+ name = "ifOutDiscards"
76
+ oid = "1.3.6.1.2.1.2.2.1.19"
77
+
78
+ [[instances.table.field]]
79
+ name = "ifOutErrors"
80
+ oid = "1.3.6.1.2.1.2.2.1.20"
81
+
82
+ [[instances.table.field]]
83
+ name = "ifAlias"
84
+ oid = "1.3.6.1.2.1.31.1.1.1.18"
85
+ is_tag = true
86
+
87
+ [[instances.table.field]]
88
+ name = "ifHCInOctets"
89
+ oid = "1.3.6.1.2.1.31.1.1.1.6"
90
+
91
+ [[instances.table.field]]
92
+ name = "ifHCOutOctets"
93
+ oid = "1.3.6.1.2.1.31.1.1.1.10"
94
+
95
+ {% endfor %}
96
+ {% endfor %}
@@ -0,0 +1,41 @@
1
+ {% for instance in instances %}
2
+ {% for agent, detail in instance.items() %}
3
+ [[instances]]
4
+ agents = [
5
+ "udp://{{agent}}"
6
+ ]
7
+ {% if detail.version == 2 %}
8
+ version = {{detail.version}}
9
+ community = "{{detail.community}}"
10
+ {% endif %}
11
+ {% if detail.version == 3 %}
12
+ version = {{detail.version}}
13
+ sec_name = "{{detail.sec_name}}"
14
+ auth_protocol = "{{detail.auth_protocol}}"
15
+ auth_password = "{{detail.auth_password}}"
16
+ priv_protocol = "{{detail.priv_protocol}}"
17
+ priv_password = "{{detail.priv_password}}"
18
+ sec_level = "{{detail.sec_level}}"
19
+ {% endif %}
20
+ timeout = "{{config.timeout}}"
21
+ retries = 3
22
+ path = ["{{config.path}}"]
23
+ translator = "gosmi"
24
+ max_repetitions = 50
25
+
26
+ [[instances.field]]
27
+ name = "sysName"
28
+ oid = "1.3.6.1.2.1.1.5.0"
29
+ is_tag = true
30
+
31
+ [[instances.field]]
32
+ oid = "1.3.6.1.2.1.1.1.0"
33
+ name = "sysDescr"
34
+ is_tag = true
35
+
36
+ [[instances.field]]
37
+ oid = "1.3.6.1.2.1.1.3.0"
38
+ name = "sysUpTime"
39
+ conversion = "float(2)"
40
+ {% endfor %}
41
+ {% endfor %}
@@ -0,0 +1,211 @@
1
+ # # collect interval
2
+ # interval = 15
3
+
4
+ # Read metrics from one or many vCenters
5
+ {% for instance in instances %}
6
+ {% for name, vcenter_info in instance.items() %}
7
+ [[instances]]
8
+ vcenter = "{{ vcenter_info['vcenter'] }}"
9
+ username = "{{ vcenter_info['username'] }}"
10
+ password = "{{ vcenter_info['password'] }}"
11
+
12
+ cluster_metric_exlcude = ["*"]
13
+ ## VMs
14
+ ## Typical VM metrics (if omitted or empty, all metrics are collected)
15
+ # vm_include = [ "/*/vm/**"] # Inventory path to VMs to collect (by default all are collected)
16
+ # vm_exclude = [] # Inventory paths to exclude
17
+ vm_metric_include = [
18
+ # "config.hardware.numCPU",
19
+ # "config.hardware.memoryMB",
20
+ "cpu.demand.average",
21
+ "cpu.idle.summation",
22
+ "cpu.latency.average",
23
+ "cpu.readiness.average",
24
+ "cpu.ready.summation",
25
+ "cpu.run.summation",
26
+ "cpu.usagemhz.average",
27
+ "cpu.usage.average",
28
+ "cpu.used.summation",
29
+ "cpu.wait.summation",
30
+ "mem.active.average",
31
+ "mem.granted.average",
32
+ "mem.latency.average",
33
+ "mem.swapin.average",
34
+ "mem.swapinRate.average",
35
+ "mem.swapout.average",
36
+ "mem.swapoutRate.average",
37
+ "mem.usage.average",
38
+ "mem.vmmemctl.average",
39
+ "net.bytesRx.average",
40
+ "net.bytesTx.average",
41
+ "net.droppedRx.summation",
42
+ "net.droppedTx.summation",
43
+ "net.usage.average",
44
+ "power.power.average",
45
+ "virtualDisk.numberReadAveraged.average",
46
+ "virtualDisk.numberWriteAveraged.average",
47
+ "virtualDisk.read.average",
48
+ "virtualDisk.readOIO.latest",
49
+ "virtualDisk.throughput.usage.average",
50
+ "virtualDisk.totalReadLatency.average",
51
+ "virtualDisk.totalWriteLatency.average",
52
+ "virtualDisk.write.average",
53
+ "virtualDisk.writeOIO.latest",
54
+ "sys.uptime.latest",
55
+ ]
56
+ # vm_metric_exclude = [] ## Nothing is excluded by default
57
+ # vm_instances = true ## true by default
58
+
59
+ ## Hosts
60
+ ## Typical host metrics (if omitted or empty, all metrics are collected)
61
+ # host_include = [ "/*/host/**"] # Inventory path to hosts to collect (by default all are collected)
62
+ # host_exclude [] # Inventory paths to exclude
63
+ host_metric_include = [
64
+ "cpu.coreUtilization.average",
65
+ "cpu.costop.summation",
66
+ "cpu.demand.average",
67
+ "cpu.idle.summation",
68
+ "cpu.latency.average",
69
+ "cpu.readiness.average",
70
+ "cpu.ready.summation",
71
+ "cpu.swapwait.summation",
72
+ "cpu.usage.average",
73
+ "cpu.usagemhz.average",
74
+ "cpu.used.summation",
75
+ "cpu.utilization.average",
76
+ "cpu.wait.summation",
77
+ "disk.deviceReadLatency.average",
78
+ "disk.deviceWriteLatency.average",
79
+ "disk.kernelReadLatency.average",
80
+ "disk.kernelWriteLatency.average",
81
+ "disk.numberReadAveraged.average",
82
+ "disk.numberWriteAveraged.average",
83
+ "disk.read.average",
84
+ "disk.totalReadLatency.average",
85
+ "disk.totalWriteLatency.average",
86
+ "disk.write.average",
87
+ "mem.active.average",
88
+ "mem.latency.average",
89
+ "mem.state.latest",
90
+ "mem.swapin.average",
91
+ "mem.swapinRate.average",
92
+ "mem.swapout.average",
93
+ "mem.swapoutRate.average",
94
+ "mem.totalCapacity.average",
95
+ "mem.usage.average",
96
+ "mem.vmmemctl.average",
97
+ "net.bytesRx.average",
98
+ "net.bytesTx.average",
99
+ "net.droppedRx.summation",
100
+ "net.droppedTx.summation",
101
+ "net.errorsRx.summation",
102
+ "net.errorsTx.summation",
103
+ "net.usage.average",
104
+ "power.power.average",
105
+ "storageAdapter.numberReadAveraged.average",
106
+ "storageAdapter.numberWriteAveraged.average",
107
+ "storageAdapter.read.average",
108
+ "storageAdapter.write.average",
109
+ "sys.uptime.latest",
110
+ ]
111
+
112
+
113
+ # host_instances = true ## true by default
114
+ # host_include = [] ## Nothing included by default
115
+ # host_exclude = [] ## Nothing excluded by default
116
+ # host_metric_include = [] ## Nothing included by default
117
+ # host_metric_exclude = [] ## Nothing excluded by default
118
+
119
+
120
+ ## Clusters
121
+ # cluster_include = [ "/*/host/**"] # Inventory path to clusters to collect (by default all are collected)
122
+ # cluster_exclude = [] # Inventory paths to exclude
123
+ # cluster_metric_include = [] ## if omitted or empty, all metrics are collected
124
+ # cluster_metric_exclude = [] ## Nothing excluded by default
125
+ # cluster_instances = false ## false by default
126
+
127
+ ## Resource Pools
128
+ # resoucepool_include = [ "/*/host/**"] # Inventory path to datastores to collect (by default all are collected)
129
+ # resoucepool_exclude = [] # Inventory paths to exclude
130
+ # resoucepool_metric_include = [] ## if omitted or empty, all metrics are collected
131
+ # resoucepool_metric_exclude = [] ## Nothing excluded by default
132
+ # resoucepool_instances = false ## false by default
133
+
134
+ ## Datastores
135
+ # datastore_include = [ "/*/datastore/**"] # Inventory path to datastores to collect (by default all are collected)
136
+ # datastore_exclude = [] # Inventory paths to exclude
137
+ # datastore_metric_include = [] ## if omitted or empty, all metrics are collected
138
+ # datastore_metric_exclude = [] ## Nothing excluded by default
139
+ # datastore_instances = false ## false by default
140
+
141
+ ## Datacenters
142
+ # datacenter_include = [ "/*/host/**"] # Inventory path to clusters to collect (by default all are collected)
143
+ # datacenter_exclude = [] # Inventory paths to exclude
144
+ # datacenter_metric_include = [] ## if omitted or empty, all metrics are collected
145
+ # datacenter_metric_exclude = [ "*" ] ## Datacenters are not collected by default.
146
+ # datacenter_instances = false ## false by default
147
+
148
+ ## Plugin Settings
149
+ ## separator character to use for measurement and field names (default: "_")
150
+ # separator = "_"
151
+
152
+ ## Collect IP addresses? Valid values are "ipv4" and "ipv6"
153
+ # ip_addresses = ["ipv6", "ipv4" ]
154
+
155
+ ## When set to true, all samples are sent as integers. This makes the output
156
+ ## data types backwards compatible with Telegraf 1.9 or lower. Normally all
157
+ ## samples from vCenter, with the exception of percentages, are integer
158
+ ## values, but under some conditions, some averaging takes place internally in
159
+ ## the plugin. Setting this flag to "false" will send values as floats to
160
+ ## preserve the full precision when averaging takes place.
161
+ # use_int_samples = true
162
+
163
+ ## Custom attributes from vCenter can be very useful for queries in order to slice the
164
+ ## metrics along different dimension and for forming ad-hoc relationships. They are disabled
165
+ ## by default, since they can add a considerable amount of tags to the resulting metrics. To
166
+ ## enable, simply set custom_attribute_exclude to [] (empty set) and use custom_attribute_include
167
+ ## to select the attributes you want to include.
168
+ ## By default, since they can add a considerable amount of tags to the resulting metrics. To
169
+ ## enable, simply set custom_attribute_exclude to [] (empty set) and use custom_attribute_include
170
+ ## to select the attributes you want to include.
171
+ # custom_attribute_include = []
172
+ # custom_attribute_exclude = ["*"]
173
+
174
+
175
+ ## The number of vSphere 5 minute metric collection cycles to look back for non-realtime metrics. In
176
+ ## some versions (6.7, 7.0 and possible more), certain metrics, such as cluster metrics, may be reported
177
+ ## with a significant delay (>30min). If this happens, try increasing this number. Please note that increasing
178
+ ## it too much may cause performance issues.
179
+ # metric_lookback = 3
180
+
181
+ ## number of objects to retrieve per query for realtime resources (vms and hosts)
182
+ ## set to 64 for vCenter 5.5 and 6.0 (default: 256)
183
+ # max_query_objects = 256
184
+
185
+ ## number of metrics to retrieve per query for non-realtime resources (clusters and datastores)
186
+ ## set to 64 for vCenter 5.5 and 6.0 (default: 256)
187
+ # max_query_metrics = 256
188
+
189
+ ## number of go routines to use for collection and discovery of objects and metrics
190
+ # collect_concurrency = 1
191
+ # discover_concurrency = 1
192
+
193
+ ## the interval before (re)discovering objects subject to metrics collection (default: 300s)
194
+ # object_discovery_interval = "300s"
195
+
196
+ ## timeout applies to any of the api request made to vcenter
197
+ # timeout = "60s"
198
+
199
+ ## Optional SSL Config
200
+ use_tls = true
201
+ # tls_ca = "/path/to/cafile"
202
+ # tls_cert = "/path/to/certfile"
203
+ # tls_key = "/path/to/keyfile"
204
+ ## Use SSL but skip chain & host verification
205
+ insecure_skip_verify = true
206
+
207
+ ## The Historical Interval value must match EXACTLY the interval in the daily
208
+ # "Interval Duration" found on the VCenter server under Configure > General > Statistics > Statistic intervals
209
+ # historical_interval = "5m"
210
+ {% endfor %}
211
+ {% endfor %}
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import click
4
+ from pytbox.database.victoriametrics import VictoriaMetrics
5
+ from pytbox.utils.richutils import RichUtils
6
+
7
+ rich_utils = RichUtils()
8
+
9
+ @click.group()
10
+ def vm_group():
11
+ """VictoriaMetrics 查询工具"""
12
+ pass
13
+
14
+
15
+ @vm_group.command('query')
16
+ @click.option('--url', '-u', type=str, required=True)
17
+ @click.option('--query', '-q', type=str, required=True)
18
+ def query(url, query):
19
+ """查询 VM 数据"""
20
+ vm_client = VictoriaMetrics(url=url)
21
+ r = vm_client.query(query, output_format='json')
22
+ rich_utils.print(msg=r)