# 5 Real life scenario

Suppose we would like to set up network discovery for local network
having IP range of 192.168.1.1-192.168.1.255. In our scenario we want
to:

-   discover those hosts that have Zabbix Agent running
-   run discovery every 10 minutes
-   add host to monitoring if host uptime is more than 1 hour
-   remove hosts if host downtime is more than 24 hours
-   use Template\_Windows for Windows hosts
-   use Template\_Linux for Linux hosts
-   add Linux hosts to "Linux servers" group
-   add Windows hosts to "Windows servers" group

##### Step 1

Define a network discovery rule for our IP range (*Configuration →
Discovery → Create rule* button)

![](../../../assets/en/manual/auto-discovery/1.8.5_discovery_rule.png)

Zabbix will try to discover hosts in IP range of
192.168.1.1-192.168.1.255 by connecting to Zabbix Agents and getting
value from **system.uname** key. A value received from an agent can be
used to apply different actions for different operating systems. For
example, link Windows servers to Template\_Windows, Linux servers to
Template\_Linux.

The rule will be executed every 10 minutes (600 seconds).

When the rule is added, Zabbix will automatically start discovery and
generation of discovery-based events for further processing.

##### Step 2

Define an action for adding newly-discovered Linux servers to the
respective group/template. (*Configuration → Actions → Create Action*
button)

![](../../../assets/en/manual/auto-discovery/1.8.5_discovery_action1.png){width="600"}

The action will be activated if:

-   "Zabbix agent" service is "Up"
-   value of system.uname (the Zabbix Agent's key we used in rule
    definition) contains "Linux"
-   Uptime is more than 1 hour (3600 seconds)

The action will execute the following operations:

-   add the newly discovered host to "Linux servers" group (also add
    host if it wasn't added previously)
-   link host to "Template\_Linux" template. Zabbix will automatically
    start monitoring the host using items and triggers from
    "Template\_Linux".

##### Step 3

Define an action for adding newly-discovered Windows servers to the
respective group/template.

![](../../../assets/en/manual/auto-discovery/1.8.5_discovery_action2.png){width="600"}

##### Step 4

Define an action for removing lost servers.

![](../../../assets/en/manual/auto-discovery/1.8.5_discovery_action3.png){width="600"}

A server will be removed if "Zabbix agent" service is "Down" for more
than 24 hours (86400 seconds).
