We had the need to create a batch file for installing the agent that would populate the Hostanme= field in all lower case, regardless of how it was cased for computername.
This was important since active checks require an exact match for hostname.
This batch file will also copy the install media from a centralized location (change the paths!), install the service, start the service and also create the list of performance counters placing that in the C:\zabbix\ directory.
Also note that this batch file will place the zabbix_agentd.conf file into the C:\zabbix\ directory instead of the default of going into the root of C.
Also note that the zabbix_agentd.conf file must have the last line as Hostname= with no carriage return at the end or it will put the hostname on the next line.
We use a basic conf file similar to this:
This was important since active checks require an exact match for hostname.
This batch file will also copy the install media from a centralized location (change the paths!), install the service, start the service and also create the list of performance counters placing that in the C:\zabbix\ directory.
Also note that this batch file will place the zabbix_agentd.conf file into the C:\zabbix\ directory instead of the default of going into the root of C.
Also note that the zabbix_agentd.conf file must have the last line as Hostname= with no carriage return at the end or it will put the hostname on the next line.
We use a basic conf file similar to this:
Code:
Server=<Zabbix server IP> LogFile=c:\zabbix\zabbix_agentd.log DebugLevel=3 Hostname=
Code:
=============== Zabbix Agent install ================== @echo off date /t time /t @echo ---------------------------- @echo Starting Zabbix Installation @echo ---------------------------- C: md c:\zabbix copy \\servername\Zabbix_Install_media\agent167\zabbix_agentd.conf c:\zabbix copy \\servername\Zabbix_Install_media\agent167\*.exe c:\zabbix SETLOCAL ENABLEDELAYEDEXPANSION CALL :LoCase computername set computername ECHO %computername% >> c:\zabbix\zabbix_agentd.conf ENDLOCAL GOTO:EOF :LoCase :: Subroutine to convert a variable VALUE to all lower case. :: The argument for this subroutine is the variable NAME. SET %~1=!%1:A=a! SET %~1=!%1:B=b! SET %~1=!%1:C=c! SET %~1=!%1:D=d! SET %~1=!%1:E=e! SET %~1=!%1:F=f! SET %~1=!%1:G=g! SET %~1=!%1:H=h! SET %~1=!%1:I=i! SET %~1=!%1:J=j! SET %~1=!%1:K=k! SET %~1=!%1:L=l! SET %~1=!%1:M=m! SET %~1=!%1:N=n! SET %~1=!%1:O=o! SET %~1=!%1:P=p! SET %~1=!%1:Q=q! SET %~1=!%1:R=r! SET %~1=!%1:S=s! SET %~1=!%1:T=t! SET %~1=!%1:U=u! SET %~1=!%1:V=v! SET %~1=!%1:W=w! SET %~1=!%1:X=x! SET %~1=!%1:Y=y! SET %~1=!%1:Z=z! :EOF c:\zabbix\zabbix_agentd –i --install -c c:\zabbix\zabbix_agentd.conf @echo ------------------- @echo Zabbix Installed @echo ------------------- @echo Starting Zabbix Service @echo ------------------- c:\zabbix\zabbix_agentd –s -c c:\zabbix\zabbix_agentd.conf @echo ------------------- @echo Service Started... @echo ------------------- @echo Running Typeperf... @echo ------------------- typeperf -qx > c:\zabbix\%computername%PERF.txt cd\ date /t time /t @echo ---- EOF ---------- =================================