2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

zabbix agentをwindowsにサクッと入れるshell メモ

Posted at

zabbix3.2-agent-Setup

最新確認

  1. ここから対象のDLを確認
    1. Windows全般
      1. http://www.zabbix.com/downloads/3.2.0/zabbix_agents_3.2.0.win.zip

このshellの手順

  1. \c直下に/zabbix-agent ディレクトリを作る
  2. 作成したディレクトリに、64bitのbinを配置する。
  3. 同じ場所にzabbix_agentd.confを配置し、環境に合わせて内容を編集する。
  4. 管理者権限でコマンドプロンプトを起動する。

以下powershellで上記手順の実行

IPにとか適宜書換

mkdir C:\zabbix_agent
invoke-webrequest -uri http://www.zabbix.com/downloads/3.2.0/zabbix_agents_3.2.0.win.zip -outfile C:\zabbix_agent\zabbix_agents_3.2.0.win.zip

# ZIP 解凍
# Powershell V5以降なら以下でできるはずなのだが・・
#expand-archive -path C:\zabbix_agent\zabbix_agents_3.2.0.win.zip -destinationpath C:\zabbix_agent\

$file = "C:\zabbix_agent\zabbix_agents_3.2.0.win.zip"
$shell = New-Object -ComObject shell.application
$zip = $shell.NameSpace($file)
$dest =  $shell.NameSpace((Split-Path $file -Parent))
$dest.CopyHere($zip.Items())

# exeとconf配置
Copy-Item C:\zabbix_agent\bin\win64\*.exe C:\zabbix_agent\
Copy-Item C:\zabbix_agent\conf\zabbix_agentd.win.conf C:\zabbix_agent\
Rename-Item C:\zabbix_agent\zabbix_agentd.win.conf  zabbix_agentd.conf 

Remove-Item C:\zabbix_agent\zabbix_agents_3.2.0.win.zip


# Fileの書換
$conf= Get-Content C:\zabbix_agent\zabbix_agentd.conf -Encoding UTF8
$conf= $conf.Replace("LogFile=c:\zabbix_agentd.log", "LogFile=c:\zabbix_agent\zabbix_agentd.log")
$conf= $conf.Replace("Server=127.0.0.1", "Server=192.168.X.XXX")
$conf= $conf.Replace("ServerActive=127.0.0.1", "ServerActive=192.168.X.XXX:10051")
$conf= $conf.Replace("Hostname=Windows host", "Hostname=${Env:COMPUTERNAME}")
#$conf= $conf.Replace("# HostnameItem=system.hostname", "HostnameItem=system.hostname")
$conf= $conf.Replace("# HostMetadata=", "HostMetadata=")


#$conf= $conf.Replace("", "")
#$conf | Out-file C:\zabbix_agent\zabbix_agentd.conf -Encoding UTF8 これだとUTFがうまくいかね。
[IO.File]::WriteAllLines("C:\zabbix_agent\zabbix_agentd.conf", $conf)

# Agent Install サービス登録 作成したディレクトリに移動し、以下のコマンドを入力する。
cd  C:\zabbix_agent
.\zabbix_agentd.exe -i -c C:\zabbix_agent\zabbix_agentd.conf

# サービス開始
.\zabbix_agentd.exe -s -c zabbix_agentd.conf

# サービス削除
# .\zabbix_agentd.exe -d

firewall開ける

IPにとか適宜書換

if (-not(Get-NetFirewallRule | where Name -eq "Zabbix Agent"))
{
    New-NetFirewallRule `
        -Name "Zabbix Agent" `
        -DisplayName "Zabbix Agent" `
        -Description "for Zabbix Agent" `
        -Group "Zabbix" `
        -Enabled True `
        -Profile Any `
        -Direction Inbound `
        -Action Allow `
        -EdgeTraversalPolicy Block `
        -LooseSourceMapping $False `
        -LocalOnlyMapping $False `
        -OverrideBlockRules $False `
        -Program Any `
        -LocalAddress Any `
        -RemoteAddress 192.168.16.0/24 `
        -Protocol TCP `
        -LocalPort 10050 `
        -RemotePort Any `
        -LocalUser Any `
        -RemoteUser Any
    
}
else
{
		echo "Windows PowerShell Remoting port TCP 10050 was alredy opend. Show Rule"
		Get-NetFirewallPortFilter -Protocol TCP | where Localport -eq 10050
}

powershell痒い所に微妙に手が届かない・・
Uninstallとか超めんどくさそう。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?