Zabbix agent2
Jump to navigation
Jump to search
UserParameters
#Powershell test url
vim .\zabbix_agent2.win.conf
Windows
UserParameter=check.url.http_code[*],powershell.exe -NonInteractive -NoProfile -Command "try { ($rsp = Invoke-WebRequest $1 ).StatusCode } catch { $_.Exception.Response.StatusCode.Value__ } " UserParameter=check.url.time_total[*],powershell.exe -NonInteractive -NoProfile -Command "$url='$1'; (Measure-Command -Expression { $site = Invoke-WebRequest -Uri $url -UseBasicParsing }).Milliseconds"
Linux
UserParameter=check.url.http_code[*],curl -s -o /dev/null -w '%{http_code}' $1 UserParameter=check.url.time_total[*],curl -s -o /dev/null -w '%{time_total}' $1
restart-service -n "Zabbix Agent 2"
Test
.\zabbix_agent2.exe -t check.url.time_total[https://www.uvoo.io]
Add to template in gui and then assign same check name/key and use zabbix active agent
Test zabbix agent2 from agent host
Linux
cd /etc/zabbix/ zabbix_agent2 -t vm.memory.size[available]
cd /app/zabbix .\zabbix_agent2.exe -t system.run['powershell.exe -c "ls"'] .\zabbix_agent2.exe -t system.run['powershell.exe -NonInteractive -NoProfile -Command "ls"']
Windows
cd "C:\Program Files\Zabbix Agent 2\" ./zabbix_agent2.exe -t vm.memory.size[available]
From Server Passive
zabbix_get -s myhostoripaddr.example.com -p 10050 -k vm.memory.size[free] # Use psk or ca key for encrypted
One big line from anywhere
$tlsid = (Get-Content 'C:\Program Files\Zabbix Agent 2\zabbix_agent2.conf' | Select-String -Pattern '^TLSPSKIdentity=')[0].Line.split('=')[1]; & "C:\Program Files\Zabbix Agent 2\zabbix_agent2.exe" -t vm.memory.size[available] -c "C:\Program Files\Zabbix Agent 2\zabbix_agent2.conf" $conf="C:\Program Files\Zabbix Agent 2\zabbix_agent2.conf"; get-content $conf |select-string -pattern 'AllowKey' -notmatch
zabbix_agent2 -t system.run['ls -l /'] zabbix_get -s 127.0.0.1 -p 10050 -k system.run['/mon/checkip ping <host/ip>'] /app/zabbix/zabbix_agent2 -t "system.run[powershell.exe -command get-childitem]" -c .\zabbix_agent2.conf /app/zabbix/zabbix_agent2 -t "system.run[powershell.exe -command ls]" -c .\zabbix_agent2.conf ./zabbix_agent2.exe -t "get[url-response-latency https://www.google.com/]" -c .\zabbix_agent2.conf
UserParameter=jping[*],powershell.exe -NoProfile -ExecutionPolicy bypass -File C:\app\zabbix\get-monitor.ps1 $1 /app/zabbix/zabbix_agent2 -t "jping[return1]" -c .\zabbix_agent2.conf /app/zabbix/zabbix_agent2 -t "system.run[powershell.exe -command C:\app\zabbix\get.ps1 battery-status]" -c .\zabbix_agent2.conf
AllowKey=system.run[dir] /app/zabbix/zabbix_agent2 -t "system.run[dir]" -c .\zabbix_agent2.conf
update timeout for system.run commands in /etc/zabbix/zabbix_agent2.conf
Timeout=10
# Download and install Zabbix Agent $ErrorActionPreference = "Stop" cd C:\tmp\z $version = "5.0.5" $file = "zabbix_agent-$version-windows-amd64-openssl.msi" $file_sha256 = "4ee20029dacdbab91f0c0bf9d026a44286773c19878689d54f93cf287341e24e" $hostname = (hostname).ToLower() # https://www.zabbix.com/downloads/5.2.1/zabbix_agent2-5.2.1-windows-amd64-openssl.msi # https://www.zabbix.com/downloads/5.0.5/zabbix_agent2-5.0.5-windows-amd64-openssl.msi function uninstall { # This does not work properly, dang you windows # $description = wmic product get description | findstr -i zabbix # wmic product where "description='Zabbix Agent (64-bit)' " uninstall # zabbix_agentd.exe --uninstall # as admin msiexec /x $file # sc delete "Zabbix Agent" } function download { if( -Not(Test-Path "$file") ){ curl.exe -L -O https://www.zabbix.com/downloads/$version/$file } $get_file_hash = (Get-FileHash "$file").Hash.ToLower() if( -Not($get_file_hash -eq $file_sha256) ){ write-host "E: Invalid SHA256 file hash." mv -force "$file" "$file.badsha256" exit } } function install { $install_folder = "C:\app\zabbix"; msiexec /I zabbix_agent-5.0.5-windows-amd64-openssl.msi HOSTNAME=myhostname HOSTNAMEFQDN=1 SERVER=monitor-proxies.example.com SERVERACTIVE=monitor-proxies.example.com INSTALLFOLDER="$install_folder" SKIP=fw /qn } download install