mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Double quote to prevent globbing and word splitting
https://github.com/koalaman/shellcheck/wiki/SC2086
This commit is contained in:
parent
15125852e8
commit
5c08e0744c
@ -72,7 +72,7 @@ nvSmiExec=${smiexec:-'/usr/bin/nvidia-smi'}
|
|||||||
# Check if autoconf was requested
|
# Check if autoconf was requested
|
||||||
if [ "$1" = "autoconf" ]; then
|
if [ "$1" = "autoconf" ]; then
|
||||||
# Autoconf only returns yes if nvidia-smi exists and is executable
|
# Autoconf only returns yes if nvidia-smi exists and is executable
|
||||||
if [ -x $nvSmiExec ]; then
|
if [ -x "$nvSmiExec" ]; then
|
||||||
echo yes
|
echo yes
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
@ -93,7 +93,7 @@ fi
|
|||||||
# Get number of GPUs
|
# Get number of GPUs
|
||||||
nGpusOutput=$($nvSmiExec -L)
|
nGpusOutput=$($nvSmiExec -L)
|
||||||
nGpus=$(echo "$nGpusOutput" | wc -l)
|
nGpus=$(echo "$nGpusOutput" | wc -l)
|
||||||
if [ $nGpus -eq 0 ]; then
|
if [ "$nGpus" -eq 0 ]; then
|
||||||
# Exit if no GPUs found
|
# Exit if no GPUs found
|
||||||
echo "No NVIDIA GPUs detected. Exiting."
|
echo "No NVIDIA GPUs detected. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
@ -117,7 +117,7 @@ if [ "$1" = "config" ]; then
|
|||||||
echo 'graph_category sensors'
|
echo 'graph_category sensors'
|
||||||
echo "graph_info Temperature information for NVIDIA GPUs using driver version $driverVersion"
|
echo "graph_info Temperature information for NVIDIA GPUs using driver version $driverVersion"
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
||||||
echo "temp${nGpusCounter}.warning ${warning:-75}"
|
echo "temp${nGpusCounter}.warning ${warning:-75}"
|
||||||
@ -131,14 +131,14 @@ if [ "$1" = "config" ]; then
|
|||||||
gpusTotalMemOutput=$(echo "$smiOutput" | grep -v BAR1 | grep -A 3 "Memory Usage" | grep "Total" | cut -d : -f 2 | tr -d ' ')
|
gpusTotalMemOutput=$(echo "$smiOutput" | grep -v BAR1 | grep -A 3 "Memory Usage" | grep "Total" | cut -d : -f 2 | tr -d ' ')
|
||||||
gpusTotalMem=''
|
gpusTotalMem=''
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
||||||
echo "mem${nGpusCounter}.info Memory information for $gpuName"
|
echo "mem${nGpusCounter}.info Memory information for $gpuName"
|
||||||
gpuMem=$(echo "$gpusTotalMemOutput"| sed -n $((nGpusCounter+1))p)
|
gpuMem=$(echo "$gpusTotalMemOutput"| sed -n $((nGpusCounter+1))p)
|
||||||
gpusTotalMem="${gpusTotalMem}${gpuMem} for GPU ${nGpusCounter}"
|
gpusTotalMem="${gpusTotalMem}${gpuMem} for GPU ${nGpusCounter}"
|
||||||
: $((nGpusCounter=nGpusCounter+1))
|
: $((nGpusCounter=nGpusCounter+1))
|
||||||
if [ $nGpusCounter -lt $nGpus ]; then
|
if [ "$nGpusCounter" -lt "$nGpus" ]; then
|
||||||
gpusTotalMem="${gpusTotalMem}, "
|
gpusTotalMem="${gpusTotalMem}, "
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -156,7 +156,7 @@ if [ "$1" = "config" ]; then
|
|||||||
echo 'graph_category sensors'
|
echo 'graph_category sensors'
|
||||||
echo "graph_info Fan speed of NVIDIA GPUs using driver version $driverVersion"
|
echo "graph_info Fan speed of NVIDIA GPUs using driver version $driverVersion"
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
||||||
echo "fan${nGpusCounter}.info Fan information for $gpuName"
|
echo "fan${nGpusCounter}.info Fan information for $gpuName"
|
||||||
@ -169,7 +169,7 @@ if [ "$1" = "config" ]; then
|
|||||||
echo 'graph_category sensors'
|
echo 'graph_category sensors'
|
||||||
echo "graph_info power consumption of NVIDIA GPUs using driver version $driverVersion"
|
echo "graph_info power consumption of NVIDIA GPUs using driver version $driverVersion"
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
||||||
echo "power${nGpusCounter}.info power consumption of $gpuName"
|
echo "power${nGpusCounter}.info power consumption of $gpuName"
|
||||||
@ -185,7 +185,7 @@ if [ "$1" = "config" ]; then
|
|||||||
|
|
||||||
# Common stuff for all quantities
|
# Common stuff for all quantities
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
gpuName=$(echo "$nGpusOutput" | sed -n $((nGpusCounter+1))p | cut -d \( -f 1)
|
||||||
echo "${name}${nGpusCounter}.label $gpuName"
|
echo "${name}${nGpusCounter}.label $gpuName"
|
||||||
@ -207,7 +207,7 @@ case $name in
|
|||||||
usedMemGpus=$(echo "$smiOutput" | grep -v BAR1 | grep -A 3 "Memory Usage" | grep "Used" | cut -d : -f 2 | cut -d ' ' -f 2)
|
usedMemGpus=$(echo "$smiOutput" | grep -v BAR1 | grep -A 3 "Memory Usage" | grep "Used" | cut -d : -f 2 | cut -d ' ' -f 2)
|
||||||
valueGpus=''
|
valueGpus=''
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
totalMemGpu=$(echo "$totalMemGpus" | sed -n $((nGpusCounter+1))p)
|
totalMemGpu=$(echo "$totalMemGpus" | sed -n $((nGpusCounter+1))p)
|
||||||
usedMemGpu=$(echo "$usedMemGpus" | sed -n $((nGpusCounter+1))p)
|
usedMemGpu=$(echo "$usedMemGpus" | sed -n $((nGpusCounter+1))p)
|
||||||
@ -232,7 +232,7 @@ case $name in
|
|||||||
|
|
||||||
# Print requested value
|
# Print requested value
|
||||||
nGpusCounter=0
|
nGpusCounter=0
|
||||||
while [ $nGpusCounter -lt $nGpus ]
|
while [ "$nGpusCounter" -lt "$nGpus" ]
|
||||||
do
|
do
|
||||||
value=$(echo "$valueGpus" | sed -n $((nGpusCounter+1))p)
|
value=$(echo "$valueGpus" | sed -n $((nGpusCounter+1))p)
|
||||||
echo "${name}${nGpusCounter}.value $value"
|
echo "${name}${nGpusCounter}.value $value"
|
||||||
|
Loading…
Reference in New Issue
Block a user