From 6b44c296ea004b4e0c469ad0c3adb41000c28808 Mon Sep 17 00:00:00 2001 From: AngelaBriel Date: Wed, 20 Mar 2024 14:12:41 +0100 Subject: [PATCH] add supportconfig plugin (jsc#PED-2560) --- .../prometheus-ha_cluster_exporter.spec | 8 +- supportconfig-ha_cluster_exporter | 87 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 supportconfig-ha_cluster_exporter diff --git a/packaging/obs/prometheus-ha_cluster_exporter/prometheus-ha_cluster_exporter.spec b/packaging/obs/prometheus-ha_cluster_exporter/prometheus-ha_cluster_exporter.spec index 4f54bc1..d590c24 100644 --- a/packaging/obs/prometheus-ha_cluster_exporter/prometheus-ha_cluster_exporter.spec +++ b/packaging/obs/prometheus-ha_cluster_exporter/prometheus-ha_cluster_exporter.spec @@ -1,5 +1,5 @@ # -# Copyright 2019-2022 SUSE LLC +# Copyright 2019-2024 SUSE LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -68,6 +68,9 @@ install -D -m 0644 %{shortname}.sysconfig %{buildroot}%{_fillupdir}/sysconfig.%{ install -Dd -m 0755 %{buildroot}%{_sbindir} ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name} +# Install supportconfig plugin +install -D -m 755 supportconfig-ha_cluster_exporter %{buildroot}%{_prefix}/lib/supportconfig/plugins/%{shortname} + %pre %service_add_pre %{name}.service @@ -93,5 +96,8 @@ ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name} %{_unitdir}/%{name}.service %{_fillupdir}/sysconfig.%{name} %{_sbindir}/rc%{name} +%dir %{_prefix}/lib/supportconfig +%dir %{_prefix}/lib/supportconfig/plugins +%{_prefix}/lib/supportconfig/plugins/%{shortname} %changelog diff --git a/supportconfig-ha_cluster_exporter b/supportconfig-ha_cluster_exporter new file mode 100644 index 0000000..d413ca1 --- /dev/null +++ b/supportconfig-ha_cluster_exporter @@ -0,0 +1,87 @@ +#!/bin/bash +set -u + +# supportconfig plugin for ha_cluster_exporter +# +# v1.0 +# +# February 2024 v1.0 first release + +SVER='1.0.0' +TITLE="SUSE supportconfig plugin for ha_cluster_exporter" + +function display_package_info() { + echo -e "\n#==[ Command ]======================================#" + echo -e "# rpm -qi ${1}" + rpm -qi "${1}" + + echo -e "\n#==[ Command ]======================================#" + echo -e "# rpm -V ${1}" + rpm -V "${1}" +} + +function display_file_stat() { + echo -e "\n#==[ File ]===========================#" + echo -e "# ls -ld ${1} ; stat ${1} \n" + + if [ -e "${1}" ] ; then + ls -ld "${1}" + echo + stat "${1}" + else + echo "${1} does not exist!" + fi +} + +function display_file() { + echo -e "\n#==[ File Content ]===========================#" + echo -e "# cat ${1}" + + if [ -e "${1}" ] ; then + cat "${1}" + else + echo "${1} does not exist!" + fi +} + +function display_systemd_status() { + echo -e "\n#==[ Command ]======================================#" + echo -e "# systemctl status ${1}" + + systemctl status "${1}" 2>&1 +} + +function display_cmd() { + ORG_CMDLINE="${@}" + CMDBIN=${ORG_CMDLINE%% *} + FULLCMD=$(\which $CMDBIN 2>/dev/null | awk '{print $1}') + echo -e "\n#==[ Command ]======================================#" + if [ -x "$FULLCMD" ]; then + CMDLINE=$(echo $ORG_CMDLINE | sed -e "s!${CMDBIN}!${FULLCMD}!") + echo -e "# $CMDLINE" + echo "$CMDLINE" | bash + else + echo -e "# $ORG_CMDLINE" + echo "Command not found or not executable" + fi +} + +# ---- Main ---- +echo -e "Supportconfig Plugin for $TITLE, v${SVER}" + +display_package_info prometheus-ha_cluster_exporter +display_systemd_status prometheus-ha_cluster_exporter + +for file in /usr/etc/ha_cluster_exporter.{yaml,json,toml} /etc/ha_cluster_exporter.{yaml,json,toml} /usr/etc/ha_cluster_exporter.web.yaml /etc/ha_cluster_exporter.web.yaml; do + [ -e "${file}" ] && { display_file_stat "${file}" ; display_file "${file}" ; echo ; } +done + +display_file_stat /etc/sysconfig/prometheus-ha_cluster_exporter +display_file /etc/sysconfig/prometheus-ha_cluster_exporter + +#log infos from system log +display_cmd "grep -E -i 'ha_cluster_exporter\[.*\]:' /var/log/messages" +display_cmd "ss -tulpan | grep exporter" + +# Bye. +exit 0