This was developed and tested with Zabbix 1.1beta9 on Fedora Core 4 but may be more widely applicable. Feedback appreciated.
Four instances of this type of script have been posted or linked here -- in June 2005 (www.zabbix.com/forum/showthread.php?t=2577), August 2005 (2 instances, www.zabbix.com/forum/showthread.php?t=2269) and October 2005 (www.zabbix.com/forum/showthread.php?t=1996).
So why another? I studied the earlier scripts and the script from the Zabbix 1.1beta9 distribution. A simpler and more powerful script could be created by making greater use of standard tools.
FYI the "standard tools" are:
Important features of these sample scripts are:
To install the attached zabbix_server_script.txt ...
Four instances of this type of script have been posted or linked here -- in June 2005 (www.zabbix.com/forum/showthread.php?t=2577), August 2005 (2 instances, www.zabbix.com/forum/showthread.php?t=2269) and October 2005 (www.zabbix.com/forum/showthread.php?t=1996).
So why another? I studied the earlier scripts and the script from the Zabbix 1.1beta9 distribution. A simpler and more powerful script could be created by making greater use of standard tools.
FYI the "standard tools" are:
- chkconfig (8)
- functions defined in /etc/rc.d/init.d/functions. For further information on these functions see the functions file itself (reverse engineering never fails!)and usage examples in the attached script zabbix_server_script.txt
- sample scripts. The best sample scripts I found (and they seem to be based on a single source script) were at https://www.linux.org/docs/ldp/howto...HOWTO/boot.htm and http://yolinux.com/TUTORIALS/LinuxTu...itProcess.html
Important features of these sample scripts are:
- they provide more than just start and stop facilities: restart, reload (send HUP), condrestart (but the coding for this seems incomplete) and status
- they have their own configuration files in /etc/sysconfig/
- any process ID (PID) file written by the service must be /var/run/<base>.pid where <base> is the basename of the executable. For example, for Zabbix Server the executable is /usr/local/bin/zabbix_server so the PID file is /var/run/zabbix_server.pid. This creates a permissions problem if the service is not run as root becaue the /var/run/ directory is only writeable by root. The solution is to make /var/run/<base>.pid a symlink to a file that is writeable by the running service. Using the same example /var/run/zabbix_server.pid is created as a symlink to /tmp/zabbix_server.pid.
To install the attached zabbix_server_script.txt ...
- save it as /etc/rc.d/init.d/zabbix_server with conventional permissions (owner:root, group:root, 755). If this seems strange, bear in mind that /etc/init.d is a symlink to /etc/rc.d/init.d/
- Review the run levels in the line "# chkconfig: 2345 95 05" and change as necessary (these levels are taken from the boot/shutdown script from the distribution, zabbix-1.1beta9/misc/init.d/redhat/8.0/zabbix_suckerd)
- Execute command: chkconfig --add zabbix_server
- Check your Zabbix Server config file, by default /etc/zabbix/zabbix_server.conf and note the value of PidFile, by default /var/tmp/zabbix_server.pid
- Execute command (changing the PidFile value if necessary): ln -s /var/tmp/zabbix_server.pid /var/run/zabbix_server.pid
- Create the configuration file for the script, /etc/sysconfig/zabbix_server (owner:root, group:root, 644). This file is run with root privileges during boot and shutdown so should only be writable by root. Use the attached zabbix_server_script_conf.txt as a template, changing paths and Zabbix owning (runas) id to suit your installation.