Hi,
I have worked out a way how to deploy Zabbix Agent on discovered hosts and wanted to share my idea. Of course this could also be done using Group Policies at least for Windows, but my solution is integrated with Zabbix. Please don't try this on a production network. Setup a small subnet for this and test carefully! You will need an administrator account on the windows machine. If you have a Windows Domain it's probably best to use an account with domain admin privileges. I don't know if you can setup an account under windows that is no administrator but can install software. If yes please let me know.
First my setup:
Zabbix 1.8.3 / MySQL / Ubuntu 10.04.4 LTS
Prerequisites:
General on Zabbix Server
Nmap - to detect / guess host operating system
Samba Server - to serve agent installer files to Windows clients
Windows Agent deployment
winexe - to run remote commands from Linux (Zabbix Server) on Windows clients
Administrator account on the machine where the agent will be deployed. This can be a Domain or Local Administrator Account.
1. Login or su to zabbix user on your zabbix server.
Create the following directories under the home of zabbix:
mkdir -p scripts/logs
mkdir agents
Download the attached deploy_agents.tar.gz to the zabbix server /home/zabbix/scripts and extract it.
Download the windows zabbix agent installer to the zabbix server /home/zabbix/agents. (http://www.google.de)
Download the winexe static binary to /home/zabbix/scripts and extract it:
wget http://eol.ovh.org/winexe/winexe-static-081123.bz2
bunzip winexe-static-081123.bz2
2. Add an entry to /etc/sudoers for zabbix in order to run deploy.sh as root
As user root on the zabbix server:
visudo
Now add the following lines:
Cmnd_Alias ZABBIX = /home/zabbix/scripts/deploy.sh, /usr/bin/nmap *
zabbix ALL = (ALL) NOPASSWD: ZABBIX (make sure this is the last line!)
3. Edit deploy_zabbag_windows.sh
The following lines need to edited:
ZABBIXSERVER=yourzabbiserver.domainname
DOMAINUSER=DOMAIN/Administrator
PASSWORD=yourpassword
if your are using a local admin account remove the DOMAIN in front!
4. Setup Samba Server
Install Samba Server via your OS package management system. Edit /etc/samba/smb.conf:
[zabbix]
comment = Zabbix Installer Share
read only = yes
locking = no
path = /home/zabbix/agents
guest ok = yes
browseable = yes
public = yes
Restart the samba server.
Test deploy.sh
Before configuring Zabbix to make use of the deploy.sh script I recommend to test it.
First, check if the sudo command is visible for the zabbix user:
sudo -l
The output should look similar to this:
zabbix@zabbix:~$ sudo -l
Matching Defaults entries for zabbix on this host:
env_reset
User zabbix may run the following commands on this host:
(ALL) NOPASSWD: /home/zabbix/scripts/deploy.sh, /usr/bin/nmap *
Now try to run the deploy command using sudo:
sudo /home/zabbix/scripts/deploy.sh hostname
The script will try to detect the OS running on 'hostname' and if it is Windows it will trigger the deploy_zabbag_windows.sh script to install the Zabbix Agent. The script will check if the credentials provided are sufficient if not it will exit with an error message indicating this. Once the script has finished verify that the zabbix agent has been installed on the target 'hostname'. If that is the case proceed to configure zabbix.
5. Create a discovery rule
Configuration --> Discovery
Name: Deploy testing
Checks: Zabbix agent "system.uname"
IP range: 192.168.0.1-254 (I recommend to test this on a small subnet first!!!)
6. Add a script
Administration --> Scripts
Name: Deploy Agent (or whatever you want)
Command: sudo /home/zabbix/scripts/deploy.sh {HOST.CONN}
7. Create Action Rule
Name=Host discovered, deploy agent (can be any name)
Discovery status = "Down"
Service type = "Zabbix agent"
Host IP = "192.168.0.1-254" (optional, to limit rule on specific subnet(s))
Run remote commands = Zabbix Server: sudo /home/zabbix/scripts/deploy.sh {DISCOVERY.DEVICE.IPADDRESS}
Send message to User "admin" (optional, for notification)
Make sure to use the correct name of your Zabbix Server. It's not the hostname it's the name of the Zabbix server in Zabbix!
I strongly recommend to test this on a small subnet before using in production. I cannot guarantee it will work, but I'm happy to help if it is not. It works fine in our environment and yes it saved me a lot of time. I'm currently extending the script to allow deploying on Linux and Solaris clients.
I have worked out a way how to deploy Zabbix Agent on discovered hosts and wanted to share my idea. Of course this could also be done using Group Policies at least for Windows, but my solution is integrated with Zabbix. Please don't try this on a production network. Setup a small subnet for this and test carefully! You will need an administrator account on the windows machine. If you have a Windows Domain it's probably best to use an account with domain admin privileges. I don't know if you can setup an account under windows that is no administrator but can install software. If yes please let me know.

First my setup:
Zabbix 1.8.3 / MySQL / Ubuntu 10.04.4 LTS
Prerequisites:
General on Zabbix Server
Nmap - to detect / guess host operating system
Samba Server - to serve agent installer files to Windows clients
Windows Agent deployment
winexe - to run remote commands from Linux (Zabbix Server) on Windows clients
Administrator account on the machine where the agent will be deployed. This can be a Domain or Local Administrator Account.
1. Login or su to zabbix user on your zabbix server.
Create the following directories under the home of zabbix:
mkdir -p scripts/logs
mkdir agents
Download the attached deploy_agents.tar.gz to the zabbix server /home/zabbix/scripts and extract it.
Download the windows zabbix agent installer to the zabbix server /home/zabbix/agents. (http://www.google.de)
Download the winexe static binary to /home/zabbix/scripts and extract it:
wget http://eol.ovh.org/winexe/winexe-static-081123.bz2
bunzip winexe-static-081123.bz2
2. Add an entry to /etc/sudoers for zabbix in order to run deploy.sh as root
As user root on the zabbix server:
visudo
Now add the following lines:
Cmnd_Alias ZABBIX = /home/zabbix/scripts/deploy.sh, /usr/bin/nmap *
zabbix ALL = (ALL) NOPASSWD: ZABBIX (make sure this is the last line!)
3. Edit deploy_zabbag_windows.sh
The following lines need to edited:
ZABBIXSERVER=yourzabbiserver.domainname
DOMAINUSER=DOMAIN/Administrator
PASSWORD=yourpassword
if your are using a local admin account remove the DOMAIN in front!
4. Setup Samba Server
Install Samba Server via your OS package management system. Edit /etc/samba/smb.conf:
[zabbix]
comment = Zabbix Installer Share
read only = yes
locking = no
path = /home/zabbix/agents
guest ok = yes
browseable = yes
public = yes
Restart the samba server.
Test deploy.sh
Before configuring Zabbix to make use of the deploy.sh script I recommend to test it.
First, check if the sudo command is visible for the zabbix user:
sudo -l
The output should look similar to this:
zabbix@zabbix:~$ sudo -l
Matching Defaults entries for zabbix on this host:
env_reset
User zabbix may run the following commands on this host:
(ALL) NOPASSWD: /home/zabbix/scripts/deploy.sh, /usr/bin/nmap *
Now try to run the deploy command using sudo:
sudo /home/zabbix/scripts/deploy.sh hostname
The script will try to detect the OS running on 'hostname' and if it is Windows it will trigger the deploy_zabbag_windows.sh script to install the Zabbix Agent. The script will check if the credentials provided are sufficient if not it will exit with an error message indicating this. Once the script has finished verify that the zabbix agent has been installed on the target 'hostname'. If that is the case proceed to configure zabbix.
5. Create a discovery rule
Configuration --> Discovery
Name: Deploy testing
Checks: Zabbix agent "system.uname"
IP range: 192.168.0.1-254 (I recommend to test this on a small subnet first!!!)
6. Add a script
Administration --> Scripts
Name: Deploy Agent (or whatever you want)
Command: sudo /home/zabbix/scripts/deploy.sh {HOST.CONN}
7. Create Action Rule
Name=Host discovered, deploy agent (can be any name)
Discovery status = "Down"
Service type = "Zabbix agent"
Host IP = "192.168.0.1-254" (optional, to limit rule on specific subnet(s))
Run remote commands = Zabbix Server: sudo /home/zabbix/scripts/deploy.sh {DISCOVERY.DEVICE.IPADDRESS}
Send message to User "admin" (optional, for notification)
Make sure to use the correct name of your Zabbix Server. It's not the hostname it's the name of the Zabbix server in Zabbix!
I strongly recommend to test this on a small subnet before using in production. I cannot guarantee it will work, but I'm happy to help if it is not. It works fine in our environment and yes it saved me a lot of time. I'm currently extending the script to allow deploying on Linux and Solaris clients.
Comment