Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt agent script to support zabbix_agent2 config #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions agent_scripts/apt_upgrade_agent_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
#

# Server configuration file route
AGENTD_CONF_FILE=/etc/zabbix/zabbix_agentd.conf
ZBX_CONFIG_FOLDER=/etc/zabbix/
ZBX_AGENT_CONF_FILE=$ZBX_CONFIG_FOLDER$(ls $ZBX_CONFIG_FOLDER | grep -E '^zabbix_agent[2d]\.conf$')

# Route for tmp file to store yum output
TEMP_ZBX_FILE=/tmp/zabbix_apt_check_output.tmp
echo -n "" > $TEMP_ZBX_FILE

# Check if Server IP/name is set in configuration file
ZBX_SERVER=$(egrep ^Server $AGENTD_CONF_FILE | cut -d = -f 2)
ZBX_SERVER=$(egrep ^Server $ZBX_AGENT_CONF_FILE | tail -n 1 | cut -d = -f 2)
if [ -z "$ZBX_SERVER" ]; then
echo "Server is not set in zabbix_agentd.conf file"
exit -1
echo "Server is not set in $ZBX_AGENT_CONF_FILE file"
exit -1
fi

# Get hostname
ZBX_HOSTNAMEITEM_PRESENT=$(egrep ^HostnameItem /etc/zabbix/zabbix_agentd.conf -c)
ZBX_HOSTNAMEITEM_PRESENT=$(egrep ^HostnameItem $ZBX_AGENT_CONF_FILE -c)
if [ "$ZBX_HOSTNAMEITEM_PRESENT" -ge "1" ]; then
ZBX_HOSTNAME=$(hostname)
ZBX_HOSTNAME=$(hostname)
else
ZBX_HOSTNAME=$(egrep ^Hostname /etc/zabbix/zabbix_agentd.conf | cut -d = -f 2)
ZBX_HOSTNAME=$(egrep ^Hostname $ZBX_AGENT_CONF_FILE | cut -d = -f 2)
fi

#######
Expand Down