From 20f671c3aa5cca0428260e13d7d374551caae11c Mon Sep 17 00:00:00 2001 From: Brian Flowers Date: Sun, 18 Sep 2016 17:58:08 -0400 Subject: [PATCH] More bugfixes on recent additions --- bdsm.d/df.generic | 7 +++++-- bdsm.d/sensors.generic | 9 ++++----- bdsm.d/template.generic | 24 +++++++++++++++++------- bdsm.d/vmstat.generic | 6 ++++-- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/bdsm.d/df.generic b/bdsm.d/df.generic index bf78a7c..45dc9c2 100755 --- a/bdsm.d/df.generic +++ b/bdsm.d/df.generic @@ -130,10 +130,13 @@ formatConfig() # SCRIPT START ############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi # Get a list of configured hosts -formatConfig -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) + if [ -z $1 ]; then help diff --git a/bdsm.d/sensors.generic b/bdsm.d/sensors.generic index 6007267..e3a0973 100755 --- a/bdsm.d/sensors.generic +++ b/bdsm.d/sensors.generic @@ -144,23 +144,22 @@ formatConfig() # SCRIPT START ############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi # Get a list of configured hosts -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) if [ -z $1 ]; then help elif [ $1 == "start" ]; then - formatConfig start elif [ $1 == "stop" ]; then - formatConfig stop elif [ $1 == "status" ]; then - formatConfig status elif [ $1 == "compatible" ]; then - formatConfig compatible elif [ $1 == "help" ]; then help diff --git a/bdsm.d/template.generic b/bdsm.d/template.generic index ffc0b03..4731fc7 100644 --- a/bdsm.d/template.generic +++ b/bdsm.d/template.generic @@ -89,17 +89,27 @@ compatible() # Check if this plugin is compatible with the given host } -# SCRIPT START +# UTILITY FUNCTIONS ############################################################################### -# Reformat config file to be more machine-readable -# Removes whitespace and adds semicolons after property values -cat /home/bdsm/bdsm.conf | sed "s/[[:space:]]//g" | tr '\n' ' ' | sed 's/}/}\ - /g' | sed 's/^;*//g' | sed 's/;\([{}]\)/\1/g' | sed 's/\([{}]\);/\1/g' \ +formatConfig() +{ + # Reformat config file to be more machine-readable + # Removes whitespace and adds semicolons after property values + cat /home/bdsm/bdsm.conf | tr '\n' ' ' | sed 's/}/}\ + /g' | sed 's/^;*//g' | sed "s/[[:space:]]//g"| \ + sed 's/;\([{}]\)/\1/g' | sed 's/\([{}]\);/\1/g' \ > /home/bdsm/.bdsm.conf.tmp - +} + +# SCRIPT START +############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi + # Get a list of configured hosts -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) if [ -z $1 ]; then help diff --git a/bdsm.d/vmstat.generic b/bdsm.d/vmstat.generic index d4ad1dd..c67d765 100755 --- a/bdsm.d/vmstat.generic +++ b/bdsm.d/vmstat.generic @@ -163,10 +163,12 @@ formatConfig() # SCRIPT START ############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi # Get a list of configured hosts -formatConfig -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) if [ -z $1 ]; then help -- 1.8.3.1