Zabbix Agent for WAPT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.8 KiB

# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
variables = {
'zabbix_servers': [ '' ]
# Read local variables file if available
if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')):
print('Reading local encrypted variables file')
from cryptography.fernet import Fernet
import yaml
f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read())
props = {
def install():
version = control['version'].split('-',1)[0]
4 years ago
# Remove previous version from suiviperf, if present
print('Checking old Zabbix Agent version...')
old_agent = installed_softwares('{65BE9C8D-BE1D-4AEA-A144-9F52D57A3D12}')
for uninstall in old_agent:
if Version(uninstall['version'].split('.',1)[0]) < Version(version) :
if Version(uninstall['version']) < Version(version):
print('Uninstalling previous version %s' % uninstall['version'])
cmd = uninstall_cmd(uninstall['key'])
print('Installing Zabbix Agent version %s' % version)
if iswin64():
4 years ago
msi = 'zabbix_agent-%s-windows-amd64-openssl.msi' % version
4 years ago
msi = 'zabbix_agent-%s-windows-i386-openssl.msi' % version
4 years ago
print('Opening port 10050 in the firewall')
# Remove the previous rule if it existed. We don't mind the return code as the rule might not exist
run_notfatal('netsh advfirewall firewall del rule name="Zabbix Agent"')
4 years ago
# And add a new one
run('netsh advfirewall firewall add rule name="Zabbix Agent" dir=in action=allow protocol=TCP localport=10050 enable=yes remoteip=%s' % (','.join(variables['zabbix_servers'])))
# Copy conf, scripts and binaries
print('Copying additional configuration, scripts and binaries')
for dir in ['zabbix_agentd.conf.d','scripts','bin']:
mkdirs(makepath(programfiles,'Zabbix Agent',dir))
copytree2(dir,makepath(programfiles,'Zabbix Agent',dir))
# Restart the service
print('Restarting the service')
service_restart('Zabbix Agent')
def uninstall():
print('Removing firewall rule')
run_notfatal('netsh advfirewall firewall del rule name="Zabbix Agent"')
def update_package():
import requests, re
from waptpackage import PackageEntry
4 years ago
print('Checking latest agent version')
page = wgets('')
latest_version ='"latest":"(\d+(\.\d+)*)"', page).group(1)
pe = PackageEntry()
control = pe.load_control_from_wapt(os.getcwd())
4 years ago
current_version = control['version'].split('-',1)[0]
if Version(latest_version) > Version(current_version):
print('Updating package from %s to %s' % (current_version, latest_version))
for arch in ['amd64', 'i386']:
4 years ago
filename ='zabbix_agent-%s-windows-%s-openssl.msi' % (latest_version, arch)
4 years ago
if not isfile(filename):
url = '' % (latest_version, filename)
print('Downloading %s from %s' % (filename, url))
wget(url, filename)
for old in glob.glob(r'zabbix_agent-*-windows-%s-openssl.msi' % arch):
4 years ago
if not old == filename:
4 years ago
pe.version = latest_version + '-0'
pe.maturity = 'PREPROD'