Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-3368

vfs.fs.discovery: Discover devices (not only mountpoint and filesystems)

XMLWordPrintable

    • Icon: Change Request Change Request
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.2.0alpha2
    • Agent (G)
    • Linux. The improvement could be made pour other operating systems, but this issue only provide details for Linux systems (tested on CentOS 7).

      Hi,

      Currently, the vfs.fs.discovery on Linux only discovers FSNAME (mountpoints) and FSTYPE (filesystems). It does so by parsing the /proc/mounts file, which provides a bit more infos (https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-proc-mounts.html) than these 2.

      Actually, some items like vfs.fs.read or vfs.fs.write require a device name (and not a mountpoint) to work, so it would be nice if the vfs.fs.discovery item would discover the devices besides their mountpoints and filesystems. People I'm working with are currently using a perl script to discover devices to be used for vfs.fs.read/write since the "native" vfs.fs.discovery doesn't provide it. I definitively think it would be cleaner and would benefit to other people to have the devices discovered and made available through vfs.fs.discovery.

      I took the opportunity to implement and test it for Linux, see the patch below.

      I worked on trunk, on the git mirror of the SVN repository. My work as been done from the following commit :

      commit 37b978f9ce53ee8b693a1c7dd6b24a6a5afca170
      Author: wiper <wiper@f4e7fd02-d210-4e34-a1e0-d4093fb66cc2>
      Date:   Tue Jul 19 07:27:08 2016 +0000
      
          ..F.....S. [ZBXNEXT-3277] added global event correlation rule processing
      
      
          git-svn-id: svn://svn.zabbix.com/trunk@61100 f4e7fd02-d210-4e34-a1e0-d4093fb66cc2
      

      The patch itself :

      diff --git a/src/libs/zbxsysinfo/linux/diskspace.c b/src/libs/zbxsysinfo/linux/diskspace.c
      index e6bb828..b8388ed 100644
      --- a/src/libs/zbxsysinfo/linux/diskspace.c
      +++ b/src/libs/zbxsysinfo/linux/diskspace.c
      @@ -121,7 +121,7 @@ int	VFS_FS_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result)
       
       int	VFS_FS_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result)
       {
      -	char		line[MAX_STRING_LEN], *p, *mpoint, *mtype;
      +	char		line[MAX_STRING_LEN], *p, *mpoint, *mtype, *mdev;
       	FILE		*f;
       	struct zbx_json	j;
       
      @@ -137,9 +137,13 @@ int	VFS_FS_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result)
       
       	while (NULL != fgets(line, sizeof(line), f))
       	{
      +		mdev = line;
      +
       		if (NULL == (p = strchr(line, ' ')))
       			continue;
       
      +		*p = '\0';
      +
       		mpoint = ++p;
       
       		if (NULL == (p = strchr(mpoint, ' ')))
      @@ -155,6 +159,7 @@ int	VFS_FS_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result)
       		*p = '\0';
       
       		zbx_json_addobject(&j, NULL);
      +		zbx_json_addstring(&j, "{#FSDEV}", mdev, ZBX_JSON_TYPE_STRING);
       		zbx_json_addstring(&j, "{#FSNAME}", mpoint, ZBX_JSON_TYPE_STRING);
       		zbx_json_addstring(&j, "{#FSTYPE}", mtype, ZBX_JSON_TYPE_STRING);
       		zbx_json_close(&j);
      

      The output confirming that it's working as intended :

      $ zabbix_get -s localhost -k vfs.fs.discovery  | python -m json.tool {
          "data": [
              ...
              {
                  "{#FSDEV}": "/dev/mapper/centos-root",
                  "{#FSNAME}": "/",
                  "{#FSTYPE}": "xfs"
              },
              ...
          ]
      }
      

      Now the final question is : is it possible to merge this into Zabbix ?

      If that sounds ok for you, how would I go into merging this into Zabbix ?

        1. zabbix_device_discovery_diff.txt
          1 kB
          Alexis "Horgix" Chotard
        2. zabbix_discovery_output.txt
          0.2 kB
          Alexis "Horgix" Chotard

            Unassigned Unassigned
            Horgix Alexis "Horgix" Chotard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: