Debian Clusters for Education and Research: The Missing Manual

Nagios Pbs Mom Plugin

From Debian Clusters

Jump to: navigation, search

This is part of the Creating Your Own Nagios Plugin tutorial and is only meant as a simple example.

check_pbsmom

#!/bin/bash
# File: /usr/lib/nagios/plugins/check_pbsmom

if [ -z "$1" ]
then
  echo "No hostname given."
  exit 3
fi

hostname=$1

pbsoutput=`pbsnodes $hostname 2>&1`

if [ "$?" -gt 0 ]
then
  error=`echo $pbsoutput | grep MSG | awk -F "MSG=" '{print $2}'`
  echo Error: $error
  exit 1
fi

state=`pbsnodes $hostname | awk 'NR==2 {print $3}'`

if [ "$state" = "down" ]
then
  echo Pbsmom is unreachable!
  exit 2
elif [ "$state" = "free" ]
then
  echo Pbsmom is running.
  exit 0
else
  echo Other pbsmom state: $state
  exit 1
fi

exit 3
Personal tools