Module org.snmp4j

Class SnmpCommand

    • Field Detail

      • V3_AUTH_PRIV_PROTOCOL

        private static final java.lang.String V3_AUTH_PRIV_PROTOCOL
        See Also:
        Constant Field Values
      • SNMPV3_ONLY_OPTIONS

        private static final java.lang.String SNMPV3_ONLY_OPTIONS
        See Also:
        Constant Field Values
      • ADDRESS_PARAMETER

        private static final java.lang.String ADDRESS_PARAMETER
        See Also:
        Constant Field Values
      • OPT_OID_PARAMETER

        private static final java.lang.String OPT_OID_PARAMETER
        See Also:
        Constant Field Values
      • OIDLIST_PARAMETER

        private static final java.lang.String OIDLIST_PARAMETER
        See Also:
        Constant Field Values
      • OPT_OIDLIST_PARAMETER

        private static final java.lang.String OPT_OIDLIST_PARAMETER
        See Also:
        Constant Field Values
      • COMMANDS

        private static final java.lang.String[][] COMMANDS
      • OP_USM_DH_KICKSTART_INIT

        private static final int OP_USM_DH_KICKSTART_INIT
        See Also:
        Constant Field Values
      • OP_USM_DH_KICKSTART_RUN

        private static final int OP_USM_DH_KICKSTART_RUN
        See Also:
        Constant Field Values
      • packetDumpEnabled

        private static boolean packetDumpEnabled
      • authProtocol

        OID authProtocol
      • privProtocol

        OID privProtocol
      • authoritativeEngineID

        OctetString authoritativeEngineID
      • trapOID

        OID trapOID
      • version

        int version
      • engineBootCount

        int engineBootCount
      • retries

        int retries
      • timeout

        int timeout
      • pduType

        int pduType
      • maxSizeResponsePDU

        int maxSizeResponsePDU
      • snapshotFile

        java.io.File snapshotFile
      • operation

        protected int operation
      • numDispatcherThreads

        int numDispatcherThreads
      • useDenseTableOperation

        boolean useDenseTableOperation
      • stdoutWidth

        private static int stdoutWidth
      • lowerBoundIndex

        OID lowerBoundIndex
      • upperBoundIndex

        OID upperBoundIndex
      • settings

        java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> settings
      • command

        java.lang.String command
      • err

        private static java.io.PrintStream err
      • out

        private static java.io.PrintStream out
      • help

        private static java.util.ResourceBundle help
      • tabs

        private static int[] tabs
      • silent

        private static boolean silent
      • returnCode

        private int returnCode
    • Constructor Detail

      • SnmpCommand

        public SnmpCommand​(java.lang.String command,
                           java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> args)
                    throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • assignOptions

        private void assignOptions​(java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> args)
      • parseOIDs

        private void parseOIDs​(java.util.Map<java.lang.String,​java.util.List<java.lang.Object>> args)
                        throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • addUsmUser

        private void addUsmUser​(Snmp snmp)
      • help

        public java.lang.String help​(java.lang.String prefix,
                                     java.lang.String command,
                                     boolean listOptionsDetails,
                                     boolean withDescription)
      • example

        public java.lang.String example​(java.lang.String prefix,
                                        java.lang.String command)
      • optionList

        private java.lang.String optionList​(int indentation,
                                            java.lang.String prefix,
                                            java.lang.String command)
      • options

        private java.lang.String options​(int indentation,
                                         java.lang.String prefix,
                                         java.lang.String command)
      • optionDetailList

        private void optionDetailList​(int indentation,
                                      java.lang.String prefix,
                                      java.lang.StringBuffer buf,
                                      java.util.SortedMap<java.lang.String,​ArgumentParser.ArgumentFormat> soptions)
      • selectFormat

        private java.lang.String[] selectFormat​(java.lang.String command)
      • tab

        private static java.lang.String tab​(int offset,
                                            int position,
                                            int tabNo)
      • getTabPosition

        private static int getTabPosition​(int tabNo)
      • format

        private static java.lang.String format​(int indentation,
                                               java.lang.String s,
                                               int tabNo,
                                               int firstLineOffset)
      • wrap

        private static java.lang.String wrap​(int offset,
                                             java.lang.String s,
                                             int maxLineLength,
                                             int firstLineOffset)
      • spaces

        public static java.lang.String spaces​(int n)
      • send

        public PDU send()
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • checkTrapVariables

        private void checkTrapVariables​(java.util.List<VariableBinding> vbs,
                                        int pduType,
                                        OID trapOID,
                                        TimeTicks sysUpTime)
      • printReport

        protected static void printReport​(PDU response)
      • processPdu

        public <A extends Address> void processPdu​(CommandResponderEvent<A> e)
        Description copied from interface: CommandResponder
        Process an incoming request, report or notification PDU.
        Specified by:
        processPdu in interface CommandResponder
        Type Parameters:
        A - type of the peer Address.
        Parameters:
        e - a CommandResponderEvent instance containing the PDU to process and some additional information returned by the message processing model that decoded the SNMP message.
      • printVariableBindings

        protected static void printVariableBindings​(PDU response)
      • table

        public int table()
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • createSnapshot

        private void createSnapshot​(java.util.List<?> snapshot)
      • dumpSnapshot

        private int dumpSnapshot()
      • walk

        private PDU walk​(Snmp snmp,
                         PDU request,
                         Target<?> target,
                         java.util.List<VariableBinding> snapshot)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • getVariableBindings

        private static java.util.List<VariableBinding> getVariableBindings​(java.lang.String[] args,
                                                                           int position)
      • getAddress

        private static Address getAddress​(java.lang.String transportAddress)
      • listen

        public int listen()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • main

        public static void main​(java.lang.String[] args)
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • getUserEngineID

        private byte[] getUserEngineID()
      • printVersion

        protected static void printVersion()
      • printUsage

        public static void printUsage()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • processMessage

        public <A extends Address> void processMessage​(TransportMapping<? super A> sourceTransport,
                                                       A incomingAddress,
                                                       java.nio.ByteBuffer wholeMessage,
                                                       TransportStateReference tmStateReference)
        Description copied from interface: TransportListener
        Processes an incoming message.
        Specified by:
        processMessage in interface TransportListener
        Type Parameters:
        A - the Address type.
        Parameters:
        sourceTransport - a TransportMapping instance denoting the transport that received the message and that will be used to send any responses to this message. The sourceTransport has to support the incomingAddress's implementation class.
        incomingAddress - the Address from which the message has been received.
        wholeMessage - an ByteBuffer containing the received message.
        tmStateReference - the transport model state reference as defined by RFC 5590.
      • processMessage

        public void processMessage​(TransportMapping<?> sourceTransport,
                                   Address destAddress,
                                   byte[] message)