I believe there are number of implementations of this, but I have developed my own that I would like to share. If you have any suggestions how to improve on it let me know.
This has been tested on Windows 2003/2008/2012
Script needs to be run from server you want to install agent. Running script following actions are performed:
#1 It detects version of Windows (32 or 64bit)
#2 Copy's over appropriate client
#3 Creates configuration file (You can adjust settings/variables in CONFIG_AGENT part of script)
#4 Installs agent
#5 Starts agent
This is how my \\HOSTNAME\zabbix$ share looks like (208 in this case is Zabbix agent version 2.0.8):
Zabbix 32 and 64bit directory, each contains all 3 files:
Script looks like this, you have to change HOSTNAME (Server that has fileshare) and ZABBIXSERVERIP (self-explanatory)
This has been tested on Windows 2003/2008/2012
Script needs to be run from server you want to install agent. Running script following actions are performed:
#1 It detects version of Windows (32 or 64bit)
#2 Copy's over appropriate client
#3 Creates configuration file (You can adjust settings/variables in CONFIG_AGENT part of script)
#4 Installs agent
#5 Starts agent
This is how my \\HOSTNAME\zabbix$ share looks like (208 in this case is Zabbix agent version 2.0.8):
09/11/2013 02:01 PM <DIR> 32bit_Agent_208
09/11/2013 02:01 PM <DIR> 64bit_Agent_208
09/11/2013 02:37 PM 1,413 install_zabbix.bat
1 File(s) 1,413 bytes
4 Dir(s) 465,082,687,488 bytes free
09/11/2013 02:01 PM <DIR> 64bit_Agent_208
09/11/2013 02:37 PM 1,413 install_zabbix.bat
1 File(s) 1,413 bytes
4 Dir(s) 465,082,687,488 bytes free
09/09/2013 05:48 AM 251,904 zabbix_agentd.exe
09/09/2013 05:48 AM 110,080 zabbix_get.exe
09/09/2013 05:48 AM 126,976 zabbix_sender.exe
3 File(s) 488,960 bytes
09/09/2013 05:48 AM 110,080 zabbix_get.exe
09/09/2013 05:48 AM 126,976 zabbix_sender.exe
3 File(s) 488,960 bytes
@echo off
echo Starting Zabbix agent installation and configuration script
:CheckOS
echo Detecting OS processor type
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
:64BIT
echo 64-bit system detected
net use y: "\\HOSTNAME\Zabbix$\64bit_Agent_208"
xcopy y:\ "C:\Program Files\Zabbix\" /y
net use /delete /y y:
GOTO CONFIG_AGENT
:32BIT
echo 32-bit system detected
net use y: "\\HOSTNAME\Zabbix$\32bit_Agent_208"
xcopy y:\ "C:\Program Files\Zabbix\" /y
net use /delete /y y:
GOTO CONFIG_AGENT
:CONFIG_AGENT
echo Configuring Zabbix agent
echo Server=ZABBIXSERVERIP > "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo Hostname=%COMPUTERNAME% >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo StartAgents=10 >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo ServerActive=ZABBIXSERVERIP >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo LogFile=C:\Program Files\Zabbix\zabbix_agentd.log >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo Timeout=5 >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
GOTO INSTALL_AGENT
:INSTALL_AGENT
echo Installing Zabbix agent service
cd c:\Program Files\Zabbix
zabbix_agentd.exe --config "C:\Program Files\Zabbix\zabbix_agentd.conf" --install
GOTO START_AGENT
:START_AGENT
echo Starting Zabbix agent
net start "Zabbix agent"
echo Starting Zabbix agent installation and configuration script - FINISHED
pause
echo Starting Zabbix agent installation and configuration script
:CheckOS
echo Detecting OS processor type
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)
:64BIT
echo 64-bit system detected
net use y: "\\HOSTNAME\Zabbix$\64bit_Agent_208"
xcopy y:\ "C:\Program Files\Zabbix\" /y
net use /delete /y y:
GOTO CONFIG_AGENT
:32BIT
echo 32-bit system detected
net use y: "\\HOSTNAME\Zabbix$\32bit_Agent_208"
xcopy y:\ "C:\Program Files\Zabbix\" /y
net use /delete /y y:
GOTO CONFIG_AGENT
:CONFIG_AGENT
echo Configuring Zabbix agent
echo Server=ZABBIXSERVERIP > "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo Hostname=%COMPUTERNAME% >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo StartAgents=10 >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo ServerActive=ZABBIXSERVERIP >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo LogFile=C:\Program Files\Zabbix\zabbix_agentd.log >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
echo Timeout=5 >> "C:\Program Files\Zabbix\zabbix_agentd.conf"
GOTO INSTALL_AGENT
:INSTALL_AGENT
echo Installing Zabbix agent service
cd c:\Program Files\Zabbix
zabbix_agentd.exe --config "C:\Program Files\Zabbix\zabbix_agentd.conf" --install
GOTO START_AGENT
:START_AGENT
echo Starting Zabbix agent
net start "Zabbix agent"
echo Starting Zabbix agent installation and configuration script - FINISHED
pause
Comment