-
Notifications
You must be signed in to change notification settings - Fork 13
/
supportconfig-sap_host_exporter
87 lines (71 loc) · 2.21 KB
/
supportconfig-sap_host_exporter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
set -u
# supportconfig plugin for sap_host_exporter
#
# v1.0
#
# February 2024 v1.0 first release
SVER='1.0.0'
TITLE="SUSE supportconfig plugin for sap_host_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-sap_host_exporter
# prometheus-sap_host_exporter@
# use 'pattern' for systemctl status cmd
display_systemd_status "*sap_host_exporter*"
# at least default config /usr/etc/sap_host_exporter/default.yaml
for file in /usr/etc/sap_host_exporter/*.{yaml,json,toml} /etc/sap_host_exporter/*.{yaml,json,toml}; do
[ -e "${file}" ] && { display_file_stat "${file}" ; display_file "${file}" ; echo ; }
done
# log infos in system log
display_cmd "grep -E -i 'sap_host_exporter\[.*\]:' /var/log/messages"
display_cmd "ss -tulpan | grep exporter"
# Bye.
exit 0