File: snmptrap.pl

package info (click to toggle)
libsnmp-session-perl 1.14~git20221124T101957-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,104 kB
  • sloc: perl: 11,920; ansic: 25; makefile: 15
file content (83 lines) | stat: -rw-r--r-- 1,970 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /usr/local/bin/perl5
# -*- mode: Perl -*-
BEGIN{
$main::OS = 'UNIX';
#$main::OS = 'NT';
#$main::OS = 'VMS';
##################################################################
   # The path separator is a slash, backslash or semicolon, depending
   # on the platform.
   $main::SL = {
     UNIX=>'/',
     WINDOWS=>'\\',
     NT=>'\\',
     VMS=>''
     }->{$main::OS};

   # The search path separator is a colon or semicolon depending on the
   # operating system.
   $main::PS = {
     UNIX=>':',
     WINDOWS=>';',
     NT=>';',
     VMS=>':'
     }->{$main::OS};

  # We need to find the place where this is installed, and
  # then take the .pm programms from there.
  $main::binpath ="";
  if ($0 =~ /^(.+\Q${main::SL}\E)/) {
    $main::binpath="$1";
  } else {
    foreach $pathname ( split ${main::PS}, $ENV{'PATH'}) {
      if ((($main::OS eq 'NT') &&
           (-e "$pathname${main::SL}$0")) ||
           (-x "$pathname${main::SL}$0")) {
	$main::binpath=$pathname;
  	last;
      }
    }
  }
  die "ERROR: Can\'t find location of mrtg executable\n" 
    unless $main::binpath; 
  unshift (@INC,$main::binpath);
}

# The older perls tend to behave peculiar with
# large integers ... 
require 5.003;

if ($main::OS eq 'UNIX' || $main::OS eq 'NT') {
    use SNMP_util "0.54";
    $main::SNMPDEBUG =0;
}

use strict;

$main::DEBUG=0;

sub main {
  
  my($trapid, $sev, $message);
  my($machine, $ret);
  # unbuffer stdout to see everything immediately
  $|=1 if $main::DEBUG;   

  $trapid = 1100;
  $sev = "Major";
  $message = "MCM -- I'm testing, please ignore";
  $machine = `hostname` ;
  chop($machine);

  $ret = &snmptrap("dizzy.unx.sas.com", "",
		"1.3.6.1.4.1.11.2.17.1", $machine, 6, $trapid, 
		"1.3.6.1.4.1.11.2.17.2.1.0", "Integer", 14,
		"1.3.6.1.4.1.11.2.17.2.2.0", "OctetString", $machine,
		"1.3.6.1.4.1.11.2.17.2.4.0", "OctetString", $message,
		"1.3.6.1.4.1.11.2.17.2.5.0", "OctetString", $sev);

  print "ret = <$ret>\n";
}

main;
exit(0);