From d83d9b3b4115b3ac66c977428dd9ab65b8b4d18e Mon Sep 17 00:00:00 2001 From: dotneft Date: Thu, 15 Dec 2022 13:37:39 +0900 Subject: [PATCH] Added MongoDB and PostgreSQL plugins for Windows agent 2 --- Dockerfiles/agent2/windows/Dockerfile | 12 ++++++---- .../build-mysql/windows/Dockerfile.agent2 | 22 ++++++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Dockerfiles/agent2/windows/Dockerfile b/Dockerfiles/agent2/windows/Dockerfile index 0b6703cca..d15950196 100644 --- a/Dockerfiles/agent2/windows/Dockerfile +++ b/Dockerfiles/agent2/windows/Dockerfile @@ -29,6 +29,10 @@ SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"] WORKDIR C:\zabbix\ COPY --from=builder ["C:\\zabbix2", "C:\\zabbix"] +COPY --from=builder ["C:\\mongodb_plugin\\zabbix-agent2-plugin-mongodb.exe", "C:\\zabbix\\zabbix-agent2-plugin\\zabbix-agent2-plugin-mongodb.exe"] +COPY --from=builder ["C:\\mongodb_plugin\\mongodb.conf", "C:\\zabbix\\conf\\zabbix_agentd.d\\mongodb.conf"] +COPY --from=builder ["C:\\postgresql_plugin\\zabbix-agent2-plugin-postgresql.exe", "C:\\zabbix\\zabbix-agent2-plugin\\zabbix-agent2-plugin-postgresql.exe"] +COPY --from=builder ["C:\\postgresql_plugin\\postgresql.conf", "C:\\zabbix\\conf\\zabbix_agentd.d\\postgresql.conf"] COPY [".\\docker-entrypoint.ps1", "C:\\zabbix"] USER ContainerAdministrator @@ -41,10 +45,10 @@ RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemD RUN Set-Location -Path $env:SystemDrive\.; ` ` - New-Item -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; ` - New-Item -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; ` - New-Item -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; ` - New-Item -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; ` ` net accounts /MaxPWAge:unlimited; ` net user /add zabbix /expire:never /passwordreq:no; ` diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 index 7c339df37..d54008bec 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 @@ -12,7 +12,9 @@ ARG MAJOR_VERSION=6.4 ARG ZBX_VERSION=${MAJOR_VERSION} ARG ZABBIX_VERSION_RC_NUM=2400 ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git -ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION +ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION ` + MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=master ` + POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=master LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" ` org.opencontainers.image.authors="Alexey Pustovalov " ` @@ -53,4 +55,22 @@ RUN Set-Location -Path $env:SystemDrive\.; ` ` Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix2\sbin; ` Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix2\conf; ` + ` + Set-Location -Path $env:SystemDrive; ` + Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); ` + git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mongodb_plugin; ` + Set-Location -Path $env:SystemDrive\mongodb_plugin; ` + mingw32-make; ` + mv $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe; ` + Write-Host 'Verifying build ("zabbix-agent2-plugin-mongodb.exe -V") ...'; ` + & $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; ` + ` + Set-Location -Path $env:SystemDrive; ` + Write-Host ('Building Zabbix PostgreSQL plugin {0} version ...' -f $env:POSTGRESQL_PLUGIN_VERSION); ` + git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\postgresql_plugin; ` + Set-Location -Path $env:SystemDrive\postgresql_plugin; ` + mingw32-make; ` + mv $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe; ` + Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; ` + & $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; ` Write-Host 'Zabbix binaries are compiled...';