From 5fb6d92501695ebc1dc67e813396837397bae097 Mon Sep 17 00:00:00 2001 From: Diver Date: Sat, 4 Feb 2017 01:34:35 +0300 Subject: [PATCH] Shellcheck override eval statement workaround Local execution fix --- plugins/emc/emc_vnx_block_lun_perfdata | 41 +++++++++----------------- plugins/emc/emc_vnx_file_ | 26 ++++++++-------- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/plugins/emc/emc_vnx_block_lun_perfdata b/plugins/emc/emc_vnx_block_lun_perfdata index 925cb1b0..08e989ff 100755 --- a/plugins/emc/emc_vnx_block_lun_perfdata +++ b/plugins/emc/emc_vnx_block_lun_perfdata @@ -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" diff --git a/plugins/emc/emc_vnx_file_ b/plugins/emc/emc_vnx_file_ index 0b1fb295..62dcf0b8 100755 --- a/plugins/emc/emc_vnx_file_ +++ b/plugins/emc/emc_vnx_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"