# Filtering optical drives from nscp-local-disk

**URL:** <https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856>\
**Category:** Service Monitoring\
**Created:** [April 9, 2019, 10:02am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856 "2019-04-09T10:02:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![funk0id](https://community.icinga.com/user_avatar/community.icinga.com/funk0id/32/389_2.png) [@funk0id](https://community.icinga.com/u/funk0id)\
**Post date:** [April 9, 2019, 10:02am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/1 "2019-04-09T10:02:39Z")

</div>

I’ve rolled out disk checks via director to monitor nscp-local-disk, we’re getting alerted of false positives due to optical drives, both empty and populated, is there an easy way of excluding these?

The example I have is as follows where G, E and I are optical drives…

CRITICAL critical(G:: 1.402GB/1.402GB used, E:: 364KB/364KB used), D:: 17.382GB/34.997GB used, L:: 1.374GB/19.997GB used, M:: 906.047MB/29.997GB used, H:: 43.543MB/15.997GB used, F:: 129.409GB/199.997GB used, C:: 47.324GB/74.509GB used, I:: 0B/0B used

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 9, 2019, 10:10am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/2 "2019-04-09T10:10:19Z")

</div>

Hi,

using [nscp\_disk\_arguments](https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#nscp-local-disk), you can pass additional parameters like filters for the [check\_drivesize](https://docs.nsclient.org/reference/windows/CheckDisk/#check_drivesize) check inside NSClient++.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![funk0id](https://community.icinga.com/user_avatar/community.icinga.com/funk0id/32/389_2.png) [@funk0id](https://community.icinga.com/u/funk0id)\
**Post date:** [April 9, 2019, 10:12am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/3 "2019-04-09T10:12:09Z")

</div>

Thanks, I presume that would then have to be per host given the drive letters can and do vary?

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 9, 2019, 10:14am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/4 "2019-04-09T10:14:44Z")

</div>

Since you’re using the Director, in fact: yes. You might leverage this into host templates where you define a generic custom variable for this, and only override this with specific other host templates you’ll then import into the host objects.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![anon66228339](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@anon66228339](https://community.icinga.com/u/anon66228339)\
**Post date:** [April 9, 2019, 10:20am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/5 "2019-04-09T10:20:10Z")

</div>

If you want to filter out CDROM and REMOVABLE ones you can give this filter a try

```auto
filter=type not in ('CDROM', 'REMOVABLE')

```

Regards,  
Carsten

---

<div class="post-metadata">

**Author:** ![funk0id](https://community.icinga.com/user_avatar/community.icinga.com/funk0id/32/389_2.png) [@funk0id](https://community.icinga.com/u/funk0id)\
**Post date:** [April 9, 2019, 10:21am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/6 "2019-04-09T10:21:40Z")

</div>

That’s exactly what I’m after thanks @anon66228339, so it’s a question of where I can fit that filter into director to roll it out in my generic host template?

---

<div class="post-metadata">

**Author:** ![anon66228339](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@anon66228339](https://community.icinga.com/u/anon66228339)\
**Post date:** [April 9, 2019, 10:25am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/7 "2019-04-09T10:25:12Z")

</div>

If you want to filter it out on all hosts, i would put it into the service template.

---

<div class="post-metadata">

**Author:** ![funk0id](https://community.icinga.com/user_avatar/community.icinga.com/funk0id/32/389_2.png) [@funk0id](https://community.icinga.com/u/funk0id)\
**Post date:** [April 9, 2019, 10:34am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/8 "2019-04-09T10:34:37Z")

</div>

Yes makes much more sense that way, is the filter on the service template that could be added in via the director web interface, can’t figure out where to apply it.

edit - Would you not change the definition of the command instead @anon66228339?

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 9, 2019, 11:14am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/9 "2019-04-09T11:14:27Z")

</div>

No, because then you would have copy the Icinga 2 provided command and create and maintain your own. Better hide this inside the template logic thus overriding any other settings. Bonus: You’ll see that custom variable in the detail views and know about it.

---

<div class="post-metadata">

**Author:** ![funk0id](https://community.icinga.com/user_avatar/community.icinga.com/funk0id/32/389_2.png) [@funk0id](https://community.icinga.com/u/funk0id)\
**Post date:** [April 9, 2019, 11:26am UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/10 "2019-04-09T11:26:43Z")

</div>

Great thanks @dnsmichi, so it’s just a case of figuring out how to pass that filter in on the service template via the director.

---

<div class="post-metadata">

**Author:** ![funk0id](https://community.icinga.com/user_avatar/community.icinga.com/funk0id/32/389_2.png) [@funk0id](https://community.icinga.com/u/funk0id)\
**Post date:** [April 12, 2019, 12:59pm UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/11 "2019-04-12T12:59:14Z")

</div>

So, I’m feeling mega stupid at the moment, this is one of the last few tweaks I’ve got to make until I can just roll agents out across my whole estate.

I can not figure out for the life of me how to incorporate `filter=type not in ('CDROM', 'REMOVABLE')` into the service template within director.

I presume, based on previous advice I shouldn’t be editing any of the conf files for director, but I can’t find where I would input the filter within director.

Starting to wish I’d not started with Icinga now but I’m that far along it feels like a waste to throw it away!

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 12, 2019, 1:11pm UTC](https://community.icinga.com/t/filtering-optical-drives-from-nscp-local-disk/856/12 "2019-04-12T13:11:24Z")

</div>

First off, navigate into the Commands section and pick external commands.  
Locate `nscp-local-disk` and select the `Fields` tab.

 ![38](https://community.icinga.com/uploads/default/original/1X/e5c21b29fa1fd845e0ba8b8ea9c5e6d0e6ea1570.jpeg)

Now select `nscp_disk_arguments` and add this field. This exports the field for usage in your service and host templates (and objects).

Once that’s done, you’ll go back into your service template (newly created or existing, doesn’t matter).

Pick the `nscp-local-disk` as check\_command, if not done yet. The `Custom Properties` line has now an additional field entry, the one you’ve defined before.

Select and add the value `filter=type not in ('CDROM', 'REMOVABLE')` to it. Save it and deploy your services which import this template.

 ![42](https://community.icinga.com/uploads/default/original/1X/8bea75db2c55c8c1e7970b6759f5f6fc8161d421.png)

Should work (haven’t tested this, just clicked around in my Vagrant box).

Cheers,  
Michael
