2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Shellcheck override

eval statement workaround
Local execution fix
This commit is contained in:
Diver 2017-02-04 01:34:35 +03:00
parent f66edd28c4
commit 5fb6d92501
2 changed files with 28 additions and 39 deletions

View File

@ -184,6 +184,7 @@ check_conf_and_set_vars () {
fi
#Choosing Cotrol Station. Code have to be "10"
for CS in $cs_addr; do
# shellcheck disable=SC2086
if [[ "10" = "$(ssh_check_cmd $CS)" ]]; then
PRIMARY_CS=$CS
SSH="ssh -q $username@$PRIMARY_CS "
@ -209,6 +210,7 @@ check_conf_and_set_vars () {
fi
local probe_sp
for probe_sp in $SPALL; do
# shellcheck disable=SC2086
if $SSH $NAVICLI -h "$probe_sp" >/dev/null 2>&1; then
StorageProcessor="$probe_sp"
break
@ -234,25 +236,16 @@ check_conf_and_set_vars 1>&2 || exit 1
run_remote() {
if [ -z "$SSH" ]; then
eval "$@"
sh -c "$*"
else
eval "$SSH" "\"$@\""
$SSH "$*"
fi
}
run_navicli() {
run_remote "$NAVICLI" "$@"
run_remote "$NAVICLI" "$*"
}
run_navicli_both_sp() {
for SP in $SPALL; do
run_remote "$NAVICLI_NOSP $SP" "$@"
# echo "$NAVICLI_NOSP $SP" "$@"
# echo "$NAVICLI_NOSP $SP" $@
done
}
# Get Lun List
LUNLIST=$(run_navicli lun -list -drivetype | sed -ne 's/^Name:\ *//p' | sort)
@ -493,27 +486,21 @@ while read -r LUN ; do
' ; "
done <<< "$LUNLIST"
ANSWER=$(run_remote "$BIGCMD")
# BIGCMD="getcontrol -cbt | sed -ne '
# s/Controller busy ticks\:\ */ spa_busyticks.value /p;
# s/Controller idle ticks\:\ */ spa_idleticks.value /p;'
BIGCMD="getcontrol -cbt | sed -ne '
s/Controller busy ticks\:\ */\${SP}_total_busyticks.value /p;
s/Controller idle ticks\:\ */\${SP}_total_idleticks.value /p;
'
"
ANSWER+=$'\n'$(run_navicli_both_sp "$BIGCMD")
run_navicli_both_sp "$BIGCMD"
for SP in $SPALL; do
FILTER_SP="$(clean_fieldname "$SP")"
BIGCMD="getcontrol -cbt | sed -ne '
s/Controller busy ticks\:\ */${FILTER_SP}_total_busyticks.value /p;
s/Controller idle ticks\:\ */${FILTER_SP}_total_idleticks.value /p;
'
"
ANSWER+=$'\n'$(run_remote "$NAVICLI_NOSP $SP" "$BIGCMD")
done
get_precise_answer_field() {
echo "$ANSWER" | grep -F "_${1}."
}
# get_similar_answer_field() {
# echo "$ANSWER" | grep -F "_${1}"
# }
#ANSWER=$BIGSSHCMD
echo "multigraph emc_vnx_block_blocks"
get_precise_answer_field "read"
get_precise_answer_field "write"

View File

@ -162,6 +162,7 @@ check_conf () {
#Choosing Cotrol Station. Code have to be "10"
for CS in $cs_addr; do
# shellcheck disable=SC2086
if [[ "10" = "$(ssh_check_cmd $CS)" ]]; then
PRIMARY_CS=$CS
break
@ -201,6 +202,7 @@ TARGET=$(echo "${0##*/}" | cut -d _ -f 6)
check_conf 1>&2 || exit 1
run_remote () {
# shellcheck disable=SC2029
ssh -q "$username@$PRIMARY_CS" ". /home/$username/.bash_profile; $*"
}
@ -492,7 +494,7 @@ if [ "$1" = "config" ] ; then
fi
for server in $nas_servers; do
run_remote nas_server -i $server | grep -q 'type *= nas' || continue
run_remote nas_server -i "$server" | grep -q 'type *= nas' || continue
nas_server_ok=TRUE
filtered_server="$(clean_fieldname "$server")"
@ -511,12 +513,12 @@ for server in $nas_servers; do
echo "${server}_cpuutil.value ${graphs[1]}"
echo -e "\nmultigraph emc_vnx_network_b"
echo "${server}_net_in.value $((${graphs[2]} * 1024))"
echo "${server}_net_out.value $((${graphs[3]} * 1024))"
echo "${server}_net_in.value $((graphs[2] * 1024))"
echo "${server}_net_out.value $((graphs[3] * 1024))"
echo -e "\nmultigraph emc_vnx_storage_b"
echo "${server}_stor_read.value $((${graphs[4]} * 1024))"
echo "${server}_stor_write.value $((${graphs[5]} * 1024))"
echo "${server}_stor_read.value $((graphs[4] * 1024))"
echo "${server}_stor_write.value $((graphs[5] * 1024))"
# [nasadmin@mnemonic0 ~]$ server_stats server_2 -monitor kernel.memory -count 1 -terminationsummary no
# server_2 Free Buffer Buffer Buffer Buffer Buffer Buffer Cache Encumbered FileResolve FileResolve FileResolve Free KiB Page Total Used KiB Memory
@ -529,11 +531,11 @@ for server in $nas_servers; do
echo -e "\nmultigraph emc_vnx_memory"
#Reserved for math
echo "${server}_total.value $((${graphs[14]} / 1))"
echo "${server}_used.value $((${graphs[15]} / 1))"
echo "${server}_free.value $((${graphs[12]} / 1))"
echo "${server}_freebuffer.value $((${graphs[1]} / 1))"
echo "${server}_encumbered.value $((${graphs[8]} / 1))"
echo "${server}_total.value $((graphs[14] / 1))"
echo "${server}_used.value $((graphs[15] / 1))"
echo "${server}_free.value $((graphs[12] / 1))"
echo "${server}_freebuffer.value $((graphs[1] / 1))"
echo "${server}_encumbered.value $((graphs[8] / 1))"
echo -e "\nmultigraph emc_vnx_filecache"
echo "${server}_highw_hits.value ${graphs[2]}"
@ -701,8 +703,8 @@ for server in $nas_servers; do
echo "${filtered_server}_tops.value ${graphs[1]}"
echo -e "\nmultigraph vnx_emc_nfs_std_nfs_b_s"
echo "${filtered_server}_rbs.value $((${graphs[3]} * 1024))"
echo "${filtered_server}_wbs.value $((${graphs[6]} * 1024))"
echo "${filtered_server}_rbs.value $((graphs[3] * 1024))"
echo "${filtered_server}_wbs.value $((graphs[6] * 1024))"
echo "${filtered_server}_tbs.value 0"