pytbox 0.0.9__py3-none-any.whl → 0.1.1__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.

pytbox/base.py CHANGED
@@ -8,11 +8,11 @@ from pytbox.feishu.client import Client as FeishuClient
8
8
  from pytbox.dida365 import Dida365
9
9
  from pytbox.alert.alert_handler import AlertHandler
10
10
  from pytbox.log.logger import AppLogger
11
-
11
+ from pytbox.win.ad import ADClient
12
+ from pytbox.network.meraki import Meraki
12
13
 
13
14
  config = load_config_by_file(path='/workspaces/pytbox/tests/alert/config_dev.toml', oc_vault_id=os.environ.get('oc_vault_id'))
14
15
 
15
-
16
16
  def get_mongo(collection):
17
17
  return Mongo(
18
18
  host=config['mongo']['host'],
@@ -45,4 +45,20 @@ def get_logger(app):
45
45
  feishu=feishu,
46
46
  dida=dida,
47
47
  mongo=get_mongo('alert_program')
48
- )
48
+ )
49
+
50
+ # ad_dev = ADClient(
51
+ # server=config['ad']['dev']['AD_SERVER'],
52
+ # base_dn=config['ad']['dev']['BASE_DN'],
53
+ # username=config['ad']['dev']['AD_USERNAME'],
54
+ # password=config['ad']['dev']['AD_PASSWORD']
55
+ # )
56
+
57
+ # ad_prod = ADClient(
58
+ # server=config['ad']['prod']['AD_SERVER'],
59
+ # base_dn=config['ad']['prod']['BASE_DN'],
60
+ # username=config['ad']['prod']['AD_USERNAME'],
61
+ # password=config['ad']['prod']['AD_PASSWORD']
62
+ # )
63
+
64
+ meraki = Meraki(api_key=config['meraki']['api_key'], organization_id=config['meraki']['organization_id'])
@@ -3,7 +3,8 @@
3
3
  import os
4
4
  from pathlib import Path
5
5
  from pytbox.utils.load_config import load_config_by_file
6
-
6
+ from glob import glob
7
+ import os
7
8
  from jinja2 import Environment, FileSystemLoader
8
9
 
9
10
 
@@ -40,52 +41,108 @@ class BuildConfig:
40
41
  f.write(render_data)
41
42
 
42
43
  def ping(self):
43
- instances = self.instances['ping']['instance']
44
- render_data = ping_template.render(instances=instances)
45
- target_dir = Path(self.output_dir) / 'input.ping'
46
- if not target_dir.exists():
47
- target_dir.mkdir(parents=True, exist_ok=True)
48
-
49
- with open(Path(self.output_dir) / 'input.ping' / 'ping.toml', 'w', encoding='utf-8') as f:
50
- f.write(render_data)
44
+ if self.instances.get('ping'):
45
+ instances = self.instances['ping']['instance']
46
+ render_data = ping_template.render(instances=instances)
47
+ target_dir = Path(self.output_dir) / 'input.ping'
48
+ if not target_dir.exists():
49
+ target_dir.mkdir(parents=True, exist_ok=True)
50
+
51
+ with open(Path(self.output_dir) / 'input.ping' / 'ping.toml', 'w', encoding='utf-8') as f:
52
+ f.write(render_data)
51
53
 
52
54
  def prometheus(self):
53
- instances = self.instances['prometheus']['urls']
54
- render_data = prometheus_template.render(instances=instances)
55
- target_dir = Path(self.output_dir) / 'input.prometheus'
56
- if not target_dir.exists():
57
- target_dir.mkdir(parents=True, exist_ok=True)
58
- with open(Path(self.output_dir) / 'input.prometheus' / 'prometheus.toml', 'w', encoding='utf-8') as f:
59
- f.write(render_data)
55
+ if self.instances.get('prometheus'):
56
+ instances = self.instances['prometheus']['urls']
57
+ render_data = prometheus_template.render(instances=instances)
58
+ target_dir = Path(self.output_dir) / 'input.prometheus'
59
+ if not target_dir.exists():
60
+ target_dir.mkdir(parents=True, exist_ok=True)
61
+ with open(Path(self.output_dir) / 'input.prometheus' / 'prometheus.toml', 'w', encoding='utf-8') as f:
62
+ f.write(render_data)
60
63
 
61
64
  def vsphere(self):
62
- template = self._get_template('input.vsphere/vsphere.toml.j2')
63
- instances = self.instances['vsphere']['instance']
64
- print(instances)
65
- render_data = template.render(instances=instances)
66
- target_dir = Path(self.output_dir) / 'input.vsphere'
67
- if not target_dir.exists():
68
- target_dir.mkdir(parents=True, exist_ok=True)
69
- with open(Path(self.output_dir) / 'input.vsphere' / 'vsphere.toml', 'w', encoding='utf-8') as f:
70
- f.write(render_data)
65
+ if self.instances.get('vsphere'):
66
+ template = self._get_template('input.vsphere/vsphere.toml.j2')
67
+ instances = self.instances['vsphere']['instance']
68
+ render_data = template.render(instances=instances)
69
+ target_dir = Path(self.output_dir) / 'input.vsphere'
70
+ if not target_dir.exists():
71
+ target_dir.mkdir(parents=True, exist_ok=True)
72
+ with open(Path(self.output_dir) / 'input.vsphere' / 'vsphere.toml', 'w', encoding='utf-8') as f:
73
+ f.write(render_data)
71
74
 
72
75
  def http_response(self):
73
76
  template = self._get_template('input.http_response/http_response.toml.j2')
74
- instances = self.instances['http_response']['instance']
75
- render_data = template.render(instances=instances)
76
- target_dir = Path(self.output_dir) / 'input.http_response'
77
- if not target_dir.exists():
78
- target_dir.mkdir(parents=True, exist_ok=True)
79
- with open(Path(self.output_dir) / 'input.http_response' / 'http_response.toml', 'w', encoding='utf-8') as f:
80
- f.write(render_data)
81
-
77
+ if self.instances.get('http_response'):
78
+ instances = self.instances['http_response']['instance']
79
+ render_data = template.render(instances=instances)
80
+ target_dir = Path(self.output_dir) / 'input.http_response'
81
+ if not target_dir.exists():
82
+ target_dir.mkdir(parents=True, exist_ok=True)
83
+ with open(Path(self.output_dir) / 'input.http_response' / 'http_response.toml', 'w', encoding='utf-8') as f:
84
+ f.write(render_data)
85
+
86
+ def net_response(self):
87
+ template = self._get_template('input.net_response/net_response.toml.j2')
88
+ if self.instances.get('net_response'):
89
+ instances = self.instances['net_response']['instance']
90
+ render_data = template.render(instances=instances)
91
+ target_dir = Path(self.output_dir) / 'input.net_response'
92
+ if not target_dir.exists():
93
+ target_dir.mkdir(parents=True, exist_ok=True)
94
+ with open(Path(self.output_dir) / 'input.net_response' / 'net_response.toml', 'w', encoding='utf-8') as f:
95
+ f.write(render_data)
96
+
97
+ def dns_query(self):
98
+ template = self._get_template('input.dns_query/dns_query.toml.j2')
99
+ if self.instances.get('dns_query'):
100
+ instances = self.instances['dns_query']['instance']
101
+ render_data = template.render(instances=instances)
102
+ target_dir = Path(self.output_dir) / 'input.dns_query'
103
+ if not target_dir.exists():
104
+ target_dir.mkdir(parents=True, exist_ok=True)
105
+ with open(Path(self.output_dir) / 'input.dns_query' / 'dns_query.toml', 'w', encoding='utf-8') as f:
106
+ f.write(render_data)
107
+
108
+ def snmp(self):
109
+ if self.instances.get('snmp'):
110
+ device_types = self.instances['snmp']['instances']
111
+ for device_type in device_types:
112
+ instances = self.instances['snmp']['instances'][device_type]
113
+ jinja2_dir = Path(jinja2_path) / 'input.snmp'
114
+ device_templates = glob(str(jinja2_dir / f'{device_type}_*.toml.j2'))
115
+ if not device_templates:
116
+ continue
117
+
118
+ for tmpl_path in device_templates:
119
+ tmpl_name = os.path.basename(tmpl_path)
120
+ # 例如 h3c_system.toml.j2 -> h3c_system
121
+ base_name = tmpl_name.replace('.toml.j2', '')
122
+
123
+ template = self._get_template(f'input.snmp/{tmpl_name}')
124
+ # 修复数据结构:模板期望的是数组,每个元素是字典
125
+ # instances 是 [{"udp://10.1.1.1:161": {...}, "udp://10.1.1.2:161": {...}}, ...]
126
+ render_data = template.render(instances=instances)
127
+
128
+ target_dir = Path(self.output_dir) / 'input.snmp'
129
+ if not target_dir.exists():
130
+ target_dir.mkdir(parents=True, exist_ok=True)
131
+
132
+ output_file = target_dir / f'{base_name}.toml'
133
+ with open(output_file, 'w', encoding='utf-8') as f:
134
+ f.write(render_data)
135
+
82
136
  def run(self):
