Skip to content

Instantly share code, notes, and snippets.

@boomshadow
Created August 20, 2017 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boomshadow/ed5ea7026e1b2e53ff8c27782d6146bc to your computer and use it in GitHub Desktop.
Save boomshadow/ed5ea7026e1b2e53ff8c27782d6146bc to your computer and use it in GitHub Desktop.
Datadog custom agent check for number of drives/partitions

Info

I needed a simple check that would tell me if a drive suddenly failed/disappeared from the server.
This is accomplished by counting the number of mounted partitions. You can tehn setup a monitor trigger if the count decreases.

Install

  • put disk_partition.py in your datadog's checks.d directory
  • put disk_partition.yaml in your datadog's conf.d directory

Restart the datadog agent.

References

https://stackoverflow.com/a/25777174/2785592 https://docs.datadoghq.com/guides/agent_checks/

from checks import AgentCheck
import psutil
class DiskPartitionCheck(AgentCheck):
def check(self, instance):
self.gauge('disk_partition.count', len(psutil.disk_partitions()))
init_config:
instances:
[{}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment