#!/bin/bash

# Arguments:
#  $1 = trap type

# First line passed from snmptrapd is FQDN of host that sent the trap
read host
read ipaddress

# Given a FQDN, get the short name of the host as it is setup in Nagios
hostname=$host
case $host in
	unknown)
	;;
	SMAJ01JFK352V.demat.sopragroup.fra|SMAJ01JFK352V)
		hostname="ir1aeva1"
	;;
	192.168.0.120)
		hostname="as1bdem1"
	;;
	192.168.0.1)
		hostname="is1bfw01"
	;;
esac
		

# Get severity level (OK, WARNING, UNKNOWN, or CRITICAL) and plugin output based on trape type
state=0
output="No output"
case "$1" in
	1)
		service="Test Trap"
		output="Test"
		state=2
	;;
	2)
		service="Test Trap"
		output="Test"
	;;
	# failed to format tape - critical
	7)
		output="Critical: hp OpenView storage management appliance"
		state=2
	
	;;
esac


# Submit passive check result to monitoring host
/usr/lib/nagios/plugins/eventhandlers/submit_check_result $hostname "$service" $state "$output"

exit 0