83
- # self.common('cpu')
84
- # self.common('mem')
85
- # self.common('net')
86
- # self.common('disk')
87
- # self.common('diskio')
88
- # self.vsphere()
89
- # self.ping()
90
- # self.prometheus()
91
- self.http_response()
137
+ self.common('cpu')
138
+ self.common('mem')
139
+ self.common('net')
140
+ self.common('disk')
141
+ self.common('diskio')
142
+ self.vsphere()
143
+ self.ping()
144
+ self.prometheus()
145
+ self.http_response()
146
+ self.net_response()
147
+ self.dns_query()
148
+ self.snmp()
@@ -5,7 +5,7 @@
5
5
 
6
6
  [prometheus]
7
7
  [[prometheus.urls]]
8
- "http://10.200.12.202:9100" = { name = "x", env = "prod" }
8
+ "http://10.1.1.1:9100" = { name = "x", env = "prod" }
9
9
 
10
10
  [vsphere]
11
11
  [[vsphere.instance]]
@@ -13,4 +13,24 @@
13
13
 
14
14
  [http_response]
15
15
  [[http_response.instance]]
16
- "https://www.baidu.com" = { name = "x", env = "prod" }
16
+ "https://www.baidu.com" = { name = "x", env = "prod" }
17
+
18
+
19
+ [net_response]
20
+ [[net_response.instance]]
21
+ "124.74.245.90:8443" = { name = "x", env = "prod" }
22
+
23
+ [dns_query]
24
+ [[dns_query.instance]]
25
+ "119.29.29.29_baidu.com" = { dns_server = "119.29.29.29", domains = "www.baidu.com", labels = { name = "x", env = "prod" } }
26
+
27
+ [snmp]
28
+ # 支持 h3c,huawei,cisco,ruijie
29
+ [[snmp.instances.h3c]]
30
+ "10.1.1.1:161" = { version = 2, community = "public" }
31
+ "10.1.1.2:161" = { version = 2, community = "public" }
32
+ "10.1.1.3:161" = { version = 3, sec_name = "sec", auth_protocol = "SHA", auth_password = "pass01", priv_protocol = "AES", priv_password = "pass02", sec_level = "authPriv" }
33
+
34
+ # [[snmp.instances.huawei]]
35
+ # "udp://172.16.1.1:161" = { version = 2, community = "public"}
36
+ # "udp://172.16.1.2:161" = { version = 2, community = "public"}
@@ -0,0 +1,12 @@
1
+ {% for instance in instances %}
2
+ {% for name, data in instance.items() %}
3
+ [[instances]]
4
+ # append some labels for series
5
+ labels = { {% for k, v in data['labels'].items() %}{% if not loop.first %}, {% endif %}{% if k.isidentifier() %}{{ k }}{% else %}"{{ k }}"{% endif %} = "{{ v }}"{% endfor %} }
6
+ servers = ["{{ data['dns_server'] }}"]
7
+ ## Domains or subdomains to query.
8
+ domains = ["{{ data['domains'] }}"]
9
+ record_type = "A"
10
+ timeout = 2
11
+ {% endfor %}
12
+ {% endfor %}
@@ -0,0 +1,9 @@
1
+ {% for instance in instances %}
2
+ {% for target, labels in instance.items() %}
3
+ [[instances]]
4
+ targets = [
5
+ "{{ target }}"
6
+ ]
7
+ labels = { {% for k, v in labels.items() %}{% if not loop.first %}, {% endif %}{% if k.isidentifier() %}{{ k }}{% else %}"{{ k }}"{% endif %} = "{{ v }}"{% endfor %} }
8
+ {% endfor %}
9
+ {% 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 = "5s"
21
+ retries = 3
22
+ path = ["/usr/share/snmp/mibs"]
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 = "5s"
21
+ retries = 3
22
+ path = ["/usr/share/snmp/mibs"]
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 = "5s"
21
+ retries = 3
22
+ path = ["/usr/share/snmp/mibs"]
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 = "5s"
21
+ retries = 3
22
+ path = ["/usr/share/snmp/mibs"]
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 = "5s"
21
+ retries = 3
22
+ path = ["/usr/share/snmp/mibs"]
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 = "5s"
21
+ retries = 3
22
+ path = ["/usr/share/snmp/mibs"]
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 %}