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. DCI filter script - how to ignore some filesystems when using {instance} ?

DCI filter script - how to ignore some filesystems when using {instance} ?

Scheduled Pinned Locked Moved Support
18 Posts 7 Posters 60.0k 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.
  • S
    S
    sharpspro
    wrote on last edited by
    #5

    That worked great. Thank you so much!

    1 Reply Last reply
    0
    • S
      S
      sharpspro
      wrote on last edited by
      #6

      The issue I see with this is when a CD disk does not report its value as ERROR and starts reporting the value as "0". An example of this would be when a CD/DVD is put into the drive and the reported value changes from ERROR to 0 (zero) space available and the threshold alert will be sent.

      My question is, is there a way to exclude CD/DVD drives completely with this filter? Or is there another work around to get this accomplished?

      Below is how I have the scrpit currently:
      if (rindex($1,":")>0)
      {
      // if(length($1)>3) return false;
      if (rindex($1,"A:")>0) return false;
      value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")");
      return (value != null) && (value > 0);
      //return %(true, $1);
      }
      return false;

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

        Hi,

        in version 2.0-M3 I've added new parameter FileSystem.Type, so with agent version 2.0-M3 you can filter out CDs as following:

        if (rindex($1,":")>0)
        {
           type = AgentReadParameter($node, "FileSystem.Type(" . $1 . ")");
           // exclude CDs:
           return (value != null) && (value != "CDFS");
           // if only NTFS systems are of interest (usual situation):
           // return value == "NTFS";
        }
        return false;
        

        Best regards,
        Victor

        1 Reply Last reply
        0
        • S
          S
          sharpspro
          wrote on last edited by
          #8

          Hi Victor,

          Thanks for the reply! When will that version 2.0-M3 be available?

          Thanks!

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

            Most likely next week, or week after in worst case.

            Best regards,
            Victor

            1 Reply Last reply
            0
            • S
              S
              sharpspro
              wrote on last edited by
              #10

              Guys,

              I'm looking to create a script that will only show drives within a certain size range. For example only show drives that are between 500Gb and 1,000GB or 1,000GB and 1,500GB.

              The reason being is that i want to setup thresholds differently on drives. Smaller drives i would like to have a higher percentage free than huge drives. The bigger the drive gets the lower i want the percentage free to alert on the threshold.

              1 Reply Last reply
              0
              • A
                A
                Alex Kirhenshtein
                wrote on last edited by
                #11
                if ($1 =~ "[:/]") {
                  value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")")
                  return (value > 5*1024*1024*1024 && value < 1*1024*1024*1024*1024);
                }
                return false;
                

                @sharpspro said in DCI filter script - how to ignore some filesystems when using {instance} ?:

                Guys,

                I'm looking to create a script that will only show drives within a certain size range. For example only show drives that are between 500Gb and 1,000GB or 1,000TB and 1,500GB.

                The reason being is that i want to setup thresholds differently on drives. Smaller drives i would like to have a higher percentage free than huge drives. The bigger the drive gets the lower i want the percentage free to alert on the threshold.

                1 Reply Last reply
                0
                • S
                  S
                  sharpspro
                  wrote on last edited by
                  #12

                  I tried your suggestion and it did not work for me. Currently I'm using a filter script to ignore CD/DVD drives that report as errors when there is no disk inserted as well as system partitions with no drive letter. I got the script from this post please review below.
                   
                  CURRENT SCRIPT

                  if (rindex($1,":")>0)
                  {
                  // if(length($1)>3) return false;
                  if (rindex($1,"A:")>0) return false;
                  value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")");
                  return (value != null) && (value > 0);
                  //return %(true, $1);
                  }
                  return false;
                  

                  SO for the DCI I created I removed the current script I use and I tried your suggestion and it located all drives and didn't filter anything.

                  NEW SCRIPT

                  if ($1 =~ "[:/]") {
                    value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")")
                    return (value > 5*1024*1024*1024 && value < 1*1024*1024*1024*1024);
                  }
                  return false;
                  

                  For the values you suggested (5*1024*1024*1024) is for 5GB I asume and (1*1024*1024*1024*1024) is for 1TB. If I understand this right, if I wanted to filter drives that are 500GB to 1000GB I would use (value > 512*1024*1024*1024 && value < 1*1024*1024*1024*1024) Not sure on this and hope its not a stupid question.

                  1 Reply Last reply
                  0
                  • S
                    S
                    sharpspro
                    wrote on last edited by
                    #13

                    Any Ideas? I'm running Version 2.0-M1 on Windows Server 2008r2. Do I need to upgrade to M2 for the script you provided to work? I'm waiting for M3 to be tested more before I upgrade to that version.

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

                      This script:

                      if ($1 =~ "[:/]") {
                        value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")")
                        return (value > 5*1024*1024*1024 && value < 1*1024*1024*1024*1024);
                      }
                      return false;
                      

                      has few typos - match operation is ~= and semicolon is missing in line 2. It should be

                      if ($1 ~= "[:/]") {
                        value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")");
                        return (value > 5*1024*1024*1024 && value < 1*1024*1024*1024*1024);
                      }
                      return false;
                      

                      Best regards,
                      Victor

                      1 Reply Last reply
                      0
                      • S
                        S
                        sharpspro
                        wrote on last edited by
                        #15

                        Some reason that script is not working. I included screen shots maybe I have something wrong.

                        When I change the scrpit to the one I used prior and it locates all the drives. That script is below.

                        if (rindex($1,":")>0)
                        {
                        // if(length($1)>3) return false;
                        if (rindex($1,"A:")>0) return false;
                        value = AgentReadParameter($node, "FileSystem.Total(" . $1 . ")");
                        return (value != null) && (value > 0);
                        //return %(true, $1);
                        }
                        return false;
                        

                         


                        NetXMS Pic 1.png

                        NetXMS Pic 2.png

                        1 Reply Last reply
                        0
                        • S
                          S
                          sharpspro
                          wrote on last edited by
                          #16

                          Does anyone have any ideas on what I'm doing wrong? I messed with it a little more and had no luck with my testing.

                          Thanks in advance guys!

                          1 Reply Last reply
                          0
                          • H
                            H
                            Hanfelt
                            wrote on last edited by
                            #17

                            Im no programmer but this seemed to work for me.

                            type = AgentReadParameter($node, "FileSystem.Type(" . $1 . ")");
                            if ((type == null) || (type == "") || (type == "CDFS"))
                              return false;
                            if ($1 ~= "[:/]") {
                              return true;
                            }

                            1 Reply Last reply
                            0
                            • T
                              T
                              TOLeg
                              wrote on last edited by
                              #18

                              To filter CD/DVD and Volume in the "Instance Detection" section, I use this script:

                              type=AgentReadParameter($node, "FileSystem.Type(" . $1 . ")");
                              if ((type == null) || (type == "") || (type == "CDFS") || (type == "UDF"))
                              {
                              return false;
                              }

                              if (
                              type != null && (
                              type == "aufs" ||
                              type == "autofs" ||
                              type == "cgroup" ||
                              type == "configfs" ||
                              type == "debugfs" ||
                              type == "devpts" ||
                              type == "devtmpfs" ||
                              type == "fusectl" ||
                              type == "fuse.gvfsd-fuse" ||
                              type == "fuse.lxcfs" ||
                              type == "hugetlbfs" ||
                              type == "iso9660" ||
                              type == "mqueue" ||
                              type == "nfsd" ||
                              type == "overlay" ||
                              type == "proc" ||
                              type == "pstore" ||
                              type == "rpc_pipefs" ||
                              type == "securityfs" ||
                              type == "selinuxfs" ||
                              type == "squashfs" ||
                              type == "sysfs" ||
                              type == "tmpfs"
                              )) {
                              return false;
                              }

                              if (($1 == "/proc") ||
                                  ($1 like "/proc/*") ||
                                  ($1 == "/sys") ||
                                  ($1 like "/sys/*") ||
                                  ($1 == "/run") ||
                                  ($1 like "/run/*") ||
                                  ($1 == "/dev") ||
                                  ($1 like "*Volume*") ||
                                  ($1 like "/dev/*"))
                                return false;
                              return true;

                              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