|
|
|
@ -21,16 +21,31 @@ props = { |
|
|
|
|
|
|
|
|
|
def install(): |
|
|
|
|
version = control['version'].split('-',1)[0] |
|
|
|
|
print('Installing Zabbix Agent version ' + version) |
|
|
|
|
|
|
|
|
|
# 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): |
|
|
|
|
killalltasks(['zabbix_agentd.exe']) |
|
|
|
|
print('Uninstalling previous version %s' % uninstall['version']) |
|
|
|
|
cmd = uninstall_cmd(uninstall['key']) |
|
|
|
|
run_notfatal(cmd) |
|
|
|
|
|
|
|
|
|
print('Installing Zabbix Agent version %s' % version) |
|
|
|
|
|
|
|
|
|
if iswin64(): |
|
|
|
|
install_msi_if_needed('zabbix_agent-%s_x64.msi' % version,killbefore=['zabbix_agentd.exe'],properties=props,remove_old_version=True) |
|
|
|
|
msi = 'zabbix_agent-%s-win-amd64-openssl.msi' % version |
|
|
|
|
else: |
|
|
|
|
install_msi_if_needed('zabbix_agent-%s_x86.msi' % version,killbefore=['zabbix_agentd.exe'],properties=props,remove_old_version=True) |
|
|
|
|
msi = 'zabbix_agent-%s-win-i386-openssl.msi' % version |
|
|
|
|
|
|
|
|
|
install_msi_if_needed(msi,killbefore=['zabbix_agentd.exe'],properties=props,remove_old_version=True) |
|
|
|
|
|
|
|
|
|
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"') |
|
|
|
|
|
|
|
|
|
# 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']))) |
|
|
|
|
|
|
|
|
@ -41,22 +56,26 @@ def uninstall(): |
|
|
|
|
def update_package(): |
|
|
|
|
import requests, re |
|
|
|
|
from waptpackage import PackageEntry |
|
|
|
|
print('Updating Zabbix Agent package') |
|
|
|
|
page = requests.get('https://www.suiviperf.com/zabbix/',headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'}).text |
|
|
|
|
version = re.search('zabbix_agent-(\d+(\.\d+)*)_x64.msi', page).group(1) |
|
|
|
|
for arch in ['86', '64']: |
|
|
|
|
if not isfile('zabbix_agent-%s_x%s.msi' % (version, arch)): |
|
|
|
|
filename ='zabbix_agent-%s_x%s.msi' % (version, arch) |
|
|
|
|
url = 'http://www.suiviperf.com/zabbix/%s' % filename |
|
|
|
|
print('Downloading %s from %s' % (filename, url)) |
|
|
|
|
wget(url, filename) |
|
|
|
|
for old in glob.glob(r'zabbix_agent-*_x%s' % arch): |
|
|
|
|
if not old == filename: |
|
|
|
|
remove_file(old) |
|
|
|
|
|
|
|
|
|
print('Checking latest agent version') |
|
|
|
|
page = wgets('https://www.zabbix.com/download') |
|
|
|
|
latest_version = re.search('"latest":"(\d+(\.\d+)*)"', page).group(1) |
|
|
|
|
pe = PackageEntry() |
|
|
|
|
control = pe.load_control_from_wapt(os.getcwd()) |
|
|
|
|
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']: |
|
|
|
|
filename ='zabbix_agent-%s-win-%s-openssl.msi' % (latest_version, arch) |
|
|
|
|
if not isfile(filename): |
|
|
|
|
url = 'https://www.zabbix.com/downloads/%s/%s' % (latest_version, filename) |
|
|
|
|
print('Downloading %s from %s' % (filename, url)) |
|
|
|
|
wget(url, filename) |
|
|
|
|
for old in glob.glob(r'zabbix_agent-*-win-%s-openssl.msi' % arch): |
|
|
|
|
if not old == filename: |
|
|
|
|
remove_file(old) |
|
|
|
|
|
|
|
|
|
if Version(version) > Version(control['version'].split('-',1)[0]): |
|
|
|
|
pe.version = version + '-0' |
|
|
|
|
pe.version = latest_version + '-0' |
|
|
|
|
pe.maturity = 'PREPROD' |
|
|
|
|
pe.save_control_to_wapt(os.getcwd()) |
|
|
|
|