Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

zabbix3.2-agent-Setup

最新確認
- http://www.zabbix.com/jp/download.php

  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とか超めんどくさそう。

nagamoo
最近はインフラとかミドルよりな感じ。 うまくツールを使いこなしたいっすわー KVSとかログのビジュアル化とかビッグデータ系とか。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした