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. help with aggregate DCI

help with aggregate DCI

Scheduled Pinned Locked Moved Support
15 Posts 6 Posters 31.7k 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.
  • T
    T
    Tursiops
    wrote on last edited by
    #4

    Hi,

    The following should work.

    searchTimeTotal = 0;
    activeDCIs=0;
    foreach (dci : FindAllDCIs($node,"\\MSExchange ADAccess Domain Controllers(*)\\LDAP Search Time") )
    {
    	dciValue = GetDCIValue($node,dci->id);
    	if ( dciValue == null ) continue; // To skip in case of errors
    	searchTimeTotal+=dciValue;
    	activeDCIs++;
    }
    return format((searchTimeTotal/activeDCIs),2); // You may want to change the number of decimals or round instead.
    

    Cheers

    1 Reply Last reply
    0
    • E
      E
      Egert143
      wrote on last edited by
      #5

      Hello

      Sorry for digging up an old topic. Is this script supposed to work with current version ?

      I made new script out of it and changed line:

      "foreach (dci : FindAllDCIs($node,"\\MSExchange ADAccess Domain Controllers(*)\\LDAP Search Time") )"
       to
      "foreach (dci : FindAllDCIs($node,"Cpu *") )".

      then added new dci with origin script and parameter selected as above script, i get result: -nan(ind) / result 0.

      data looks like:

      Cpu 1, Cpu 2, Cpu 3 etc. What am i dooing wrong ?

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

        Hi,

        yes, script is valid, but you have to remember that it search DCIs by name (parameter name). Are you sure you have parameter names Cpu 1, etc. and not DCI descriptions?

        Best regards,
        Victor

        1 Reply Last reply
        0
        • E
          E
          Egert143
          wrote on last edited by
          #7

          Nice got that bit to work, indeed i was mixing parameter name and description.

          But i have one tiny problem still: The cpu dci-s are auto generated by instance, and ".1.3.6.1.2.1.25.3.3.1.2.{instance}" counts as result also when searching with "foreach (dci : FindAllDCIs($node,".1.3.6.1.2.1.25.3.3.1.2.*") )", how can i filter that one out ?

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

            You can do something like

            for (dci : FindAllDCIs($node, ".1.3.6.1.2.1.25.3.3.1.2.*"))
            {
               if (dci->name like "*{instance}")
                  continue;
               // your code here
            }
            

            Best regards,
            Victor

            1 Reply Last reply
            0
            • E
              E
              Egert143
              wrote on last edited by
              #9

              When i add "dciValueB = GetDCIValue($node,dci->name);" then i already get dci unsupported error.

              When i use "if (dci->name like "*{instance}") continue;" it doesent match.

              1 Reply Last reply
              0
              • Z
                Z
                Tatjana Dubrovica
                wrote on last edited by
                #10

                @egert143 said in help with aggregate DCI:

                When i add "dciValueB = GetDCIValue($node,dci->name);" then i already get dci unsupported error.

                When i use "if (dci->name like "*{instance}") continue;" it doesent match.

                You should do: "dciValueB = GetDCIValue($node,dci->id);"
                As GetDCIValue requires node object and DCI id as a parameters: https://www.netxms.org/documentation/nxsl-3.0/#func-getdcivalue

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

                  @egert143 said in help with aggregate DCI:

                  When i use "if (dci->name like "*{instance}") continue;" it doesent match.

                  Please share full script code. I checked on my system and it works as expected.

                  Best regards,
                  Victor

                  1 Reply Last reply
                  0
                  • E
                    E
                    Egert143
                    wrote on last edited by
                    #12
                    searchTimeTotal = 0;
                    activeDCIs=1;
                    
                    foreach (dci : FindAllDCIs($node,".1.3.6.1.2.1.25.3.3.1.2.*") )
                    {
                    
                    	dciValue = GetDCIValue($node,dci->id);
                    
                    	if ( dci->name like "*{instance}" ) continue;
                    
                    
                    	if ( dciValue == null ) continue;
                    
                    
                    	searchTimeTotal+=dciValue;
                    	activeDCIs++;
                    }
                    
                    return activeDCIs;
                    //return round(searchTimeTotal/activeDCIs,2);
                    

                    Cpu DCI:
                    Description: Cpu {instance}
                    parameter: .1.3.6.1.2.1.25.3.3.1.2.{instance}
                    discovery: snmp walk:.1.3.6.1.2.1.25.3.3.1.2

                    the result i am looking for should be 36 (36 cores), but i am getting 37 instead.

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

                      You initialize variable activeDCIs to 1, which gives you incorrect result - if you have 36 cores line

                      activeDCIs++;

                      will be execured 36 times and result will be 37.

                      Best regards,
                      Victor

                      1 Reply Last reply
                      0
                      • E
                        E
                        Egert143
                        wrote on last edited by
                        #14

                        Such a simple mistake. 🙂 Got it working now, many thanks.

                        1 Reply Last reply
                        0
                        • H
                          H
                          Hospital
                          wrote on last edited by
                          #15

                          Thumbs up for this topic! To calculate Total Space Used on all filesystems, into single aggregate DCI:

                          UsedSpaceTotal=0;
                          foreach (dci : FindAllDCIs($node,"FileSystem.Used*") )
                          {
                          	dciValue = GetDCIValue($node,dci->id);
                          	if ( dciValue == null ) continue; // To skip in case of errors
                          	UsedSpaceTotal+=dciValue;
                          }
                          return UsedSpaceTotal;
                          
                          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