Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. SSH DCI Collection

SSH DCI Collection

Scheduled Pinned Locked Moved Support
13 Posts 2 Posters 45.9k Views
  • 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.
  • L
    L
    lweidig
    wrote on last edited by
    #4

    Here is the Parameter we use for the DCI:

    :global inPool "client";/system script run dhcpPoolMon
    

    The script simply counts up the total number of leases available / in use in that DHCP pool and reports back with a JSON formatted response.  The script is:

    :global inPool
    
    :local ipUsed 0
    :local ipTotal 0
    :local nextPool $inPool
    :local currPool
    
    # Process the pool passed in and any next pools as one block
    :do {
      :set currPool $nextPool
    #  Each pool can have multiple ranges listed
      :foreach range in=[/ip pool get "$currPool" ranges] do={
        :local rangeString [:tostr  $range]
        :local ipStart [:toip [:pick $rangeString 0 [:find $rangeString "-"]]]
        :local ipEnd [:toip [:pick $rangeString ([:find $rangeString "-"] + 1) 31]]
        :set ipTotal ($ipTotal + $ipEnd - $ipStart + 1)
    #   Read through leases and count ones in this pool
        /ip dhcp-server lease
        :foreach i in=[find] do={
          :local ipActive [:toip [get $i active-address]]
          :if (($ipActive >= $ipStart) && ($ipActive <= $ipEnd)) do={
            :set ipUsed ($ipUsed + 1)
          }
        }
      }
      :set nextPool [:tostr  [/ip pool get "$currPool" next-pool]]
    } while ([:len $nextPool] > 1)
    
    put "{total:$ipTotal, used:$ipUsed}"
    

    That way pools can be expanded prior to being exhausted.  Thanks!

    1 Reply Last reply
    0
    • L
      L
      lweidig
      wrote on last edited by
      #5

      @Victor - Wondering if you have had any opportunity to look into this.  We are running 3.9.420 and still having issues with this.

      1 Reply Last reply
      0
      • V
        V
        Victor Kirhenshtein
        wrote on last edited by
        #6

        Hi,

        I just configured it on my home Mikrotik routers and it works, so I suspect it has something to do with Mikrotik firmware version. Mine have 7.1.1 and 6.49.1.
        I will also check if I can add additional diagnostic to SSH subagent.

        Best regards,
        Victor

        1 Reply Last reply
        0
        • L
          L
          lweidig
          wrote on last edited by
          #7

          Ours is running 6.48.6 which is in the long term channel where we like to be.  We might have one running 6.49.1 and I will look around, but we have not yet ventured into the 7.x.x line.  You are a brave man - though you did say it was at home.  I might upgrade my home one to that and see as well.  Is your server Ubuntu 20.04 as well? 

          Could you post the SSH properties setup on the Node and also the General properties for the DCI.  I just keep thinking something is not right on my side.

          Appreciate the assistance!

          1 Reply Last reply
          0
          • V
            V
            Victor Kirhenshtein
            wrote on last edited by
            #8

            Hi,

            I did some more accurate testing and it seems to be my failure - I manage to get same error with agent 3.9, but it works fine if built from master branch. So looks like we already fixed something, I just have to find out what exactly 🙂

            Best regards,
            Victor

            1 Reply Last reply
            0
            • V
              V
              Victor Kirhenshtein
              wrote on last edited by
              #9

              So, after more digging and experimenting, it looks like a bug in libssh (that one: https://github.com/ParallelSSH/ssh-python/issues/23, https://bugzilla.redhat.com/show_bug.cgi?id=1849069), said to be present in libssh versions up to 0.9.5. I've tested agent with libssh 0.9.6 and it works stable as expected. Master branch behaves a bit better with older libssh because of different timing (caused by internal structure changes), but still runs into this error periodically.
              Unfortunately, Ubuntu 20 comes with libssh 0.9.3, and I suppose they will not update it to 0.9.6 or newer. I will add workaround for that bug (interpret remote channel closure as success if some data was received before), that should fix it for our purposes.

              Best regards,
              Victor

              1 Reply Last reply
              0
              • L
                L
                lweidig
                wrote on last edited by
                #10

                Was hoping this was resolved in 4.0.2157 as I saw this in release notes:

                • Improved SSH subagent

                The issue still however persists with this release.

                1 Reply Last reply
                0
                • V
                  V
                  Victor Kirhenshtein
                  wrote on last edited by
                  #11

                  Hello,

                  I tried to reproduce this issue with latest agent, but it works as expected for me. Are you sure agent used as a proxy for SSH connection was upgraded to 4.0.2157? If yes, please try to set debug level to 8 and send me excerpt from the log around request for parameter SSH.Command.

                  Best regards,
                  Victor

                  1 Reply Last reply
                  0
                  • L
                    L
                    lweidig
                    wrote on last edited by
                    #12

                    If I actually remove the agent and let it poll directly from the server with the node containing the credentials I seem to be getting the results now.  Will test this on a larger batch of devices, but hoping with that configuration setup it will work.  No agent involved at all.  Thanks for checking into this!

                    1 Reply Last reply
                    0
                    • V
                      V
                      Victor Kirhenshtein
                      wrote on last edited by
                      #13

                      Actually, agent is already involved in SSH polling. If SSH proxy is not specified server will use it's local agent as a proxy.

                      Best regards,
                      Victor

                      1 Reply Last reply
                      0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      Powered by NodeBB Contributors
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups