Contact Info

Crumbtrail

ActiveXperts.com » Network Monitor » Scripts » Custom Script

ping.sh - ssh script by ActiveXperts Software

ping.sh ping a host.

Use ping.sh directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select ping.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.


ping.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
#     ping.sh
# Description
#     Tries to ping a host
# Declare Parameters
#     1) host (string) - Host to ping
# Usage
#     ping.sh <host>
# Sample
#     ping.sh activexperts.com
#################################################################################

#!/bin/sh

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


ping $1 -c1 &> /dev/null
if [ $? -eq 0 ] ; then
  echo "SUCCESS: Ping successful, packet sent 1, received 1, lost 0 DATA:1"
else
  echo "ERROR: Ping failed, packet sent 1, received 0, lost 1 DATA:0"
fi