Contact Info

Crumbtrail

ActiveXperts.com » Support » ActiveXperts Network Monitor » Online » Linux

Using Shell Scripts to monitor Linux and Unix computers with ActiveXperts Network Monitor

Introduction

ActiveXperts Network Monitor ships with a collection of shell scripts to monitor remote Linux- and Unix computers. There are two types of check for that: an RSH check and an SSH check.

SSH allows secure network services over an insecure network, such as the Internet. With SSH, ActiveXperts Network Monitor can login onto a remote machine running the SSH daemon, and execute a command or shell script. RSH is another IP-based protocol to execute programs on a remote Linux/Unix computer, but it less popular because it is NOT secure. Therefore, SSH is recommended for checking remote Linux- and Unix computers.

ActiveXperts Network Monitor requires the output (i.e. StdOut) to be formatted according to the following syntax:

[ SUCCESS | ERROR | UNCERTAIN]: { <explanation> } { DATA:<value>}

The <explanation> will be shown in the 'Last Response' column in the Manager application. The <value> field will be shown in the 'Data' column in the Manager application.

The shell script must reside on the Linux machine, i.e. you cannot use a script that resides on the Windows monitoring server. The shell script must have the 'Execute' permission flag set.

Here's a sample shell script that works with Network Monitor. This script checks the size of a directory:

#!/bin/bash
# Validate number of arguments
if [ $# -ne 2 ] ; then
  echo "UNCERTAIN: Invalid number of arguments - Usage: directory-size sDirectory nMaxSizeMB"
  exit 1
fi

# Validate numeric parameter nMaxSizeMB
regExpNumber='^[0-9]+$'
if ! [[ $2 =~ $regExpNumber ]] ; then
  echo "UNCERTAIN: Invalid argument: nMaxSizeMB (number expected)"
  exit 1
fi

# Check the size of the directory specified
if [ ! -d "$1" ]; then
  echo "UNCERTAIN: Directory [$1] does not exist"
  exit 0
fi

nSizeKB=`du -s "$1" | awk '{ print $1; }'`
nSizeMB=$( echo "$nSizeKB / 1024" | bc )

# Round a float to an integer value
nRoundSizeMB=$( echo "$nSizeMB / 1" | bc )

# Round a float to an integer value
nRoundMaxMB=$( echo "$2 / 1" | bc )

if [ $nRoundSizeMB -le $nRoundMaxMB ] ; then
  echo "SUCCESS: Size=[$nRoundSizeMB MB], max. allowed=[$nRoundMaxMB MB] DATA:$nRoundSizeMB"
else
  echo "ERROR: Size=[$nRoundSizeMB MB], max. allowed=[$nRoundMaxMB MB] DATA:$nRoundSizeMB"
fi

exit 0

Network Monitor Shell Script checks

ActiveXperts Network Monitor ships with a selection of shell scripts. These scripts work out of the box. The scripts are located in the <installation-dir>\Scripts\Monitor (Linux) (e.g., C:\Program Files\ActiveXperts\Network Monitor\Scripts\Monitor (Linux). you must copy the script to the linux machine first in order to run the script.

Samples

CPU usage check

Click here for a CPU monitoring script.

Directory size check

Click here for a directory size check.

Disk Existence check

Click here for a disk existence check.

Disk Free Space check

Click here for a disk free space check.

Disk Used Space check

Click here for a disk used space check.

Disk Used Space Percentage check

Click here for a disk used space percentage check.

E-mail POP3 check

Click here for an e-mail POP3 check.

E-mail SMTP check

Click here for an e-mail SMTP check.

File content check

Click here for a file content check.

File existence check

Click here for a file existence check.

Memory usage check

Click here for a memory monitoring script.

Ping check

Click here for a ping check.

Process check

Click here for a process check.

User Exists

Click here for a Linux User Existence check.