Compare commits
3 Commits
6132cdd879
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6094f9e4fe | |||
| 85079c9272 | |||
| 419f7acd4b |
12
README.md
12
README.md
@@ -24,7 +24,7 @@ zabbix:
|
|||||||
* user must have access to API `template.get`
|
* user must have access to API `template.get`
|
||||||
|
|
||||||
## usage
|
## usage
|
||||||
* get an overview of *used* templates: `./main.py --overview`
|
* get an overview of *used* templates: `./main.py --overview --server foo`
|
||||||
```
|
```
|
||||||
Borg Backup Passive
|
Borg Backup Passive
|
||||||
Vendor:
|
Vendor:
|
||||||
@@ -41,7 +41,15 @@ FreeBSD by Zabbix agent
|
|||||||
router.exmaple.com
|
router.exmaple.com
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
* check for new versions and download known templates: `./main.py --check`
|
* get an overview of *used* templates in machine readable format: `./main.py --overview --server foo --format machine`
|
||||||
|
* copy&paste'able into libre calc
|
||||||
|
```
|
||||||
|
name vendor version uuid hosts known
|
||||||
|
Borg Backup Passive 3077e7298167465b96d30503bcff4769 devloop.de,blah.example.com,moep.example.com no
|
||||||
|
FreeBSD by Zabbix agent Zabbix 7.0-2 a3dc630729e443139f4e608954fa6e19 router.exmaple.com yes
|
||||||
|
...
|
||||||
|
```
|
||||||
|
* check for new versions and download known templates: `./main.py --check --server foo`
|
||||||
```
|
```
|
||||||
found update for Template Module Generic SNMPv2
|
found update for Template Module Generic SNMPv2
|
||||||
found update for Template OS FreeBSD
|
found update for Template OS FreeBSD
|
||||||
|
|||||||
32
main.py
32
main.py
@@ -24,8 +24,14 @@ def get_api_templates(server):
|
|||||||
api_templates = api.template.get(selectHosts=["hostid", "name"], sortfield="name")
|
api_templates = api.template.get(selectHosts=["hostid", "name"], sortfield="name")
|
||||||
return [t for t in api_templates if len(t["hosts"]) > 0]
|
return [t for t in api_templates if len(t["hosts"]) > 0]
|
||||||
|
|
||||||
def overview(server):
|
def overview(server, format):
|
||||||
api_templates = get_api_templates(server)
|
api_templates = get_api_templates(server)
|
||||||
|
if format == "human":
|
||||||
|
overview_output_human(api_templates)
|
||||||
|
elif format == "machine":
|
||||||
|
overview_output_machine(api_templates)
|
||||||
|
|
||||||
|
def overview_output_human(api_templates):
|
||||||
for api_template in api_templates:
|
for api_template in api_templates:
|
||||||
print(api_template["name"])
|
print(api_template["name"])
|
||||||
print(f"\tVendor: {api_template['vendor_name']}")
|
print(f"\tVendor: {api_template['vendor_name']}")
|
||||||
@@ -37,6 +43,27 @@ def overview(server):
|
|||||||
if not api_template['uuid'] in templates["templates"]:
|
if not api_template['uuid'] in templates["templates"]:
|
||||||
print("\t!!! not found in templates.yml")
|
print("\t!!! not found in templates.yml")
|
||||||
|
|
||||||
|
def overview_output_machine(api_templates):
|
||||||
|
print("name", end="\t")
|
||||||
|
print("vendor", end="\t")
|
||||||
|
print("version", end="\t")
|
||||||
|
print("uuid", end="\t")
|
||||||
|
print("hosts", end="\t")
|
||||||
|
print("known")
|
||||||
|
for api_template in api_templates:
|
||||||
|
print(api_template["name"], end="\t")
|
||||||
|
print(api_template["vendor_name"], end="\t")
|
||||||
|
print(api_template["vendor_version"], end="\t")
|
||||||
|
print(api_template["uuid"], end="\t")
|
||||||
|
for host in api_template["hosts"]:
|
||||||
|
print(host["name"], end=",")
|
||||||
|
print("\t", end="")
|
||||||
|
if api_template['uuid'] in templates["templates"]:
|
||||||
|
print("yes")
|
||||||
|
else:
|
||||||
|
print("no")
|
||||||
|
|
||||||
|
|
||||||
def check(server):
|
def check(server):
|
||||||
api_templates = get_api_templates(server)
|
api_templates = get_api_templates(server)
|
||||||
for api_template in api_templates:
|
for api_template in api_templates:
|
||||||
@@ -58,10 +85,11 @@ def main():
|
|||||||
args_parser.add_argument("--overview", action="store_true", help="show overview of used templates")
|
args_parser.add_argument("--overview", action="store_true", help="show overview of used templates")
|
||||||
args_parser.add_argument("--check", action="store_true", help="check known templates for updates")
|
args_parser.add_argument("--check", action="store_true", help="check known templates for updates")
|
||||||
args_parser.add_argument("--server", type=str, help="server to use from config.yml", required=True)
|
args_parser.add_argument("--server", type=str, help="server to use from config.yml", required=True)
|
||||||
|
args_parser.add_argument("--format", type=str, help="output format: machine or human, default to human", default="human")
|
||||||
args = args_parser.parse_args()
|
args = args_parser.parse_args()
|
||||||
|
|
||||||
if args.overview:
|
if args.overview:
|
||||||
overview(args.server)
|
overview(args.server, args.format)
|
||||||
elif args.check:
|
elif args.check:
|
||||||
check(args.server)
|
check(args.server)
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,43 @@
|
|||||||
templates:
|
templates:
|
||||||
|
0c94915edb4c41bf8c627dddb4f68f5a:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: app/opnsense_snmp/template_app_opnsense_snmp.yaml
|
||||||
|
13b06904a6bf41cbb795e3193d896340:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: os/windows_agent/template_os_windows_agent.yaml
|
||||||
|
16f281aeb8904d3db8b66dda94611fcc:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: app/pfsense_snmp/template_app_pfsense_snmp.yaml
|
||||||
|
4904f84303c74c5e955b7849730c3155:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: db/mysql_agent2/template_db_mysql_agent2.yaml
|
||||||
|
4958b76448d74ff1b6d7d6280449beee:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: app/proxmox/template_app_proxmox.yaml
|
||||||
4cb1aabe2b704b5c882963c2ef87d8f6:
|
4cb1aabe2b704b5c882963c2ef87d8f6:
|
||||||
vendor: Zabbix
|
vendor: Zabbix
|
||||||
path: net/generic_snmp_snmp/template_module_generic_snmp_snmp.yaml
|
path: net/generic_snmp_snmp/template_module_generic_snmp_snmp.yaml
|
||||||
5630ec1b1baf449abe1bc5521f85fe6c:
|
5630ec1b1baf449abe1bc5521f85fe6c:
|
||||||
vendor: Zabbix
|
vendor: Zabbix
|
||||||
path: app/certificate_agent2/template_app_certificate_agent2.yaml
|
path: app/certificate_agent2/template_app_certificate_agent2.yaml
|
||||||
|
5fdd2ca8b8f84962aaea5a218b46ea7d:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: os/windows_agent_active/template_os_windows_agent_active.yaml
|
||||||
|
67332e679035423f85090aa985947c36:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: net/generic_snmp/template_net_generic_snmp.yaml
|
||||||
6c235d126c1f4895acfe2156b140a886:
|
6c235d126c1f4895acfe2156b140a886:
|
||||||
vendor: Zabbix
|
vendor: Zabbix
|
||||||
path: net/ubiquiti_airos_snmp/template_net_ubiquiti_airos_snmp.yaml
|
path: net/ubiquiti_airos_snmp/template_net_ubiquiti_airos_snmp.yaml
|
||||||
|
90ac276995294a6aa88462c032d2ddaf:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: app/systemd/template_app_systemd.yaml
|
||||||
a3dc630729e443139f4e608954fa6e19:
|
a3dc630729e443139f4e608954fa6e19:
|
||||||
vendor: Zabbix
|
vendor: Zabbix
|
||||||
path: os/freebsd/template_os_freebsd.yaml
|
path: os/freebsd/template_os_freebsd.yaml
|
||||||
|
aa3ce9bd8c1d40a2b0f83f9e642e88ee:
|
||||||
|
vendor: Zabbix
|
||||||
|
path: net/cisco/cisco_snmp/template_net_cisco_snmp.yaml
|
||||||
d0ef7d659a8f4beaaabfc4b6134e737a:
|
d0ef7d659a8f4beaaabfc4b6134e737a:
|
||||||
vendor: Zabbix
|
vendor: Zabbix
|
||||||
path: db/postgresql_agent2/template_db_postgresql_agent2.yaml
|
path: db/postgresql_agent2/template_db_postgresql_agent2.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user