/usr/bin/build-pysnmp-mib is in python-pysnmp4 4.2.2-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 | #!/bin/sh
#
# Convert MIB text into PySNMP-compilant MIB/managed objects module.
# See http://pysnmp.sf.net for more information.
#
basedir=$(dirname "$0")
libsmi2pysnmp=$basedir/libsmi2pysnmp # part of pysnmp distro
smidump=smidump # part of libsmi distro
while getopts o: o
do case "$o" in
o) outFile=$OPTARG ;;
[?]) echo >&2 "\
Convert MIB text file into PySNMP-compliant module, see http://pysnmp.sf.net.
Usage: $0 [-o pysnmp-mib-file ] [ mib-text-file ]\
"
exit 1;;
esac
done
[ -n "$outFile" ] && {
exec 5>"$outFile" 1>&5 || { echo >&2 "Redirection failed"; exit 1; }
}
shift $((OPTIND-1))
[ $# -gt 1 ] && { echo >&2 "Extra arguments given"; exit 1; }
[ -z $1 ] && { mibFile="-"; } || {
mibFile=$1;
export SMIPATH="$SMIPATH:$(echo $mibFile | sed -e 's,[^/]*$,.,')";
}
egrep -q 'FROM *RFC' $mibFile 2> /dev/null && ! egrep -q 'FROM *SNMPv2-' $mibFile 2> /dev/null && { oldMib='yes'; } || {
[ $? -eq 1 ] && { oldMib='no'; } || {
echo >&2 "cant open $mibFile";
exit 1;
}
}
[ $oldMib = 'yes' ] && { # pysnmp SMI is SMIv2
[ -x "$(which mktemp)" ] && tmpFile=$(mktemp -t buildmibs.XXXXXXX) || tmpFile=/tmp/buildmibs.$$
$smidump -k -f smiv2 $mibFile > $tmpFile 2> /dev/null || {
[ -f $tmpFile ] && rm -f $tmpFile;
echo >&2 "$smidump -k -f smiv2 $mibFile fails";
echo >&2 "make sure you are using libsmi version > 0.4.5 (or svn)";
exit ;
}
$smidump -k -f python $tmpFile 2> /dev/null | $libsmi2pysnmp || {
[ -f $tmpFile ] && rm -f $tmpFile;
[ -n "$outFile" ] && rm -f $outFile;
echo >&2 "$smidump -k -f python $mibFile | $libsmi2pysnmp fails";
echo >&2 "make sure you are using libsmi version > 0.4.5 (or svn)";
exit
}
rm -f $tmpFile
} || {
$smidump -k -f python $mibFile 2> /dev/null | $libsmi2pysnmp || {
[ -n "$outFile" ] && rm -f $outFile;
echo >&2 "$smidump -k -f python $mibFile | $libsmi2pysnmp fails";
echo >&2 "make sure you are using libsmi version > 0.4.5 (or svn)";
exit
}
}
exit
|