Automatic db file name for SQLite3 base proxy

This commit is contained in:
Alexey Pustovalov 2023-01-16 17:01:06 +09:00
parent eac4a90f46
commit a706601495
6 changed files with 36 additions and 5 deletions

View File

@ -137,7 +137,13 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
update_config_var $ZBX_CONFIG "DBHost"
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
: ${ZBX_USE_NODE_NAME_AS_DB_NAME:="false"}
if [ "${ZBX_USE_NODE_NAME_AS_DB_NAME,,}" == "false" ]; then
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
else
node_name=$(uname -n)
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/$node_name.sqlite"
fi
update_config_var $ZBX_CONFIG "DBUser"
update_config_var $ZBX_CONFIG "DBPort"
update_config_var $ZBX_CONFIG "DBPassword"

View File

@ -137,7 +137,13 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
update_config_var $ZBX_CONFIG "DBHost"
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
: ${ZBX_USE_NODE_NAME_AS_DB_NAME:="false"}
if [ "${ZBX_USE_NODE_NAME_AS_DB_NAME,,}" == "false" ]; then
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
else
node_name=$(uname -n)
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/$node_name.sqlite"
fi
update_config_var $ZBX_CONFIG "DBUser"
update_config_var $ZBX_CONFIG "DBPort"
update_config_var $ZBX_CONFIG "DBPassword"

View File

@ -137,7 +137,13 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
update_config_var $ZBX_CONFIG "DBHost"
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
: ${ZBX_USE_NODE_NAME_AS_DB_NAME:="false"}
if [ "${ZBX_USE_NODE_NAME_AS_DB_NAME,,}" == "false" ]; then
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
else
node_name=$(uname -n)
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/$node_name.sqlite"
fi
update_config_var $ZBX_CONFIG "DBUser"
update_config_var $ZBX_CONFIG "DBPort"
update_config_var $ZBX_CONFIG "DBPassword"

View File

@ -137,7 +137,13 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
update_config_var $ZBX_CONFIG "DBHost"
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
: ${ZBX_USE_NODE_NAME_AS_DB_NAME:="false"}
if [ "${ZBX_USE_NODE_NAME_AS_DB_NAME,,}" == "false" ]; then
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
else
node_name=$(uname -n)
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/$node_name.sqlite"
fi
update_config_var $ZBX_CONFIG "DBUser"
update_config_var $ZBX_CONFIG "DBPort"
update_config_var $ZBX_CONFIG "DBPassword"

View File

@ -137,7 +137,13 @@ update_zbx_config() {
update_config_var $ZBX_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
update_config_var $ZBX_CONFIG "DBHost"
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
: ${ZBX_USE_NODE_NAME_AS_DB_NAME:="false"}
if [ "${ZBX_USE_NODE_NAME_AS_DB_NAME,,}" == "false" ]; then
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/${ZBX_HOSTNAME:-"zabbix-proxy-sqlite3"}.sqlite"
else
node_name=$(uname -n)
update_config_var $ZBX_CONFIG "DBName" "/var/lib/zabbix/db_data/$node_name.sqlite"
fi
update_config_var $ZBX_CONFIG "DBUser"
update_config_var $ZBX_CONFIG "DBPort"
update_config_var $ZBX_CONFIG "DBPassword"

View File

@ -2,6 +2,7 @@
# ZBX_SERVER_HOST=zabbix-server
# ZBX_SERVER_PORT=10051 # Deprecated since 6.0.0
# ZBX_HOSTNAME=zabbix-proxy-$db_type
# ZBX_USE_NODE_NAME_AS_DB_NAME=false
# ZBX_ENABLEREMOTECOMMANDS=0 # Available since 3.4.0
# ZBX_LOGREMOTECOMMANDS=0 # Available since 3.4.0
# ZBX_HOSTNAMEITEM=system.hostname