-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add rpm server support #3
Draft
stefanotorresi
wants to merge
6
commits into
main
Choose a base branch
from
add-rpm-server-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
311043f
Initial rewrite
Thr3d 5b2cfa1
add checks for systemd trento server
Thr3d 2e9326f
Update trento
Thr3d b680409
Merge pull request #2 from Thr3d/main
stefanotorresi 11a76aa
preserve old name as an alias and keep soft dependencies for the k8s …
stefanotorresi e9b6e82
rename package in the ci workflow
stefanotorresi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
#!/bin/bash | ||
############################################################# | ||
# Name: Supportconfig Plugin for SUSE Trento | ||
# Description: Gathers important troubleshooting information | ||
# about a SUSE Trento SAP console | ||
# License: GPLv2 | ||
############################################################# | ||
|
||
SVER='1.0.0' | ||
TITLE="Trento" | ||
|
||
|
||
### Check if executed by supportconfig ### | ||
PP_COMM="$(cat /proc/$(grep -i ppid /proc/$$/status | awk '{print $2}')/comm)" | ||
if [[ $PP_COMM == "supportconfig" ]]; then | ||
RCFILE="/usr/lib/supportconfig/resources/supportconfig.rc" | ||
OF=plugin-trento.txt | ||
[ -s $RCFILE ] && . $RCFILE || { echo "ERROR: Initializing resource file: $RCFILE"; exit 1; } | ||
else | ||
OF=trento-support-$(hostname)-$(date +%Y%m%d-%H%M%S).txt | ||
|
||
rpm_verify() { | ||
LOGFILE=$LOG/$1 | ||
INPUT_RPM=$2 | ||
echo "#==[ Verification ]=================================#" >> $LOGFILE | ||
if rpm -q $INPUT_RPM &>/dev/null | ||
then | ||
for RPM in $(rpm -q $INPUT_RPM) | ||
do | ||
echo "# rpm -V $RPM" >> $LOGFILE | ||
rpm -V $RPM >> $LOGFILE 2>&1 | ||
ERR=$? | ||
if (( $ERR )); then | ||
echo "# Verification Status: Differences Found" >> $LOGFILE | ||
else | ||
echo "# Verification Status: Passed" >> $LOGFILE | ||
fi | ||
echo >> $LOGFILE | ||
done | ||
return 0 | ||
else | ||
echo "# RPM Not Installed: $INPUT_RPM" >> $LOGFILE | ||
echo >> $LOGFILE | ||
return 1 | ||
fi | ||
} | ||
|
||
# log_entry file type label | ||
log_entry() { | ||
LOGFILE=$LOG/$1 | ||
shift | ||
ENTRY_TYPE=$1 | ||
shift | ||
ENTRY_LABEL="$@" | ||
case $ENTRY_TYPE in | ||
command) ENTRY_HEADER="#==[ Command ]======================================#" ;; | ||
conf) ENTRY_HEADER="#==[ Configuration File ]===========================#";; | ||
log) ENTRY_HEADER="#==[ Log File ]=====================================#" ;; | ||
note) ENTRY_HEADER="#==[ Note ]=========================================#" ;; | ||
summary) ENTRY_HEADER="#==[ Summary ]======================================#" ;; | ||
*) ENTRY_HEADER="#==[ Entry ]========================================#";; | ||
esac | ||
echo "$ENTRY_HEADER" >> $LOGFILE | ||
echo "# $ENTRY_LABEL" >> $LOGFILE | ||
echo >> $LOGFILE | ||
} | ||
|
||
# Input: logfilename "text" | ||
log_write() { | ||
LOGFILE=$LOG/$1 | ||
shift | ||
echo "$@" >> $LOGFILE | ||
} | ||
|
||
_log_cmd() { | ||
EXIT_STATUS=0 | ||
shift | ||
CMDLINE=($@) | ||
CMDBIN=${CMDLINE[0]} | ||
CMD=($(command -v $CMDBIN)) | ||
echo "#==[ Command ]======================================#" | ||
if [[ -x "${CMD[0]}" ]]; then | ||
CMDLINE[0]="${CMD[0]}" | ||
echo "# ${CMDLINE[@]}" | ||
bash -c "${CMDLINE[*]}" 2>&1 | ||
EXIT_STATUS=$? | ||
else | ||
echo "# ${CMDLINE[@]}" | ||
echo "ERROR: Command not found or not executable" | ||
EXIT_STATUS=1 | ||
fi | ||
echo | ||
return $EXIT_STATUS | ||
} | ||
|
||
log_cmd() { | ||
LOGFILE=$LOG/$1 | ||
_log_cmd "$@" >> $LOGFILE | ||
} | ||
|
||
|
||
fi | ||
### END Check if executed by supportconfig ### | ||
|
||
|
||
### TODO ### | ||
# Detect and use usernames/database names/vhost name from config | ||
#check firewall | ||
#run standalone if not executed by supportconfig | ||
# dump-scenario | ||
# Use GNUGPL2 license to match supportutils, instead of Apache-2.0? | ||
|
||
|
||
|
||
|
||
#TODO sanitize these values | ||
# password from AMQP_URL | ||
# password from DATABASE_URL | ||
# password from EVENTSTORE_URL | ||
# postgresql-password | ||
# postgresql-postgres-password | ||
# .secretKeyRef | ||
# adminUser | ||
# admin-user | ||
# admin-password | ||
# SMTP_PASSWORD | ||
# ADMIN_USER | ||
# ADMIN_PASSWORD | ||
# SECRET_KEY_BASE | ||
# ACCESS_TOKEN_ENC_SECRET | ||
# REFRESH_TOKEN_ENC_SECRET | ||
_sanitize_file_trento() { | ||
CLEAN_FILE=${LOG}/$1 | ||
REPLACED='*REMOVED BY SUPPORTCONFIG*' | ||
sed -i -e "\ | ||
s/\(ADMIN_PASSWORD[[:space:]]*=\).*/\1 $REPLACED/g;\ | ||
s/\(SECRET_KEY_BASE[[:space:]]*=\).*/\1 $REPLACED/g;\ | ||
s/\(ACCESS_TOKEN_ENC_SECRET[[:space:]]*=\).*/\1 $REPLACED/g;\ | ||
s/\(REFRESH_TOKEN_ENC_SECRET[[:space:]]*=\).*/\1 $REPLACED/g;\ | ||
s/\(SMTP_PASSWORD[[:space:]]*=\).*/\1 $REPLACED/g" \ | ||
$CLEAN_FILE | ||
} | ||
|
||
|
||
|
||
## Docs ## | ||
log_entry $OF section "Current Documentation" | ||
echo -e "\ | ||
https://documentation.suse.com/sles-sap/trento/html/SLES-SAP-trento/ | ||
https://www.trento-project.io/web/ | ||
https://www.trento-project.io/wanda/ | ||
https://github.com/trento-project/agent/blob/main/README.md | ||
" | ||
############################################################# | ||
log_entry $OF section "Supportconfig Plugin for $TITLE v${SVER}" | ||
|
||
## Check for different Trento deployment types ## | ||
|
||
### Trento Server - Kubernetes ### | ||
#TODO | ||
if rpm -q --quiet trento-server-installer; then | ||
command -v trento-support &>/dev/null && \ | ||
trento-support --output stdout --collect all --output stdout | ||
fi | ||
|
||
### Trento Server - Docker ### | ||
#TODO | ||
#command -v docker &>/dev/null | ||
#command -v podman &>/dev/null | ||
# images: trento/trento-web & trento/trento-wanda | ||
|
||
### Trento Server - Systemd ### | ||
if rpm -q --quiet trento-web; then | ||
log_cmd $OF "rpm -qa | egrep 'trento|postgresql-server|rabbitmq-server|prometheus'" | ||
for RPM in trento-web trento-wanda postgresql-server rabbitmq-server prometheus | ||
do | ||
rpm_verify $OF $RPM | ||
done | ||
for SERVICE in trento-web trento-wanda postgresql rabbitmq-server prometheus | ||
do | ||
log_cmd $OF "systemctl status --lines=0 ${SERVICE}.service" | ||
done | ||
|
||
conf_files $OF /etc/trento/trento-web /etc/trento/trento-wanda /var/lib/pgsql/data/postgresql.conf /var/lib/pgsql/data/pg_hba.conf /etc/rabbitmq/rabbitmq.conf /etc/prometheus/prometheus.yml | ||
echo | ||
log_entry $OF section "Trento Web/Wanda health status" | ||
log_cmd $OF curl -sS http://localhost:4000/api/readyz | ||
echo | ||
log_cmd $OF curl -sS http://localhost:4000/api/healthz | ||
echo | ||
log_cmd $OF curl -sS http://localhost:4001/api/readyz | ||
echo | ||
log_cmd $OF curl -sS http://localhost:4001/api/healthz | ||
echo | ||
echo | ||
|
||
log_entry $OF section "Postgresql Section" | ||
|
||
|
||
echo "#==[ Postgresql permissions ]=======================#" | ||
echo "#==[ Trento databases ]=============================#" | ||
DB_TRENTO="" | ||
DB_TRENTO_EVENTS="" | ||
DB_WANDA="" | ||
DB_TRENTO_USER="" | ||
DB_WANDA_USER="" | ||
#TODO use detected database names | ||
su - postgres -c 'psql -tlq | cut -d \| -f 1 | grep -wE "trento|trento_event_store|wanda"' | ||
echo | ||
|
||
echo "#==[ trento database permissions ]==================#" | ||
#TODO detect trento-web database name/user from trento-web's DATABASE_URL | ||
su - postgres -c "psql -d trento -c \" | ||
SELECT grantor, grantee, table_schema, table_name, privilege_type | ||
FROM information_schema.table_privileges | ||
WHERE grantee = 'trento_user'\"" | ||
|
||
echo "#==[ trento_event_store database permissions ]======#" | ||
#TODO detect trento-web database name/user from trento-web's EVENTSTORE_URL | ||
su - postgres -c "psql -d trento_event_store -c \" | ||
SELECT grantor, grantee, table_schema, table_name, privilege_type | ||
FROM information_schema.table_privileges | ||
WHERE grantee = 'trento_user'\"" | ||
|
||
echo "#==[ wanda database permissions ]===================#" | ||
#TODO detect trento-wanda database name/user from trento-wanda's DATABASE_URL | ||
su - postgres -c "psql -d wanda -c \" | ||
SELECT grantor, grantee, table_schema, table_name, privilege_type | ||
FROM information_schema.table_privileges | ||
WHERE grantee = 'wanda_user'\"" | ||
|
||
log_entry $OF section "Rabbitmq Section" | ||
#TODO detect vhost name from AMQP_URL | ||
log_cmd $OF "rabbitmqctl list_permissions -p vhost 2>/dev/null" | ||
echo "Permissions should be: .* .* .*" | ||
fi | ||
|
||
|
||
|
||
|
||
### Trento Agent ### | ||
#TODO | ||
# collect /etc/machine-id | ||
# /etc/trento/agent.yaml | ||
|
||
if rpm -q --quiet trento-agent; then | ||
log_cmd $OF "rpm -qa | egrep 'trento-agent|golang-github-prometheus-node_exporter'" | ||
for RPM in trento-agent golang-github-prometheus-node_exporter | ||
do | ||
rpm_verify $OF $RPM | ||
done | ||
for SERVICE in trento-agent.service prometheus-node_exporter.service | ||
do | ||
log_cmd $OF "systemctl status ${SERVICE}.service" | ||
done | ||
fi | ||
|
||
|
||
_sanitize_file_trento $OF | ||
echolog Done |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Thr3d could you please help me with changing this if block to something else?
trento-server-installer
is now deprecated and its presence as a package shouldn't be used to determine whether or not we have a kubernetes setup.