From d2e89a56f2235cab007c69fbe1b63c70d400c182 Mon Sep 17 00:00:00 2001 From: Brian Flowers Date: Fri, 16 Sep 2016 02:56:50 -0400 Subject: [PATCH] Added compatibility function to plugins --- bdsm.d/df.generic | 11 +++++++++++ bdsm.d/sensors.generic | 11 +++++++++++ bdsm.d/template.generic | 5 +++++ bdsm.d/vmstat.generic | 15 +++++++++++++-- bdsm.sh | 9 ++++----- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/bdsm.d/df.generic b/bdsm.d/df.generic index 5ccb905..ed8e62d 100755 --- a/bdsm.d/df.generic +++ b/bdsm.d/df.generic @@ -104,6 +104,17 @@ status() fi } +compatible() +{ + compatible="`ssh -q $HOSTNAME 'df --output=pcent /' 2>&1 1>/dev/null`" + if [ "$compatible" != "" ]; then + echo 0 + return + fi + echo 1 + return +} + # UTILITY FUNCTIONS ############################################################################### diff --git a/bdsm.d/sensors.generic b/bdsm.d/sensors.generic index f8f20d3..d92d496 100755 --- a/bdsm.d/sensors.generic +++ b/bdsm.d/sensors.generic @@ -118,6 +118,17 @@ status() fi } +compatible() +{ + compatible="`ssh -q $HOSTNAME 'sensors' 2>&1 1>/dev/null`" + if [ "$compatible" != "" ]; then + echo 0 + return + fi + echo 1 + return +} + # UTILITY FUNCTIONS ############################################################################### diff --git a/bdsm.d/template.generic b/bdsm.d/template.generic index e1fb372..abe8273 100644 --- a/bdsm.d/template.generic +++ b/bdsm.d/template.generic @@ -84,6 +84,11 @@ status() # Check if the monitor is running and echo ON or OFF } +compatible() +{ + # Check if this plugin is compatible with the given host +} + # SCRIPT START ############################################################################### diff --git a/bdsm.d/vmstat.generic b/bdsm.d/vmstat.generic index ad1ac0b..6947ab4 100755 --- a/bdsm.d/vmstat.generic +++ b/bdsm.d/vmstat.generic @@ -69,14 +69,14 @@ start() fi # Check what options awk supports - if [ "`ssh $HOSTNAME \"echo | awk -W interactive '{print 1}' 2>&1 1>/dev/null\"`" != "" ]; then + if [ "`ssh -q $HOSTNAME \"echo | awk -W interactive '{print 1}' 2>&1 1>/dev/null\"`" != "" ]; then awkopt="" else awkopt="-W interactive" fi ssh -q $HOSTNAME <