#!/usr/bin/perl

###############################################################################
#                                                                             #
# Filename: bakSNMPTrap                                                       #
#                                                                             #
# Description:                                                                #
#                                                                             #
###############################################################################
###############################################################################
#                                                                             #
#  Copyright  2000 - 2001 Intel Corporation.                                 #
#  Intel Corporation All Rights Reserved.                                     #
#                                                                             #
#  The source code contained or described herein and all documents related to #
#  the source code ("Material") are owned by Intel Corporation or its         #
#  suppliers or licensors.  Title to the Material remains with Intel          #
#  Corporation or its suppliers and licensors.  The Material contains trade   #
#  secrets and proprietary and confidential information of Intel or its       #
#  suppliers and licensors.  The Material is protected by worldwide copyright #
#  and trade secret laws and treaty provisions.  No part of the Material may  #
#  be used, copied, reproduced, modified, published, uploaded, posted,        #
#  transmitted, distributed, or disclosed in any way without Intel's prior    #
#  express written permission.                                                #
#                                                                             #
#  No license under any patent, copyright, trade secret or other intellectual #
#  property right is granted to or conferred upon you by disclosure or        #
#  delivery of the Materials, either expressly, by implication, inducement,   #
#  estoppel or otherwise. Any license under such intellectual property rights #
#  must be express and approved by Intel in writing.                          #
#                                                                             #
###############################################################################

#-----------------------------------------------------------------------------
#	Structures

#	Commands available for the associated ASM OID.
$oid{"ERACPU Temperature"}	= ".1.3.6.1.4.1.343.2.10.3.3.4";
$oid{"ERACPUTemp"} 		    = ".1.3.6.1.4.1.343.2.10.3.3.4";
$oid{"ERA+12v"} 			= ".1.3.6.1.4.1.343.2.10.3.3.5";
$oid{"ERA-12v"} 			= ".1.3.6.1.4.1.343.2.10.3.3.6";
$oid{"ERA+5v"} 			    = ".1.3.6.1.4.1.343.2.10.3.3.7";
$oid{"ERA+3.3v"} 			= ".1.3.6.1.4.1.343.2.10.3.3.8";
$oid{"ERA+Vcore"} 			= ".1.3.6.1.4.1.343.2.10.3.3.10";
$oid{"ERA+Vio"} 			= ".1.3.6.1.4.1.343.2.10.3.3.9";
$oid{"ERAInt"} 			    = ".1.3.6.1.4.1.343.2.10.3.3.11";
$oid{"ERADisk"}				= ".1.3.6.1.4.1.343.2.10.3.3.24.1.3";
$oid{"PFCPUTemp"} 			= ".1.3.6.1.4.1.343.2.10.3.3.26";
$oid{"PF+12v"} 				= ".1.3.6.1.4.1.343.2.10.3.3.14";
$oid{"PF-12v"} 				= ".1.3.6.1.4.1.343.2.10.3.3.15";
$oid{"PF+5V"} 				= ".1.3.6.1.4.1.343.2.10.3.3.16";
$oid{"PF+3.3v"} 			= ".1.3.6.1.4.1.343.2.10.3.3.17";
$oid{"PF+Vcore"} 			= ".1.3.6.1.4.1.343.2.10.3.3.18";
$oid{"PF+Vio"} 				= ".1.3.6.1.4.1.343.2.10.3.3.19";
$oid{"PFCPUUtil"} 			= ".1.3.6.1.4.1.343.2.10.3.3.20";
$oid{"PFMemUtil"} 			= ".1.3.6.1.4.1.343.2.10.3.3.21";
$oid{"PFSingle-bit"} 		= ".1.3.6.1.4.1.343.2.10.3.3.22";

$threshold{"1"} = "1";
$threshold{"2"} = "2";
$threshold{"3"} = "3";
$threshold{"4"} = "4";
$threshold{"5"} = "5";

$intrusion{"1"} = "0";
$intrusion{"2"} = "1";

$id = $ARGV[0];
$my_threshold = $ARGV[1];
$dest = $ARGV[2];

if( exists($oid{$id} ) )
{
	if($id =~ "Int" || $id =~ "PFCPUUtil" || $id =~ "PFMemUtil" || $id =~ "PFSingle-bit")
	{
		$my_threshold = $intrusion{$my_threshold};
	}else{
		$my_threshold = $threshold{$my_threshold};
	}
	system("/usr/bin/snmptrap $dest public .1.3.6.1.4.1.343.2.10.3.3 $dest 6 25 '' $oid{$id} i $my_threshold");
}elsif($id =~ /^ERAFan[0-9]*$/)
{
 	$id = substr($id, 6);
   	$my_threshold = $threshold{$my_threshold};
  	system("/usr/bin/snmptrap $dest public .1.3.6.1.4.1.343.2.10.3.3 $dest 6 25 '' .1.3.6.1.4.1.343.2.10.3.3.23.1.1 i $id .1.3.6.1.4.1.343.2.10.3.3.23.1.2  i $my_threshold");
}elsif( $id =~ /^ERADisk.*$/ )
{
	$id = substr($id, 7);
	$id =~ tr/[A-Z]/[a-z]/;
    system("/usr/bin/snmptrap $dest public .1.3.6.1.4.1.343.2.10.3.3 $dest 6 25 '' .1.3.6.1.4.1.343.2.10.3.3.3 s \/dev\/hd$id .1.3.6.1.4.1.343.2.10.3.3.13  i $my_threshold");
}

