9 Replies Latest reply on Sep 9, 2009 8:17 AM by ejensen

    SmartGroup using negated RegEx

    simonpt

      I want to create a scheduled email report publisher which gives the network uptime of our critical infrastructure (namely servers and routers).  To do this I figure I need to create a SmartGroup that includes only the ping monitors of these devices.  That's because I don't want pesky bandwidth/disk/memory monitors that go "down" to affect the uptime stats.


      I've started creating a SmartGroup as follows:



      SmartGroup contains: Monitors
      Start with: No Monitors
      Add monitors where property Device Type matches regular expression \i(router|server)
      Remove monitors where property Type matches regular expression [insert expression here]


      This is where I need an expression that removes all monitors except 'ping' monitors.  Does anyone know how to negate the expression \i(ping)?  My searches on the topic have shown that regular expressions don't allow you to negate a whole word (only a single character class).  I've tried a few alternative suggestions but none give the desired result.


      Or does someone have a completely different way of achieving the same result?


      Thanks - Simon

        • Re: SmartGroup using negated RegEx
          chris.lapoint

          Simon, since you're starting this SmartGroup with "No Monitors", you should only have to add the Ping monitors to the SmartGroup to have the desired effect (versus using a "remove" clause).

            • Re: SmartGroup using negated RegEx
              simonpt

              Hi Chris


              Thanks for your reply. 


              The problem I'm encountering is that I only want to include router/server ping monitors, eg, (device type = router OR server) AND monitor type = ping.  With the way the SmartGroup logic works, when I add 'device type = router|server', I get all the monitors for these devices so I then need to remove everything except the ping monitors, hence the request for negating the ping regex.  You get the same problem if you start with nothing and add 'monitor type = ping' -- you then need to remove all monitors for devices other than routers and servers.


              Does this make sense?


              I think SmartGroups would work better if you could use standard and/or conditionals, rather than it's current approach of starting with nothing/everything and then adding/removing.  As this example shows, there are times when you can't get the result you want.


              Rgds, Simon

                • Re: SmartGroup using negated RegEx
                  Peter.Cooper

                  Hi Simon, you can import this SmartGroup as is. It adds ping monitors, then removes anything that doesn't belong to a router or server. Import is: Configuration Tab > Server Settings > Import Settings > Cut and paste from XML.
                   

                  <group>
                  <typeid>3899979</typeid>
                  <nv>
                  <ui>
                  <name>Ping Monitors from Routers &amp; Switches</name>
                  </ui>
                  </nv>
                  <ignore>
                  <u0>
                  <kind>4</kind>
                  </u0>
                  <u1>
                  <kind>4</kind>
                  </u1>
                  </ignore>
                  <col/>
                  <depends/>
                  <devices>false</devices>
                  <start>empty</start>
                  <constraints>
                  <u0>
                  <mode>5</mode>
                  <name>type</name>
                  <regex>^ping$</regex>
                  </u0>
                  <u1>
                  <mode>4</mode>
                  <name>device.type</name>
                  <regex>^(?!hub_sw|server)</regex>
                  </u1>
                  </constraints>
                  </group>