Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
install_zabbix_agent_win
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rinat K. Nugaev
install_zabbix_agent_win
Commits
5447d0c6
Commit
5447d0c6
authored
Jun 09, 2018
by
Rinat K. Nugaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Try and Catch command for run agent and added chosing paltform
parent
1311e390
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
6 deletions
+64
-6
zabbix_install.ps1
+64
-6
No files found.
zabbix_install.ps1
View file @
5447d0c6
...
...
@@ -8,6 +8,28 @@
#
# CHANGELOG
# Version 0.3:
<#
.NAME
Zabbix Agent Install.
.SYNOPSIS
Installs Zabbix Agent Service and starts it.
.Descripton
This script downloading zabbix agent zip archive unzip this archive to the ProgramFiles folder
Script installs Zabbix Agent Service
This script install only 64 bit version
.Remarks
This can then be deployed via GPO or other means.
This coupled with a discovery rule in the Zabbix app will set the host up.
Ensure that you have set the configuration file correctly for your Zabbix setup BEFORE deploying.
.Author: Rinat K. Nugaev
.Date: 06/08/2018
#>
#Checking that script run with admin privilegies
...
...
@@ -37,7 +59,7 @@ Break
#Getting and defining some vars
$PathZabbix
=
${
env
:ProgramFiles
}
+
'\Zabbix'
#
$osarch = wmic os get OSArchitecture /value
$osarch
=
wmic os get OSArchitecture /value
$ZabbixConf
=
$PathZabbix
+
'\conf\zabbix_agentd.conf'
#Getting monitoring server ip for Firewall Rule
$monserverip
=
(
Test-Connection
-ComputerName monitoring.nugaev.net -count 1
)
.IPV4Address.ipaddressTOstring
...
...
@@ -83,12 +105,48 @@ HostMetadataItem=system.uname
#Adding content to the config file
Add-Content
-Value
"
$confcont
"
-Path
$ZabbixConf
#Installing zabbix agent as a service
New-Service
-Name
"Zabbix Agent"
-BinaryPathName
'"C:\Program Files\Zabbix\bin\win64\zabbix_agentd.exe" --config "C:\Program Files\Zabbix\conf\zabbix_agentd.conf"'
`
-DisplayName
"Zabbix Agent"
-Description
"Provides system monitoring"
-StartupType
"Automatic"
-ErrorAction SilentlyContinue
#Starting zabbix agent
Get-service
-name
"Zabbix Agent"
|
start-service
$osarch
=
wmic os get OSArchitecture /value
if
(
$osarch
-eq
"OSArchitecture=64-bit"
)
{
$osarch
=
'win64'
}
else
{
$osarch
=
'win32'
}
#Defining zabbix install command. It depends on $osarch variable
$ZabbixInstallCommand
=
"
`"
C:\Program Files\Zabbix\bin\
$osarch
\zabbix_agentd.exe
`"
--config
`"
C:\Program Files\Zabbix\conf\zabbix_agentd.conf
`"
"
Try
{
New-Service
-Name
"Zabbix Agent"
-BinaryPathName
$ZabbixInstallCommand
`
-DisplayName
"Zabbix Agent"
-Description
"Provides system monitoring"
-StartupType
"Automatic"
}
Catch
{
$ErrorMessage
=
$_
.Exception.Message
$FailedItem
=
$_
.Exception.ItemName
write-host
"Cannot Install Zabbix Service ((("
write-host
$ErrorMessage
Break
}
#Starting zabbix agent
Try
{
start-service
-name
"Zabbix Agent"
-ErrorAction Stop
}
Catch
{
$ErrorMessage
=
$_
.Exception.Message
$FailedItem
=
$_
.Exception.ItemName
write-host
"Cannot Start Zabbix Service ((("
write-host
$ErrorMessage
Break
}
#Dont remember why but entering to the temporary directory
cd
${
ENV
:temp
}
#Adding firewall rules for zabbix agent inbound for zabbix server and outbound for agent
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment