I just made a small script which helps me to install and upgrade zabbix agents on our servers.
It was written for DELL PowerEdge servers running CentOS 5.0 OS, but it works on other hard- and software (tested on Fedora Core) as well.
The script is configurable, so not-RedHat-based linux distros might also work.
Top features:
- compiles and installs the desired zabbix agent on the local system
- also installs required software like gcc via yum or apt
- installs the net-snmp and DELL OpenManage (Server Admin) software if desired
All of you who still are interested, here's the Script and further information:
- German Version: http://www.heiwu.de/myfiles/install_...603_release.sh
- English Version: http://www.heiwu.de/myfiles/install_...603_release.sh
I post this code because i want to share it with all who are interested.
Because it's poorly tested, please read through my code, evtl. run it and share your experience here! If i get enough feedback, i'll debug and improve the script.
Here is a detailed description what the script does:
1.) Configuration
The configuration is done in the first few lines of the script. Open it with your favourite Text editor, i suggest one with syntax highlighting, and view/change the variables as desired.
a) Files:
The script needs 3 files:
- The zabbix sources in tar.gz format (like zabbix-1.4.5.tar.gz)
- zabbix_agentd.conf file (this may already be modified (Server, UserParameter, ...) and will be copied into /etc/zabbix/ by the script)
- An initscript (will be copied into /etc/init.d/)
It doesn't matter where these files are, but i suggest to put them into the same directory where this script is.
If so, you may set "srcpath" to "here". The script will change it to its working directory then.
If you placed the files somewhere else, set "srcpath" to the path where the zabbix sources are located.
then set "cfgfile" and "initfile" so they match the location of the zabbix_agentd.conf and initscript. You may use "$srcpath" if the are located in the same directory as the sources are.
b) Zabbix Version to install:
set "version" to the Zabbix version you want to install. together with the content of "srcpath" the script makes the path- and filename for the sourcefile. If you set it to "latest", the script expects a file "zabbix-latest.tar.gz" which contains the sources. That file may be a symlink pointing to the source file.
c) Dependencies:
A fresh installed system doesn't always have a compiler installed. This script has 2 variables containing lists of all desired software packets. "deps" is for software that's installed if zabbix is installed without snmp, "deps_snmp" if it's installed with snmp and dell omsa. You may add all software packets you want to, never mind if needed for zabbix/gcc or other software.
d) Options for ./configure:
The content of this variables will be passed to the ./configure script.
e) snmpd.conf
It SNMP will be installed, this script needs to know where the snmpd.conf file will be, so it can modify the file with the Data needed for DELL OMSA. Default is for RedHat systems.
f) Packet Manager:
RedHat systems use yum to install needed packets. If you want to use this script on a debian based OS, set it to use APT. The Script will put the content of this variable together with the content of the $deps, so watch out that it fits. The Default values as example:
cmd_pktmgr="yum -y install"; and deps="gcc"
Line 103 in the script: "$cmd_pktmgr $deps_snmp" will result in:
"yum -y install gcc". Line 125: "$cmd_pktmgr srvadmin-base" -> "yum -y install srvadmin-base". last call is Line 133 "$cmd_pktmgr $deps".
2) Script
a) Preparing the script
First, the wildcards "here" and "scrpath" are checked and changed into usable values. srcpath becomes the absolute path of the script. WATCH OUT, DOESN'T WORK IF SCRIPT IS CALLED WITH ../ !!! Version becomes the zabbix version number of the release that is stored in the given tar.gz file.
b) unpacking sources
the sources are unpacked into the homedir of the currend user.
c) checking/preparing system
if cfgfile and initfile are readable, you will be asked if you want to install zabbix with or without snmp and dell omsa.
if snmp desired, the packets listed in deps_snmp are installed. Then each is checked via "rpm -q $packet-name". Option for dpkg is missing at the moment, maybe one can tell and test how you check the packets with dpkg? Then the SNMP Software and Dell OMSA packets are installed.
If no snmp is wished, only the software in deps is installed.
d) configure and install Zabbix Agent
Now the system should be ready to configure and install zabbix.
For both, logfiles are written and all output gets in there, so the screen keeps tidy. When the configuration is done, the tail of the log is displayed so you can check if everything was ok. after 10 seconds "./make install" is called.
e) System configuration
When Zabbix is installed, the user account "zabbix" is created if it doesn't already exist. Then then directories are created for log, config and PID-File and owned to zabbix.
Initscript and Configfile configured at the beginning of the script are copied into their proper locations. Does the path /etc/init.d/ work for debian systems, too?
Nest, chkconfig is told to run zabbix in level 3,4 and 5. here someone rumming debian might get problems. Solution is needed for debian systems...
Last step is to add zabbix port 10050 to /etc/services.
f) Testing and start
several tests are made and the server is started if all are ok.
That's it!
Please give me feedback about this script! I spent many hours on it, so i hope someon is interested in this...
We all know nobody's perfect, and more than ever software.
Here's the first known bug:
- Calling the Script relative, beginning with "../" doesn't work
Workaround: Please call it absolute (or relative begin path with "./")
Known Problems:
- Debian Users might run into trouble when installed packets are checked, as most systems don't have rmp installed...
It was written for DELL PowerEdge servers running CentOS 5.0 OS, but it works on other hard- and software (tested on Fedora Core) as well.
The script is configurable, so not-RedHat-based linux distros might also work.
Top features:
- compiles and installs the desired zabbix agent on the local system
- also installs required software like gcc via yum or apt
- installs the net-snmp and DELL OpenManage (Server Admin) software if desired
All of you who still are interested, here's the Script and further information:
- German Version: http://www.heiwu.de/myfiles/install_...603_release.sh
- English Version: http://www.heiwu.de/myfiles/install_...603_release.sh
I post this code because i want to share it with all who are interested.
Because it's poorly tested, please read through my code, evtl. run it and share your experience here! If i get enough feedback, i'll debug and improve the script.
Here is a detailed description what the script does:
1.) Configuration
The configuration is done in the first few lines of the script. Open it with your favourite Text editor, i suggest one with syntax highlighting, and view/change the variables as desired.
a) Files:
The script needs 3 files:
- The zabbix sources in tar.gz format (like zabbix-1.4.5.tar.gz)
- zabbix_agentd.conf file (this may already be modified (Server, UserParameter, ...) and will be copied into /etc/zabbix/ by the script)
- An initscript (will be copied into /etc/init.d/)
It doesn't matter where these files are, but i suggest to put them into the same directory where this script is.
If so, you may set "srcpath" to "here". The script will change it to its working directory then.
If you placed the files somewhere else, set "srcpath" to the path where the zabbix sources are located.
then set "cfgfile" and "initfile" so they match the location of the zabbix_agentd.conf and initscript. You may use "$srcpath" if the are located in the same directory as the sources are.
b) Zabbix Version to install:
set "version" to the Zabbix version you want to install. together with the content of "srcpath" the script makes the path- and filename for the sourcefile. If you set it to "latest", the script expects a file "zabbix-latest.tar.gz" which contains the sources. That file may be a symlink pointing to the source file.
c) Dependencies:
A fresh installed system doesn't always have a compiler installed. This script has 2 variables containing lists of all desired software packets. "deps" is for software that's installed if zabbix is installed without snmp, "deps_snmp" if it's installed with snmp and dell omsa. You may add all software packets you want to, never mind if needed for zabbix/gcc or other software.
d) Options for ./configure:
The content of this variables will be passed to the ./configure script.
e) snmpd.conf
It SNMP will be installed, this script needs to know where the snmpd.conf file will be, so it can modify the file with the Data needed for DELL OMSA. Default is for RedHat systems.
f) Packet Manager:
RedHat systems use yum to install needed packets. If you want to use this script on a debian based OS, set it to use APT. The Script will put the content of this variable together with the content of the $deps, so watch out that it fits. The Default values as example:
cmd_pktmgr="yum -y install"; and deps="gcc"
Line 103 in the script: "$cmd_pktmgr $deps_snmp" will result in:
"yum -y install gcc". Line 125: "$cmd_pktmgr srvadmin-base" -> "yum -y install srvadmin-base". last call is Line 133 "$cmd_pktmgr $deps".
2) Script
a) Preparing the script
First, the wildcards "here" and "scrpath" are checked and changed into usable values. srcpath becomes the absolute path of the script. WATCH OUT, DOESN'T WORK IF SCRIPT IS CALLED WITH ../ !!! Version becomes the zabbix version number of the release that is stored in the given tar.gz file.
b) unpacking sources
the sources are unpacked into the homedir of the currend user.
c) checking/preparing system
if cfgfile and initfile are readable, you will be asked if you want to install zabbix with or without snmp and dell omsa.
if snmp desired, the packets listed in deps_snmp are installed. Then each is checked via "rpm -q $packet-name". Option for dpkg is missing at the moment, maybe one can tell and test how you check the packets with dpkg? Then the SNMP Software and Dell OMSA packets are installed.
If no snmp is wished, only the software in deps is installed.
d) configure and install Zabbix Agent
Now the system should be ready to configure and install zabbix.
For both, logfiles are written and all output gets in there, so the screen keeps tidy. When the configuration is done, the tail of the log is displayed so you can check if everything was ok. after 10 seconds "./make install" is called.
e) System configuration
When Zabbix is installed, the user account "zabbix" is created if it doesn't already exist. Then then directories are created for log, config and PID-File and owned to zabbix.
Initscript and Configfile configured at the beginning of the script are copied into their proper locations. Does the path /etc/init.d/ work for debian systems, too?
Nest, chkconfig is told to run zabbix in level 3,4 and 5. here someone rumming debian might get problems. Solution is needed for debian systems...

Last step is to add zabbix port 10050 to /etc/services.
f) Testing and start
several tests are made and the server is started if all are ok.
That's it!

Please give me feedback about this script! I spent many hours on it, so i hope someon is interested in this...
We all know nobody's perfect, and more than ever software.
Here's the first known bug:
- Calling the Script relative, beginning with "../" doesn't work
Workaround: Please call it absolute (or relative begin path with "./")
Known Problems:
- Debian Users might run into trouble when installed packets are checked, as most systems don't have rmp installed...




Comment