New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diskusage beacon does not recognize tmpfs disks in linux. #48536

Closed
whytewolf opened this Issue Jul 11, 2018 · 6 comments

Comments

@whytewolf
Contributor

whytewolf commented Jul 11, 2018

Description of Issue/Question

The beacon diskusage does not monitor the usage of tmpfs based disks.

Setup

beacons: 
  diskusage: 
    - /tmp: 95% 
df
Filesystem                      1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00  39269648   1423436  37846212   4% /
devtmpfs                           933740         0    933740   0% /dev
tmpfs                              941688        28    941660   1% /dev/shm
tmpfs                              941688      8624    933064   1% /tmp

Steps to Reproduce Issue

Because of the regex stuff psutil is asked for a partitions list. But that list only includes items that are physical

python2.7 -c 'import psutil; print psutil.disk_partitions(all=False)'
[sdiskpart(device='/dev/mapper/VolGroup00-LogVol00', mountpoint='/', fstype='ext4', opts='rw'), sdiskpart(device='/dev/sda1', mountpoint='/boot', fstype='ext4', opts='rw')]

Versions Report

Salt Version:
           Salt: 2018.3.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Mar 30 2018, 15:31:59)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 6.9 Final
         locale: UTF-8
        machine: x86_64
        release: 2.6.32-696.6.3.el6.x86_64
         system: Linux
        version: CentOS 6.9 Final

@whytewolf whytewolf added the ZD label Jul 11, 2018

@whytewolf

This comment has been minimized.

Contributor

whytewolf commented Jul 11, 2018

ZD-2686

@rickh563

This comment has been minimized.

rickh563 commented Jul 12, 2018

ZD-2686 Notes:

Appears this commit is what changed the behavior from 2016.11 to 2018.3.*

0b0ada6

The behavior before the commit was to walk through the list of monitored directory/filesystems. The behavior after the change is to compare the list of what is being monitored to the list of mount points in an effort to support pattern matching. Since the psutil doesn't return all types of mount points, this doesn't work with tmpfs mounts.

Try this first _current_usage = psutil.disk_usage(mount) then attempt the loop if it doesn't return a result which looks like what it would have done before the commit with the exception that it wouldn't match /opt/symphony-*. Still, the behavior from 2016.11 would be preserved

@rallytime

This comment has been minimized.

Contributor

rallytime commented Jul 13, 2018

@garethgreenaway Can you fix this for 2018.3.3?

@garethgreenaway

This comment has been minimized.

Member

garethgreenaway commented Jul 18, 2018

@rallytime On it.

@garethgreenaway

This comment has been minimized.

Member

garethgreenaway commented Jul 18, 2018

This actually appears really simple, updating psutil.disk_partitions to use all=True instead of all=False ensures that the tmpfs file systems are included in the list.

diff --git a/salt/beacons/diskusage.py b/salt/beacons/diskusage.py
index e2e6edf884..04fd8fea0b 100644
--- a/salt/beacons/diskusage.py
+++ b/salt/beacons/diskusage.py
@@ -83,7 +83,7 @@ def beacon(config):
     it will override the previously defined threshold.
 
     '''
-    parts = psutil.disk_partitions(all=False)
+    parts = psutil.disk_partitions(all=True)
     ret = []
     for mounts in config:
         mount = next(iter(mounts))
@@ -100,7 +100,7 @@ def beacon(config):
 
                 current_usage = _current_usage.percent
                 monitor_usage = mounts[mount]
-                log.info('current_usage %s', current_usage)
+                log.debug('current_usage %s', current_usage)
                 if '%' in monitor_usage:
                     monitor_usage = re.sub('%', '', monitor_usage)
                 monitor_usage = float(monitor_usage)
@rallytime

This comment has been minimized.

Contributor

rallytime commented Jul 23, 2018

@whytewolf This is fixed with #48718

@rallytime rallytime closed this Jul 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment