[ZBXNEXT-3110] Updated freebsd RC script from zabbix agent Created: 2016 Jan 22  Updated: 2016 Jan 25

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G)
Affects Version/s: 2.4.7
Fix Version/s: None

Type: Change Request Priority: Trivial
Reporter: chris scott Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: freebsd, init.d, rc.d, startup
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

freebsd systems


Attachments: File zabbix_freebsd_rcd.tgz    

 Description   

Two issues

1. Currently the freebsd rc.d script to start the agent has the config file hardwired in. This is not ideal as when you are managing a heterogeneous enviroment you have to remember where the config file its stored on that particular OS. It would be nice to have a fixed location common to all unix OS's. eg /opt/zabbix/etc/agentd.conf or similar. There is no way to do this on freebsd without hacking the startup script. Linux you can through /etc/sysconfig

2. There is no ability to run a pre script before the agent is started. On RHEL linux you can do this easily with the /etc/sysconfig stuff. It is useful to be able to this as you can standardize the format of things like hostname or programatically determine things like bind interfaces. Therefore please considers the following replacement to the freebsd rc.d script.

Default operation shouldn't be altered. However if you define

#!/bin/sh

# PROVIDE: zabbix_agentd
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to
# enable zabbix_agentd:
#
# zabbix_agentd_enable (bool): Set to NO by default.  Set it to YES to
#         enable zabbix_agentd.
#


. /etc/rc.subr

name="zabbix_agentd"
rcvar=zabbix_agentd_enable
start_precmd="zabbix_precmd"
required_files="/usr/local/etc/zabbix24/zabbix_agentd.conf"


# read configuration and set defaultsc
load_rc_config "$name"
: ${zabbix_agentd_enable="NO"}
#: ${zabbix_agentd_pre:=/usr/local/etc/zabbix24/${name}.pre.sh}


if [ ! -z "$zabbix_agentd_conf" ] ; then
        zabbix_agentd_flags="${zabbix_agentd_flags} -c ${zabbix_agentd_conf}"
        required_files=${zabbix_agentd_conf}
fi

zabbix_precmd()
{
        if [ ! -z "$zabbix_agentd_pre" ] ; then
                if [ -e $zabbix_agentd_pre ] ; then
                        . $zabbix_agentd_pre
                fi
        fi

}


command="/usr/local/sbin/${name}"


run_rc_command "$1"

here is the diff

# diff zabbix_agentd zabbix_agentd.old
13a14
>
17a19,20
> start_precmd="zabbix_precmd"
> required_files="/usr/local/etc/zabbix24/zabbix_agentd.conf"
19,22d21
< command="/usr/local/sbin/${name}"
< required_files="/usr/local/etc/zabbix24/${name}.conf"
<
< load_rc_config $name
23a23,24
> # read configuration and set defaultsc
> load_rc_config "$name"
24a26,46
> #: ${zabbix_agentd_pre:=/usr/local/etc/zabbix24/${name}.pre.sh}
>
>
> if [ ! -z "$zabbix_agentd_conf" ] ; then
>       zabbix_agentd_flags="${zabbix_agentd_flags} -c ${zabbix_agentd_conf}"
>       required_files=${zabbix_agentd_conf}
> fi
>
> zabbix_precmd()
> {
>       if [ ! -z "$zabbix_agentd_pre" ] ; then
>               if [ -e $zabbix_agentd_pre ] ; then
>                       . $zabbix_agentd_pre
>               fi
>       fi
>
> }
>
>
> command="/usr/local/sbin/${name}"
>
26a49
>


 Comments   
Comment by chris scott [ 2016 Jan 22 ]

Sorry forgot to say all the user has to do is define these two variables in their rc.conf files

zabbix_agentd_pre=<location of pre script>
zabbix_agentd_conf=<location_of_config>

not setting them results in standard behaviour

Comment by chris scott [ 2016 Jan 22 ]

files also attached

Generated at Sun Dec 14 00:05:43 EET 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.