Contact Info

Crumbtrail

ActiveXperts.com » Network Monitor » Scripts » Custom Script

process.sh - ssh script by ActiveXperts Software

process.sh checks whether a process is running.

Use process.sh directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select process.sh. Configure the required parameter, or press 'Load a working sample'.

In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.


process.sh script code

#################################################################################
# ActiveXperts Network Monitor - Shell script checks
# © 1999-2015, ActiveXperts Software B.V.
#
# For more information about ActiveXperts Network Monitor and SSH, please
# visit the online ActiveXperts Network Monitor Shell Script Guidelines at:
#   http://www.activexperts.com/support/network-monitor/online/linux/
#################################################################################
# Script
#     process.sh
# Description:
#     Checks if the specified process is running
# Declare Parameters
#     1) process (string) - Host to check
# Usage
#     process.sh <process name>
# Sample
#     process.sh processname
#################################################################################

#!/bin/sh

# Validate number of arguments
if [ $# -ne 1 ] ; then
  echo "UNCERTAIN: Invalid number of arguments  Usage: process <process name>"
  exit 1
fi

# Validate number of arguments
PR=`ps -C "$1" | awk ' { 
    if (NR==2) {
  print "1"
    }
}'`

#Checks if the specified process is running
if [ "$PR" == "1" ]; then
  echo "SUCCESS: Process '$1' is running DATA:1"
else
  echo "ERROR: Process '$1' is not running DATA:0"
fi