# OneAgent Plugin checking for created file within particular location

**URL:** <https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058>\
**Category:** Extensions\
**Tags:** oneagent, extensions\
**Created:** [June 19, 2019, 12:26pm UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058 "2019-06-19T12:26:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantin\_Mavr](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/konstantin_mavr/32/34928_2.png) [@Konstantin\_Mavr](https://community.dynatrace.com/u/Konstantin_Mavr)\
**Post date:** [June 19, 2019, 12:26pm UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/1 "2019-06-19T12:26:41Z")

</div>

Hi All,

I am trying to develop OneAgent plugin which will monitor paricular file location for any generated files. Plugin was built under Linux as it will be used on it and succesfully uploaded on DT SaaS.However when a file is generated instead of reporting the mentioned problem, DT just increased the number of monitored hosts.

{

“version”: “0.2”,

“name”: “custom.python.basic\_file\_check\_linux”,

“type”: “python”,

“entity”: “HOST”,

“processTypes”: [1],

“source”: {

“package”: “basic\_file\_check\_linux”,

“className”: “BasicFileCheckLinux”,

“install\_requires”: [],

“activation”: “Singleton”

},

“metrics”: [

{

“timeseries”: {

“key”: “file\_exists”,

“unit”: “Count”,

“displayname”: “File with extension.fail was generated”,

“dimensions”: []

}

}

],

“configUI”: {

“displayName”: “Basic File Existence Check (Linux)”

},

“properties”: [

{

“key”: “file\_path”,

“type”: “String”

}

],

“alert\_settings”: [

{

“alert\_id”: “custom\_file\_exists\_check\_linux”,

“event\_type”: “ERROR\_EVENT”,

“event\_name”: “Fail file generated”,

“description”: “File with extension .fail was generated within {file\_path}”,

“threshold”: 1,

“alert\_condition”: “ABOVE”,

“samples”: 5,

“violating\_samples”: 3,

“dealerting\_samples”: 5

}

]

}

Alerting settings are minimized as possibly.

Do you have any idea what should be adjusted in order to have the problem reported when the file is generated within the file location?

Cheers,

Konstantin

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [June 19, 2019, 2:24pm UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/2 "2019-06-19T14:24:10Z")

</div>

Did you tried creating custom threshold via API on this custom metric?

> **[Migration guides for deprecated APIs](https://docs.dynatrace.com/docs/dynatrace-api/basics/deprecation-migration-guides)**
>
> Migrate your automation to newer endpoints of the Dynatrace API.

Sebastian

---

<div class="post-metadata">

**Author:** ![Konstantin\_Mavr](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/konstantin_mavr/32/34928_2.png) [@Konstantin\_Mavr](https://community.dynatrace.com/u/Konstantin_Mavr)\
**Post date:** [June 28, 2019, 1:31pm UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/3 "2019-06-28T13:31:44Z")

</div>

No, I haven’t tried to define a custom threshold via the API but what is the idea behind that action?

Also today I received strange error during plugin upload:

The metricGroup field is missing. Since version 1.172, the metric group is an obligatory field. It is used for grouping custom metrics into a hierarchical namespace where various sources, for example multiple plugins, can provide data. Moreover, the metric group becomes a primary part of the metric key, which means that once defined, it must remain the same for the continuity of data. The metric group will also help you find metrics on custom charts.

Where should that MetricGroup be placed - in the Metrics section of plugin.json probably?

Cheers,

Konstantin

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [June 28, 2019, 1:34pm UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/4 "2019-06-28T13:34:48Z")

</div>

My idea was threshold on this metrics because without it it will never fire problem I think.

Sebastian

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [June 28, 2019, 3:50pm UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/5 "2019-06-28T15:50:27Z")

</div>

Have you considered just writing a daemon process to watch for the file and push an error event to Dynatrace when it exists? This way there will be no charge for custom metrics, you can set the interval to whatever makes sense, etc.

---

<div class="post-metadata">

**Author:** ![Konstantin\_Mavr](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/konstantin_mavr/32/34928_2.png) [@Konstantin\_Mavr](https://community.dynatrace.com/u/Konstantin_Mavr)\
**Post date:** [July 2, 2019, 10:30am UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/6 "2019-07-02T10:30:47Z")

</div>

Hi Dave, no I haven’t considered such an option. But how could I configure the push event to Dynatrace when the file exists?

Thanks in advance,

Konstantin

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [July 4, 2019, 12:46am UTC](https://community.dynatrace.com/t/oneagent-plugin-checking-for-created-file-within-particular-location/21058/7 "2019-07-04T00:46:13Z")

</div>

You should be able to send an ERROR\_EVENT as documented here:

[https://www.dynatrace.com/support/help/extend-dynatrace/dynatrace-api/environment-api/events/post-event/](https://www.dynatrace.com/support/help/extend-dynatrace/dynatrace-api/environment-api/events/post-event/#expand-752authentication)

You would just need to send a description, title and source.

HTH,

dave
