#!/bin/sh
#SYSTEMS: Solaris, Linux
MSG="# Checking for the Simple Network Management Protocol (SNMP) service..."
SYSTEM=`uname -s`
######Solaris######
if [ "$SYSTEM" = "SunOS" ]; then
  echo ""; echo "$MSG"
  case "`uname -r`" in
  5.[6789]*) ;;
  *)
    #Only supported on Solaris 2.6 and newer"
    exit 0;;
  esac
  #Check for snmp daemon...
  PS=`ps -ef | grep /snmpdx | grep -v grep`
  if [ "$PS" != "" ]; then  #SNMPDX daemon found running...
    echo "--FAIL-- [SNMP001f] SNMP server daemon found running on this system."
  elif [ -s /etc/rc3.d/S76snmpdx ]; then  #SNMP startup script found...
    echo "--WARN-- [SNMP002w] SNMP server startup script /etc/rc3.d/S76snmpdx was found."
  fi
fi
######Linux######
if [ "$SYSTEM" = "Linux" ]; then
  echo ""; echo "$MSG"
  #Check if it shows up in the rc*.d directories.  Allow for multiple files found.
  CHK=`ls /etc/rc.d/rc*.d/S*snmpd 2>/dev/null | tr "[\n]" " "`
    if [ "$CHK" != "" ]; then
      echo "--WARN-- [SNMP002w] The following 'snmpd' service startup script(s) were found: $CHK"
    fi
  #Check the process table
  PS=`ps -ef | grep "snmpd" | grep -v "grep"`
  if [ "$PS" != "" ]; then 
    echo "--FAIL-- [SNMP001f] The SNMP daemon (snmpd) is currently running."
  fi
fi


