Documentation
    Preparing search index...

    Checks for the disk space and report warning or error after a certain threshold is exceeded.

    const diskCheck = new DiskSpaceCheck()
    .as('Root disk space check')
    .warnWhenExceeds(70) // Warning at 70%
    .failWhenExceeds(85) // Error at 85%
    .cacheFor('1 minute')

    const result = await diskCheck.run()
    console.log(result.status) // 'ok' | 'warning' | 'error'

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    cacheDuration?: number

    The cache duration for the check result in seconds

    name: string = 'Disk space check'

    The name of the disk space check

    diskPath: string = ...

    The disk path to check for space usage

    Methods

    • Define a custom unique name for the check

      Parameters

      • name: string

        The unique name for the health check

      Returns this

      const check = new MyCheck().as('Database connection check')
      
    • Specify the duration for which the check should be cached for

      Parameters

      • duration: string | number

        The cache duration as a string (e.g., '5s', '1m') or number in seconds

      Returns DiskSpaceCheck

      const check = new MyCheck().cacheFor('5 minutes')
      // or
      const check2 = new MyCheck().cacheFor(300) // 300 seconds
    • Define a custom callback to compute the disk space. Defaults to using "check-disk-space" package

      Parameters

      • callback: () => Promise<{ free: number; size: number }>

        Function that returns disk space information

      Returns this

      const diskCheck = new DiskSpaceCheck()
      .compute(async () => {
      // Custom disk space computation
      return { free: 1000000000, size: 5000000000 } // 1GB free, 5GB total
      })