# Best way to enable OneAgent start and stop

**URL:** <https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931>\
**Category:** Container platforms\
**Tags:** dynatrace-operator, oneagent\
**Created:** [June 3, 2025, 11:03pm UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931 "2025-06-03T23:03:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SachinJindal](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@SachinJindal](https://community.dynatrace.com/u/SachinJindal)\
**Post date:** [June 3, 2025, 11:03pm UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/1 "2025-06-03T23:03:22Z")

</div>

i have scenario where Oneagent will be installed on both the Prod and DR sites. Our goal is to monitor only one site at a time based on our requirements to reduce the cost & Instead of performing the installation as needed, we would prefer to simply switch the monitoring on or off as required. i think by default Oneagent automatically comes up as soon as we do server reboot as well.

Could you please confirm best way to have this flexibility &&nbsp; would this necessitate stopping and starting the applications each time we switch between sites?

---

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [June 4, 2025, 7:14am UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/2 "2025-06-04T07:14:41Z")

</div>

[@SachinJindal](https://community.dynatrace.com/user/52338)&nbsp;You turn off the monitoring for host from&nbsp;Host settings instead, this way monitoring is disabled until its manually re-enabled even though OneAgent service continues to run

> **[Host-level settings](https://docs.dynatrace.com/docs/observe/infrastructure-observability/hosts/configuration)**
>
> Host-level settings

---

<div class="post-metadata">

**Author:** ![MuhammadGamal](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@MuhammadGamal](https://community.dynatrace.com/u/MuhammadGamal)\
**Post date:** [June 4, 2025, 7:38am UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/3 "2025-06-04T07:38:51Z")

</div>

You can disable the host monitoring per host.&nbsp;  
navigate&nbsp;&nbsp;settings \>&nbsp;Monitoring \>&nbsp;Monitoring overview \> Hosts&nbsp; ,

and choose the host you need, click Edit,&nbsp; and disable the monitoring&nbsp;

 ![Screenshot 2025-06-04 104031.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/9/89cec1cbbab9a6784bfb0fc5bce6f629c4c1f688.png)  
 ![Screenshot 2025-06-04 103659.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/7/c7d7fb90d34e747573c513623f98e7721268207f.png)

---

<div class="post-metadata">

**Author:** ![lubrman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/lubrman/32/7353_2.png) [@lubrman](https://community.dynatrace.com/u/lubrman)\
**Post date:** [June 4, 2025, 9:18am UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/4 "2025-06-04T09:18:10Z")

</div>

Hi&nbsp;[@SachinJindal](https://community.dynatrace.com/user/52338)

You can use an Ansible role to control the activation of OneAgent, where you can declare the argument oneagent\_platform\_install\_args: [--set-monitoring-mode=infra-only]. For example, this ensures that OneAgent will run in infrastructure-only mode. Alternatively, you can completely disable the agent, which can then be further automated as part of a CI/CD pipeline.

> **[Ansible Galaxy](https://galaxy.ansible.com/ui/repo/published/dynatrace/oneagent/content/role/oneagent/)**

> **[Install OneAgent using Ansible](https://docs.dynatrace.com/docs/ingest-from/dynatrace-oneagent-classic/deployment-orchestration/ansible)**
>
> Learn how to deploy OneAgent using Dynatrace-provided Ansible playbook.

---

<div class="post-metadata">

**Author:** ![Aymeric\_M](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/aymeric_m/32/35713_2.png) [@Aymeric\_M](https://community.dynatrace.com/u/Aymeric_M)\
**Post date:** [June 4, 2025, 12:13pm UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/5 "2025-06-04T12:13:17Z")

</div>

You can also use Workflows to switch on/off monitoring on a set of hosts.  
For example you could create 2 manually triggered workflows (one for switching from Prod to DR and the other to switch from DR to Prod).  
Each workflow would work something like this :

1. a task to provide or generate (via DQL) the 2 lists of hosts
2. a task to generate the lists of json settings objects for enabling monitoring on one list of hosts and disabling monitoring on the other list of hosts
3. a task to send the&nbsp; list of settings objects using the Dynatrace JS SDK

---

<div class="post-metadata">

**Author:** ![SachinJindal](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@SachinJindal](https://community.dynatrace.com/u/SachinJindal)\
**Post date:** [June 4, 2025, 6:42pm UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/6 "2025-06-04T18:42:54Z")

</div>

Since i have got more than 40-50- servers it will be difficult to disable for each host manually and this activity would be on a monthly basis

---

<div class="post-metadata">

**Author:** ![SachinJindal](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@SachinJindal](https://community.dynatrace.com/u/SachinJindal)\
**Post date:** [June 4, 2025, 6:45pm UTC](https://community.dynatrace.com/t/best-way-to-enable-oneagent-start-and-stop/51931/7 "2025-06-04T18:45:08Z")

</div>

This looks to be quite good approach .. let me see if this can be done in short timescale…
