Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. The Lounge
  4. anyone want to play with SNMP?
Forum Updated to NodeBB v4.3 + New Features

anyone want to play with SNMP?

Scheduled Pinned Locked Moved Solved The Lounge
12 Posts 5 Posters 2.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I realize that this is about as un-Qt a topic as we could get, but...I'm running out of places to look, and there are lots of smart people who frequent this forum.

    I have a (non-Qt) embedded application that needs to talk to a server via SNMP. The requirement is excruciatingly simple - I just need to send a trap to the server whenever a particular event occurs on my embedded device.

    It's almost uncanny how little usable information I've been able to find on SNMP. The web is filled with companies who want to offer their management services, but any discussion of message transfers at the byte level is almost nonexistent.

    What I would LOVE is if someone could help me figure out what a trap message looks like -- not a high-level description, but a byte-by-byte example, perhaps even captured by Wireshark.

    I have no intention of implementing a full SNMP agent for this; I just want to send one (mostly pre-formatted) message.

    Thanks for any assistance...

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      Like most folks, my SNMP experience is with existing published MIBs and using them with commercial monitoring systems. I'd suggest looking up internet RFC documents related to SNMP. My specifying RFC you may actually find protocol information. I'm gonna be in a similar boat to you in the coming months. I need to control devices thru SNMP from an embedded board on a spacecraft and I too dont' want to implement a full blown SNMP server system. As this is "the lounge" non-Qt stuff should be fair game.

      I light my way forward with the fires of all the bridges I've burned behind me.

      mzimmersM 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        Like most folks, my SNMP experience is with existing published MIBs and using them with commercial monitoring systems. I'd suggest looking up internet RFC documents related to SNMP. My specifying RFC you may actually find protocol information. I'm gonna be in a similar boat to you in the coming months. I need to control devices thru SNMP from an embedded board on a spacecraft and I too dont' want to implement a full blown SNMP server system. As this is "the lounge" non-Qt stuff should be fair game.

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @Kent-Dorfman I've looked through the RFCs; they're borderline indecipherable. One Wireshark capture of a trap, with the fields decoded, would help more than all of them put together.

        I just have to say how amazed I am at the lack of information available on this topic. I can't even find a book that looks like it covers this.

        aha_1980A 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @Kent-Dorfman I've looked through the RFCs; they're borderline indecipherable. One Wireshark capture of a trap, with the fields decoded, would help more than all of them put together.

          I just have to say how amazed I am at the lack of information available on this topic. I can't even find a book that looks like it covers this.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi @mzimmers,

          I guess the way to go is to set up net-snmp.org, get it compiling, inject your code and then compile your own SNMP server. There are some examples how to do this on http://www.net-snmp.org/wiki/index.php/Tutorials, however, you'll have to invest some time in that topic.

          As for books, there is "Essential SNMP, Second Edition". I think we have that at work too, but I'm not 100% sure.

          Regards

          Qt has to stay free or it will die.

          mzimmersM 1 Reply Last reply
          1
          • aha_1980A aha_1980

            Hi @mzimmers,

            I guess the way to go is to set up net-snmp.org, get it compiling, inject your code and then compile your own SNMP server. There are some examples how to do this on http://www.net-snmp.org/wiki/index.php/Tutorials, however, you'll have to invest some time in that topic.

            As for books, there is "Essential SNMP, Second Edition". I think we have that at work too, but I'm not 100% sure.

            Regards

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            @aha_1980 I'm willing to do that if I have to, but I'm not sure how much good that will do. I need an example of a trap message, and can't find a resource that shows me one.

            I do have the book you mention on order; perhaps that will shed more light on this amazingly arcane subject.

            aha_1980A Pablo J. RoginaP 2 Replies Last reply
            0
            • mzimmersM mzimmers

              @aha_1980 I'm willing to do that if I have to, but I'm not sure how much good that will do. I need an example of a trap message, and can't find a resource that shows me one.

              I do have the book you mention on order; perhaps that will shed more light on this amazingly arcane subject.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mzimmers Yeah, I have the book; but it mostly covers the administrators view on the topic, not the programmers.

              However, it is a great overview over the technology, and will gain you more undestanding.

              Have you already seen http://www.net-snmp.org/wiki/index.php/TUT:snmptrap Probably that's already enough for your case?

              Regards

              Qt has to stay free or it will die.

              mzimmersM 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @aha_1980 I'm willing to do that if I have to, but I'm not sure how much good that will do. I need an example of a trap message, and can't find a resource that shows me one.

                I do have the book you mention on order; perhaps that will shed more light on this amazingly arcane subject.

                Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @mzimmers from the snmptrap tutorial link that @aha_1980 suggested, I guess you can follow it and use the snmptrap command to generate some sample traps that you can capture and analyze with Wireshark.

                In addition, you may want to look at the source code of such command, and you'll see some of the internals...

                 pdu = snmp_pdu_create(SNMP_MSG_TRAP);
                

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                1
                • aha_1980A aha_1980

                  @mzimmers Yeah, I have the book; but it mostly covers the administrators view on the topic, not the programmers.

                  However, it is a great overview over the technology, and will gain you more undestanding.

                  Have you already seen http://www.net-snmp.org/wiki/index.php/TUT:snmptrap Probably that's already enough for your case?

                  Regards

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #8

                  @aha_1980 the net-snmp page is useful but still doesn't give me the particulars of the message format that I need.

                  @Pablo-J-Rogina good suggestion -- the source code helps, though the fields seem somewhat inconsistent with those on this page. I'll keep reading through it.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    Jesse4586
                    Banned
                    wrote on last edited by
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by
                      #10

                      Just to bring this to closure: I managed to obtain an example of an SNMP trap message, and after doing some byte-by-byte decoding, I figured out what each byte meant. Then I was able to modify (by hand) to get the trap configured for my application.

                      For the morbidly curious, here's the code that defines the byte array, with copious annotations. T&L refer to type and length (from TLV). The encoding is some form of BER. Doesn't SNMP look fun?

                      int Worker::sendTrap()
                      {
                          int rc = ESP_OK;
                          // the byte array below forms a v1 trap
                          const uint8_t trap[] = {
                              0x30, // ASN.1 header
                              0x45, // ***** length of remainder of packet
                                  0x02, 0x01, 0x00, // version v1
                                  0x04, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, // community "public"
                                  0xa4, 0x38, // ***** T&L for remainder of packet
                                      0x06, 0x0f, // ***** T&L for enterprise
                                          0x2b, 0x06, 0x01, 0x04, 0x01,
                                          //0x81, 0x88, 0x53, // encoding for 17491
                                          0x82, 0xe7, 0x01, // encoding for 45953
                                          0x01, 0x01, 0x02, 0x01, 0x02, 0x81, 0x49,
                                      0x40, 0x04, // ***** T&L for agent IP address
                                      0x0, 0x0, 0x0, 0x0, // agent IP address (will be filled in below)
                                      0x02, 0x01, 0x01, // ***** generic trap (warmStart)
                                      0x02, 0x01, 0x00, // ***** specific trap (0)
                                      0x43, 0x01, 0x00, // ***** timestamp
                                      0x30, 0x16, // ***** T&L for varbind 1
                                          0x30, 0x14, // **** T&L for varbind 1 name
                                              0x06, 0x0f, 0x2b, 0x06, 0x01, 0x04, 0x01,
                                              //0x81, 0x88, 0x53, // encoding for 17491
                                              0x82, 0xe7, 0x01, // encoding for 45953
                                              0x01, 0x01, 0x02, 0x01, 0x02,
                                              0x81, 0x49, // encoding for 201
                                              0x02, 0x01, 0x01 // ***** varbind value (1)
                      
                          };
                      

                      Anyway, thanks to everyone who looked and helped.

                      Kent-DorfmanK 1 Reply Last reply
                      2
                      • mzimmersM mzimmers

                        Just to bring this to closure: I managed to obtain an example of an SNMP trap message, and after doing some byte-by-byte decoding, I figured out what each byte meant. Then I was able to modify (by hand) to get the trap configured for my application.

                        For the morbidly curious, here's the code that defines the byte array, with copious annotations. T&L refer to type and length (from TLV). The encoding is some form of BER. Doesn't SNMP look fun?

                        int Worker::sendTrap()
                        {
                            int rc = ESP_OK;
                            // the byte array below forms a v1 trap
                            const uint8_t trap[] = {
                                0x30, // ASN.1 header
                                0x45, // ***** length of remainder of packet
                                    0x02, 0x01, 0x00, // version v1
                                    0x04, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, // community "public"
                                    0xa4, 0x38, // ***** T&L for remainder of packet
                                        0x06, 0x0f, // ***** T&L for enterprise
                                            0x2b, 0x06, 0x01, 0x04, 0x01,
                                            //0x81, 0x88, 0x53, // encoding for 17491
                                            0x82, 0xe7, 0x01, // encoding for 45953
                                            0x01, 0x01, 0x02, 0x01, 0x02, 0x81, 0x49,
                                        0x40, 0x04, // ***** T&L for agent IP address
                                        0x0, 0x0, 0x0, 0x0, // agent IP address (will be filled in below)
                                        0x02, 0x01, 0x01, // ***** generic trap (warmStart)
                                        0x02, 0x01, 0x00, // ***** specific trap (0)
                                        0x43, 0x01, 0x00, // ***** timestamp
                                        0x30, 0x16, // ***** T&L for varbind 1
                                            0x30, 0x14, // **** T&L for varbind 1 name
                                                0x06, 0x0f, 0x2b, 0x06, 0x01, 0x04, 0x01,
                                                //0x81, 0x88, 0x53, // encoding for 17491
                                                0x82, 0xe7, 0x01, // encoding for 45953
                                                0x01, 0x01, 0x02, 0x01, 0x02,
                                                0x81, 0x49, // encoding for 201
                                                0x02, 0x01, 0x01 // ***** varbind value (1)
                        
                            };
                        

                        Anyway, thanks to everyone who looked and helped.

                        Kent-DorfmanK Offline
                        Kent-DorfmanK Offline
                        Kent-Dorfman
                        wrote on last edited by
                        #11

                        @mzimmers OMG, that is sooooo ugly. God bless you man, for figuring it out. Hope it works for you.

                        I light my way forward with the fires of all the bridges I've burned behind me.

                        mzimmersM 1 Reply Last reply
                        1
                        • Kent-DorfmanK Kent-Dorfman

                          @mzimmers OMG, that is sooooo ugly. God bless you man, for figuring it out. Hope it works for you.

                          mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by
                          #12

                          @Kent-Dorfman heh...as bad as that is, I found it easier than trying to build an agent (or even a part of an agent). And (drumroll please)...to my mind, both are easier than figuring out how to write MIBs!

                          SNMP is for machines, by machines. Humans need not apply.

                          1 Reply Last reply
                          1

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved