Ad Widget

Collapse

Need help with discovery and actions (auto adding hosts to host groups)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vexter0944
    Junior Member
    • Jan 2020
    • 16

    #1

    Need help with discovery and actions (auto adding hosts to host groups)

    First time Zabbix user, but long time in IT. I have Zabbix up and running, and any Windows host is being discovered and added to a host group of 'Windows Servers' and that's working well.

    Here's what is not working:

    I have a 2nd discovery rule setup - this discovery rule is setup to look at the following:
    <same subnet as discovery rule #1>
    Checks:
    Zabbix agent "agent.hostname"
    Zabbix agent "wmi.get[root\cimv2,Select Name From Win32_ServerFeature where Id=18]"

    The idea is that if the RDS role on a Windows server is installed, then it should return 'Remote Desktop Services' from that query on the 2nd check. The hostname is important because in my environment, we have several services running RDS, but I only need the info from a server named server-app01

    I can see the discovery happen when I watch the Monitoring->Discovery tab so it seems to be working ok.

    The Action is setup as follows:
    Conditions A Received value equals Remote Desktop Services

    With an Operation of Add to host groups: Remote_Desktop_Services_Servers

    No hosts are being added to the Remote_Desktop_Services_Servers and round and round we go.

    I have tried an action with a condition saying Received value contains Remote or Received value contains remote and all kinds of variations of this.

    What am I doing wrong? Are there logs I can look at/tail on the server to see what's exactly going on with discovery and/or the action rules?

    Any and all help would be much appreciated! Thanks in advance for any help offered!



  • gert.derouck
    Member
    • Jan 2020
    • 69

    #2
    Hi, discovery is for adding new hosts.

    The way i automatically assign specific additional templates to specific hosts is, based on some conditions:
    - Create items that need to be be evaluated
    - Create a trigger for this item, that fires when a specific template should be assigned to the host
    - Create a trigger action, that launches a custom script to assign a template to the host.
    The custom script can be using zabbix-cli or zabbix API to assign the template

    Comment

    • vexter0944
      Junior Member
      • Jan 2020
      • 16

      #3
      gert.derouck - thanks so much for this information and help! I was running down this path yesterday and couldn't quite get it wired up this way and so I went down the path I described in my post above.
      A couple of quick questions for clarity:

      1.
      Create a trigger for this item, that fires when a specific template should be assigned to the host:
      So I created the item (the WMI query I posted above) in the Windows OS Template the Server gets assigned to at discovery. Then I should create a trigger in that template (with a severity of information I'm assuming) - and an expression that looks for the last string returned on the tiem (in my case the word 'Remote' should be found or not found in the return since the WMI query returns Remote Desktop Services. SO After getting this trigger, it should show up in the triggers for the host as blue 'Informational' trigger - does it/should it ever go away or just stay there for as long as the WMI query is found right?

      2.
      Create a trigger action, that launches a custom script to assign a template to the host.
      I follow the trigger action idea here - makes sense. So I'll need to call the zabbix-cli or an API call from the Ubuntu server and somehow pass off the host name to that script/call and I follow that you're then adding that host to the host group.

      Although you didn't offer this as an option - I'll ask in case you or someone else might now. Is there a way to set a tag on a host and evaluate that tag and then add to a host group based on that tag? Or could the cli/api script say hey anything with this 'tag' add to this host group? Just a thought.

      Thanks again for the help - I'll look forward to your response!

      Comment

      • vexter0944
        Junior Member
        • Jan 2020
        • 16

        #4
        One last thing - I just worked through setting up the trigger and now I remember why I didn't run down this path - the Informational Blue box shows up since the trigger was triggered, but it keeps blinking PROBLEM - is there a way to tell it's just informational and not a 'PROBLEM' - that's why I didn't do this yesterday because I don't need a red flashing problem for some host in the dashboard/etc telling me Remote Desktop Services is installed

        Comment

        • gert.derouck
          Member
          • Jan 2020
          • 69

          #5
          About the trigger config: i faced the same problems at start... :-)
          My items for discovery always return '1' if some software was discovered. In the example below my item is called: sw.disc_apache
          Trigger config example:
          Code:
          {Custom Template OS Linux:sw.disc_apache.last()}=1 and ( {Custom Template OS Linux:sw.disc_apache.diff()}=1 or {Custom Template OS Linux:sw.disc_apache.count(#2)}<2 )
          Indeed severity = informational.
          It will autoclose after 2 probes due to the diff. The last part makes sure it also fires when this is a new hosts and it discovers the software at first probe.
          Last edited by gert.derouck; 25-01-2020, 18:03.

          Comment

          • gert.derouck
            Member
            • Jan 2020
            • 69

            #6
            About your second question: in my setup i don't use tags. I have a separate action trigger for each type of software to discover.
            But indeed; i like your idea of using tags for this. You can add a tag to your trigger. Or you can use specific name to your item/trigger.
            You can pass these to your script as arguments by using macro's and parse them in your script to attach relevant templates.

            Comment

            • vexter0944
              Junior Member
              • Jan 2020
              • 16

              #7
              Thanks for the response - this is putting me on a track. In the time I had posted and you responded - I had also found out about the always return '1' in the query - so got that solved, now just tweaking it more to get it where I want it. Thanks for the input and help - it is MUCH appreciated!

              Comment

              • dialod
                Junior Member
                • Apr 2020
                • 18

                #8
                Hello ! I need your help. I found your post and hope for help. There is a task that would create 2 data elements. The first element displayed server roles and the second element displayed features. How do I create a data element key correctly ? Data is needed for server inventory. I'm not very good at Zabbix. Zabbix Version 4.4.6
                Last edited by dialod; 23-04-2020, 12:28.

                Comment

                Working...