Contact Info

Crumbtrail

ActiveXperts.com » Network Monitor » Scripts » Custom Script

email-pop3.sh - ssh script by ActiveXperts Software

email-pop3.sh checks whether a POP3 server is available.

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


email-pop3.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
#     email-pop3.sh
# Description
#     Checks if the POP3 server is available
# Declare Parameters
#     1) host (string) - Host to check
# Usage
#     email-pop3.sh <host>
# Sample
#     email-pop3.sh pop3.activexperts.com
#################################################################################

#!/bin/sh

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

#Checks the connection
# Responses will be cut at 30 characters
sleep 1 | nc $1 110 2>&1 | awk -v host=$1 '
  { 
    if ( $1 == "+OK" ) 
      printf( "SUCCESS: Response from [" host "]: [%10.30s] DATA:1\n", $0 );
    else
      printf( "ERROR: Failed to connect to [" host "] DATA:0\n", $0 );
  }';