Skip to content

Commit

Permalink
Added agent configuration collection to verify proper installation. (#…
Browse files Browse the repository at this point in the history
…378)

* Added collecting agent configuration to check correct installation

* Added condition to add variable to config of agent

* Fixed commit file
  • Loading branch information
kochetovd authored Dec 2, 2024
1 parent e42d391 commit 173a16c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Config struct {
GenerateConfigPeriod time.Duration `hcl:"interval_generate_config_seconds"`
QueryOptimizationPeriod time.Duration `hcl:"interval_query_optimization_seconds"`
QueryOptimizationCollectSqlTextPeriod time.Duration `hcl:"interval_query_optimization_collect_sqltext_seconds"`
MysqlPassword string `hcl:"mysql_password"`
MysqlPassword string `hcl:"mysql_password" json:"-"`
MysqlUser string `hcl:"mysql_user"`
MysqlHost string `hcl:"mysql_host"`
MysqlPort string `hcl:"mysql_port"`
Expand Down
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ printf "\033[37m\n * Saving variables to Releem Agent configuration\033[0m\n"

printf "\033[37m\n - Adding API key to the Releem Agent configuration: $CONF\n\033[0m"
echo "apikey=\"$apikey\"" | $sudo_cmd tee -a $CONF >/dev/null

printf "\033[37m - Adding Releem Configuration Directory $WORKDIR/conf to Releem Agent configuration: $CONF\n\033[0m"
echo "releem_cnf_dir=\"$WORKDIR/conf\"" | $sudo_cmd tee -a $CONF >/dev/null

if [ -d "$WORKDIR/conf" ]; then
printf "\033[37m - Adding Releem Configuration Directory $WORKDIR/conf to Releem Agent configuration: $CONF\n\033[0m"
echo "releem_cnf_dir=\"$WORKDIR/conf\"" | $sudo_cmd tee -a $CONF >/dev/null
fi
if [ -n "$MYSQL_LOGIN" ] && [ -n "$MYSQL_PASSWORD" ]; then
printf "\033[37m - Adding user and password mysql to the Releem Agent configuration: $CONF\n\033[0m"
echo "mysql_user=\"$MYSQL_LOGIN\"" | $sudo_cmd tee -a $CONF >/dev/null
Expand Down
1 change: 1 addition & 0 deletions metrics/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (Agent *AgentMetricsGatherer) GetMetrics(metrics *models.Metrics) error {
output["TotalAllocMemory"] = m.TotalAlloc

metrics.ReleemAgent.Info = output
metrics.ReleemAgent.Conf = *Agent.configuration

Agent.logger.Debug("CollectMetrics ", output)
return nil
Expand Down
3 changes: 3 additions & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package models
import (
"database/sql"
"sync"

"github.com/Releem/mysqlconfigurer/config"
)

type MetricType byte
Expand Down Expand Up @@ -44,6 +46,7 @@ type Metrics struct {
ReleemAgent struct {
Info MetricGroupValue
Tasks MetricGroupValue
Conf config.Config
}
}

Expand Down
1 change: 1 addition & 0 deletions mysqlconfigurer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ function releem_ps_mysql() {
then
printf "\n`date +%Y%m%d-%H:%M:%S`\033[31m The MySQL service failed to restart with error! Check the MySQL error log! \033[0m\n"
fi
$sudo_cmd /opt/releem/releem-agent -f
exit "${RESTART_CODE}"
}

Expand Down

0 comments on commit 173a16c

Please sign in to comment.