Hi,
there are several way´s to install the agent, but I did not found a
comfortable way to do it automatically really.
I have written a .vbs to make the procedure simple.
Off course there might be different needs somewhere else.
You need to have the script somewhere on the network and the zabbixw32.exe and the zabbix_agentd.conf in the same folder.
Plan for the future is, that I can schedule the agent udpate.
But at first I need some experience, if this script will do the job allways.
So if you notice some problems or need some additional features, that can be usefull for other zabbix users let me know.
( just copy starting form "option explicit" to the end of the post to a file InstallUpdateZabbixW32.VBS"
Off course whs must be installed on the machine, so in case you have some old WinNT you must install it before.
InstallUpdateZabbixW32.VBS
option explicit
'************************************************* *********************************
' Script to Install / Upgrade the ZabbixW32 agent for W2K,W2K3 UK/GER Version
' Gerald Rohrbach 29.05.2006 / Germany
'
' zabbixw32.exe and zabbix_agentd.conf must be in the same folder as this script
'************************************************* *********************************
'
'call: InstallUpdateZabbixW32.vbs
'Return: 0 = sucess
'----------------------------------------------------------------------------------
Dim objShell,objFso,objFi
Dim sSourcePath
Dim sSysRoot
Dim sProgramPath
Dim sIniFilePath
Dim ret
const cPROGRAM = "zabbixW32.exe"
const cINIFILE = "zabbix_agentd.conf"
const cSERVICE = "zabbixagentdW32"
const cPROGRAMPATH = "\SYSTEM32"
const cINIFILEPATH = "\SYSTEM32\DRIVERS\ETC"
Set objShell = WScript.CreateObject("WScript.Shell")
set objFso = CreateObject("Scripting.FileSystemObject")
sSourcePath = Left(wscript.Scriptfullname,Len(wscript.Scriptfull name)-len(wscript.scriptname))
GetEnvironment "SYSTEMROOT",sSysRoot
sProgramPath = sSysRoot & cPROGRAMPATH
sIniFilePath = sSysRoot & cINIFILEPATH
' Check the folder structure for the zabbixw32.exe
If not objFso.folderExists(sProgramPath) Then
wscript.quit(1)
end if
' Check the folder structur for the zabbix_agentd.conf"
If not objFso.folderExists(sIniFilePath) Then
wscript.quit(1)
end if
' Check if an update is necessary ZabbixW32
If objFso.fileexists(sProgramPath & "\" & cPROGRAM) Then
'Stop the service
ret = objShell.run ("CMD /C net stop " & cSERVICE ,2,TRUE)
'Do not check the result, maybe the agent is there but was not started
'Uninstall old version
ret = objShell.run ("CMD /C """ & sProgramPath & "\" & cPROGRAM & """ remove " ,2,TRUE)
'Ignore the ret code, just try to make sure that the agent is not anymore installed
end if
' Delete older version
objShell.run "CMD /C DEL """ & sProgramPath & "\" & cPROGRAM & "OLD""" ,2,TRUE
' Delete version, if possible
objShell.run "CMD /C DEL """ & sProgramPath & "\" & cPROGRAM & """" ,2,TRUE
' Rename the version ( delete does not work allways, because of open handles sometimes)
objShell.run "CMD /C REN """ & sProgramPath & "\" & cPROGRAM & """ """ & sProgramPath & "\" & cPROGRAM & "OLD""" ,2,TRUE
' copy the new version with fso, to have more control
if objFso.FileExists(sSourcePath & "\" & cPROGRAM) then
'copy the new exe
set objFi = objFso.GetFile(sSourcePath & "\" & cPROGRAM)
objFi.copy sProgramPath & "\" & cPROGRAM ,true
end if
' copy the new version with fso, to have more control
' if an agent_conf file is already there, do not overwrite
if NOT objFso.FileExists(sIniFilePath & "\" & cINIFILE) then
if objFso.FileExists(sSourcePath & "\" & cINIFILE) then
'copy the new confif file
set objFi = objFso.GetFile(sSourcePath & "\" & cINIFILE)
objFi.copy sIniFilePath & "\" & cINIFILE ,true
end if
end if
'Install now the new service version
ret = objShell.run ("""" & sProgramPath & "\" & cPROGRAM & """ --config """ & sIniFilePath & "\" & cINIFILE & """ install " ,2,TRUE)
if ret = 0 then
'Start now the zabbix service
ret = objShell.run ("CMD /C net start " & cSERVICE ,2,TRUE)
if ret = 0 then ' Services was started successfull
wscript.quit(0)
end if
end if
wscript.quit(1)
'----------------------------------------------------------------------------------------------------------------
' Function / Sub
'----------------------------------------------------------------------------------------------------------------
' GetEnvironment
Function GetEnvironment( sVarName, byRef sVar)
Dim WshShell
Dim objEnv
Set WSHShell = Wscript.CreateObject("Wscript.Shell")
Set objEnv = WshShell.Environment("Process")
sVar = objEnv(sVarName)
end Function
there are several way´s to install the agent, but I did not found a
comfortable way to do it automatically really.
I have written a .vbs to make the procedure simple.
Off course there might be different needs somewhere else.
You need to have the script somewhere on the network and the zabbixw32.exe and the zabbix_agentd.conf in the same folder.
Plan for the future is, that I can schedule the agent udpate.
But at first I need some experience, if this script will do the job allways.
So if you notice some problems or need some additional features, that can be usefull for other zabbix users let me know.
( just copy starting form "option explicit" to the end of the post to a file InstallUpdateZabbixW32.VBS"
Off course whs must be installed on the machine, so in case you have some old WinNT you must install it before.
InstallUpdateZabbixW32.VBS
option explicit
'************************************************* *********************************
' Script to Install / Upgrade the ZabbixW32 agent for W2K,W2K3 UK/GER Version
' Gerald Rohrbach 29.05.2006 / Germany
'
' zabbixw32.exe and zabbix_agentd.conf must be in the same folder as this script
'************************************************* *********************************
'
'call: InstallUpdateZabbixW32.vbs
'Return: 0 = sucess
'----------------------------------------------------------------------------------
Dim objShell,objFso,objFi
Dim sSourcePath
Dim sSysRoot
Dim sProgramPath
Dim sIniFilePath
Dim ret
const cPROGRAM = "zabbixW32.exe"
const cINIFILE = "zabbix_agentd.conf"
const cSERVICE = "zabbixagentdW32"
const cPROGRAMPATH = "\SYSTEM32"
const cINIFILEPATH = "\SYSTEM32\DRIVERS\ETC"
Set objShell = WScript.CreateObject("WScript.Shell")
set objFso = CreateObject("Scripting.FileSystemObject")
sSourcePath = Left(wscript.Scriptfullname,Len(wscript.Scriptfull name)-len(wscript.scriptname))
GetEnvironment "SYSTEMROOT",sSysRoot
sProgramPath = sSysRoot & cPROGRAMPATH
sIniFilePath = sSysRoot & cINIFILEPATH
' Check the folder structure for the zabbixw32.exe
If not objFso.folderExists(sProgramPath) Then
wscript.quit(1)
end if
' Check the folder structur for the zabbix_agentd.conf"
If not objFso.folderExists(sIniFilePath) Then
wscript.quit(1)
end if
' Check if an update is necessary ZabbixW32
If objFso.fileexists(sProgramPath & "\" & cPROGRAM) Then
'Stop the service
ret = objShell.run ("CMD /C net stop " & cSERVICE ,2,TRUE)
'Do not check the result, maybe the agent is there but was not started
'Uninstall old version
ret = objShell.run ("CMD /C """ & sProgramPath & "\" & cPROGRAM & """ remove " ,2,TRUE)
'Ignore the ret code, just try to make sure that the agent is not anymore installed
end if
' Delete older version
objShell.run "CMD /C DEL """ & sProgramPath & "\" & cPROGRAM & "OLD""" ,2,TRUE
' Delete version, if possible
objShell.run "CMD /C DEL """ & sProgramPath & "\" & cPROGRAM & """" ,2,TRUE
' Rename the version ( delete does not work allways, because of open handles sometimes)
objShell.run "CMD /C REN """ & sProgramPath & "\" & cPROGRAM & """ """ & sProgramPath & "\" & cPROGRAM & "OLD""" ,2,TRUE
' copy the new version with fso, to have more control
if objFso.FileExists(sSourcePath & "\" & cPROGRAM) then
'copy the new exe
set objFi = objFso.GetFile(sSourcePath & "\" & cPROGRAM)
objFi.copy sProgramPath & "\" & cPROGRAM ,true
end if
' copy the new version with fso, to have more control
' if an agent_conf file is already there, do not overwrite
if NOT objFso.FileExists(sIniFilePath & "\" & cINIFILE) then
if objFso.FileExists(sSourcePath & "\" & cINIFILE) then
'copy the new confif file
set objFi = objFso.GetFile(sSourcePath & "\" & cINIFILE)
objFi.copy sIniFilePath & "\" & cINIFILE ,true
end if
end if
'Install now the new service version
ret = objShell.run ("""" & sProgramPath & "\" & cPROGRAM & """ --config """ & sIniFilePath & "\" & cINIFILE & """ install " ,2,TRUE)
if ret = 0 then
'Start now the zabbix service
ret = objShell.run ("CMD /C net start " & cSERVICE ,2,TRUE)
if ret = 0 then ' Services was started successfull
wscript.quit(0)
end if
end if
wscript.quit(1)
'----------------------------------------------------------------------------------------------------------------
' Function / Sub
'----------------------------------------------------------------------------------------------------------------
' GetEnvironment
Function GetEnvironment( sVarName, byRef sVar)
Dim WshShell
Dim objEnv
Set WSHShell = Wscript.CreateObject("Wscript.Shell")
Set objEnv = WshShell.Environment("Process")
sVar = objEnv(sVarName)
end Function