Jul-25-2021, 03:52 AM
Hi,
I am completely new to the python world so please bear with me, I am hoping someone can help me understand something.
I am currently trying to interact with an API using a python script. The API is for the Zabbix 5.0 application on RHEL 7.9. The goal is to use the python script to add / remove / modify hosts and items to Zabbix. There are a number of different scripts that can achieve this, both on Git and via Zabbix sources.
The issue is the RHEL server is on a closed network, which means no internet connection.
My question is, on a closed off network, how does the 'import' function of the script work ?
so for example:
Would i need to download all the modules and place them in a specific folder ?
As advised, i am new to this world so please don't hesitate to give me the idiot's guide version!
Any help will be much appreciated :)
Thanks in advance
I am completely new to the python world so please bear with me, I am hoping someone can help me understand something.
I am currently trying to interact with an API using a python script. The API is for the Zabbix 5.0 application on RHEL 7.9. The goal is to use the python script to add / remove / modify hosts and items to Zabbix. There are a number of different scripts that can achieve this, both on Git and via Zabbix sources.
The issue is the RHEL server is on a closed network, which means no internet connection.
My question is, on a closed off network, how does the 'import' function of the script work ?
so for example:
#!/usr/bin/env python # -*- coding: utf-8 -*- from pyzabbix import ZabbixAPI import csv from progressbar import ProgressBar, Percentage, ETA, ReverseBar, RotatingMarker, Timer zapi = ZabbixAPI("http://localhost/zabbix") zapi.login(user="Admin", password="zabbix") arq = csv.reader(open('/tmp/hosts.csv')) linhas = sum(1 for linha in arq) f = csv.reader(open('/tmp/hosts.csv'), delimiter=';') bar = ProgressBar(maxval=linhas,widgets=[Percentage(), ReverseBar(), ETA(), RotatingMarker(), Timer()]).start() i = 0 for [hostname,ip] in f: hostcriado = zapi.host.create( host= hostname, status= 1, interfaces=[{ "type": 1, "main": "1", "useip": 1, "ip": ip, "dns": "", "port": 10050 }], groups=[{ "groupid": 2 }], templates=[{ "templateid": 10001 }] ) i += 1 bar.update(i) bar.finish print " "In the above script, how does the following work offline:
Quote:from pyzabbix import ZabbixAPI
from progressbar import ProgressBar, Percentage, ETA, ReverseBar, RotatingMarker, Timer
Would i need to download all the modules and place them in a specific folder ?
As advised, i am new to this world so please don't hesitate to give me the idiot's guide version!
Any help will be much appreciated :)
Thanks in advance
