/usr/sbin/snmpttconvert is in snmptt 1.4-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | #!/usr/bin/perl
#
# SNMPTTCONVERT v1.4
#
# Copyright 2002-2013 Alex Burger
# alex_b@users.sourceforge.net
#
# 4/11/2002
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
##############################################################################
use strict;
#
# http://www.sourceforge.net/projects/snmptt
#
# Debugging: 0 = no output messages
# 1 = output some basic messages
# 2 = out all messages
use constant DEBUGGING => 0;
# Set this to '' to have no default EXEC line added, or modify as needed.
#$defaultexec = '';
my $defaultexec = '#EXEC qpage -f TRAP notifygroup1 "';
if (DEBUGGING >= 1)
{
print "\nLoading @ARGV\n";
}
my @trapdconf;
while (<>)
{
chomp; #remove <cr> at end of line
s/\015//; # Remove any DOS carriage returns
push(@trapdconf, $_); #add to each line to @trapconf array
}
if (DEBUGGING >= 1)
{
print "Finished loading\n\n";
}
my $currentline=0;
my ($line, $line2, $line3, $line4);
my $temp;
while ($currentline <= $#trapdconf)
{
$line = $trapdconf[$currentline];
# $_ = 'COMPAQ_11001 {.1.3.6.1.4.1.232} 6 11001 A "LOGONLY" 1';
# enterprise = .1.3.6.1.4.1.232
# 6 means it's an enterprise trap so do enterprise.0.specific below
# specific = 11001
if ( $line =~ /(\w+)\s+\{(.*)\}\s+(\d+)\s+(\d+)\s+([CAMcam-])\s+(".+").*/ )
{
if ($3 == 6)
{
$temp = "EVENT $1 $2.0.$4 $6 Normal";
}
else
{
$temp = "EVENT $1 $2.$4 $6 Normal"; # Not sure if this is correct
}
print "#\n#\n#\n";
print "$temp\n";
$currentline++; # Increment to the next line
$line3 = $trapdconf[$currentline];
# FORMAT line
print "FORMAT $line3\n";
if ($defaultexec ne '')
{
print $defaultexec.$line3,"\"\n";
}
$currentline++; # Increment to the next line
$line3 = $trapdconf[$currentline];
while ( ($currentline <= $#trapdconf) &&
!($line3 =~ /(\w+)\s+\{(.*)\}\s+(\d+)\s+(\d+)\s+([CAMcam])\s+(".+").*/ ) )
{
# Keep going through the file until the next EVENT or the end of trapd.conf
# is reached
# Check to see if next line is a FORMAT line (it should be!)
if ($line3 =~ /^SDESC/)
{
# It's a SDESC line
print "SDESC\n";
$currentline++; # Increment to the next line
$line4 = $trapdconf[$currentline];
while (! ($line4 =~ /^EDESC/) )
{
print $line4,"\n";
$currentline++; # Increment to the next line
$line4 = $trapdconf[$currentline];
}
print "EDESC\n";
}
$currentline++; # Increment to the next line
$line3 = $trapdconf[$currentline];
}
$currentline--;
}
$currentline++; # Increment to the next line
$line2 = $trapdconf[$currentline]; # Get next line
}
|