Rilevamento dei filesystem montati

Panoramica

È possibile scoprire i filesystem montati e le loro proprietà:

  • nome del punto di mount
  • tipo di filesystem
  • dimensione del filesystem
  • statistiche degli inode
  • opzioni di mount

Per farlo, è possibile usare una combinazione di:

  • l'item agent vfs.fs.get come item master
  • regola di discovery a basso livello dipendente e prototipi di item

Le statistiche del filesystem vengono restituite solo se l'utente dell'agent Zabbix dispone del permesso di attraversamento su ogni directory nel percorso del punto di mount; in caso contrario, il filesystem interessato viene omesso dall'output di vfs.fs.get.

Configurazione

Item master

Crea un item di Zabbix agent utilizzando la seguente chiave:

vfs.fs.get

Imposta il tipo di informazione su "Text" per eventuali dati JSON di grandi dimensioni.

I dati restituiti da questo item conterranno qualcosa di simile al seguente per un filesystem montato:

[
  {
    "fsname": "/",
    "fstype": "ext4",
    "bytes": {
      "total": 249405239296,
      "free": 24069537792,
      "used": 212595294208,
      "pfree": 10.170306,
      "pused": 89.829694
    },
    "inodes": {
      "total": 15532032,
      "free": 12656665,
      "used": 2875367,
      "pfree": 81.487503,
      "pused": 18.512497
    },
    "options": "rw,noatime,errors=remount-ro"
  }
]
Regola LLD dipendente

Crea una regola di discovery a basso livello come tipo Dependent item:

Come master item seleziona l'item vfs.fs.get che abbiamo creato.

Nella scheda LLD macros definisci macro personalizzate con il corrispondente JSONPath:

Nella scheda Filters puoi aggiungere un'espressione regolare che filtra solo i filesystem read-write:

Prototipo di item dipendente

Crea un prototipo di item con tipo "Dependent item" in questa regola LLD. Come item master per questo prototipo seleziona l'item vfs.fs.get che abbiamo creato.

Nota l'uso di macro personalizzate nel nome e nella chiave del prototipo di item:

  • Name: Free disk space on {#FSNAME}, type: {#FSTYPE}
  • Key: Free[{#FSNAME}]

Come tipo di informazione, usa:

  • Numeric (unsigned) per metriche come 'free', 'total', 'used'
  • Numeric (float) per metriche come 'pfree', 'pused' (percentage)

Nella scheda Preprocessing del prototipo di item seleziona JSONPath e usa la seguente espressione JSONPath come parametro:

$.[?(@.fsname=='{#FSNAME}')].bytes.free.first()

Quando inizia la discovery, verrà creato un item per ogni mountpoint. Questo item restituirà il numero di byte liberi per il mountpoint specificato.

Discovery in the short mode

As an alternative to a dependent discovery rule, you may create a discovery rule of the Zabbix agent type with the key:

vfs.fs.get[short]

In the short mode, the item returns the list of mounted filesystems without disk space and inode statistics, for example:

[
  {
    "fsname": "/",
    "fstype": "ext4",
    "options": "rw,noatime,errors=remount-ro"
  },
  {
    "fsname": "/home",
    "fstype": "xfs",
    "options": "rw,relatime,attr2,inode64,noquota"
  }
]

As the agent does not query the filesystems themselves, discovery does not trigger automounting and is not delayed by unresponsive network filesystems. It can also run less often than data collection, for example, once per hour.

In the LLD macros tab, define custom macros with the corresponding JSONPath, for example, {#FSNAME} - $.fsname and {#FSTYPE} - $.fstype.

Then create an item prototype of the Zabbix agent type that returns the statistics of one discovered filesystem:

  • Key: vfs.fs.get[full,{#FSNAME}]
  • Type of information: Text
  • Preprocessing: JSONPath $[0]

Use this item prototype as the master item for dependent item prototypes, for example, with the JSONPath $.bytes.free to get the number of free bytes.

If the agent cannot obtain statistics for a discovered filesystem (for example, because of missing permissions), vfs.fs.get[full,{#FSNAME}] returns an empty array, the $[0] preprocessing step fails, and the item becomes unsupported, so the problem is visible instead of the filesystem being silently skipped. Note that this configuration performs a separate agent check for each discovered filesystem.

This approach is used by the OS templates shipped with Zabbix and requires Zabbix agent 8.0 or later.