Skip to content
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

"conky: statfs64 '/media/usbstick': No such file or directory" spam in ~/.xsession-errors #208

Closed
mxmlnkn opened this issue Feb 7, 2016 · 8 comments · Fixed by #2023
Closed
Labels
bug related to incorrect existing implementation of some functionality

Comments

@mxmlnkn
Copy link
Contributor

mxmlnkn commented Feb 7, 2016

I make heavy use of the if_mounted directive to create an almost comprehensive disk usage stat for all my mounted devices similar to the windows workplace view, because I miss this in Linux. The problem is, that some directories are only created by the xfce auto mount service whenever that device, e.g. USB thumb drive is actually mounted. This means if that device is not mounted if_mounted won't work, because it can't even find the folder. As a result the following command

${if_mounted /media/Transcend}\
Usb${goto 30}${fs_type /media/Transcend}${goto 70}${fs_bar 10,50 /media/Transcend}\
${alignr}${fs_used /media/Transcend} / ${fs_size /media/Transcend} [${fs_used_perc /media//Transcend}%]
${endif}\

will spam my .xsession-errors with the message in the title. I only noticed this, because that file is ~500MB large. The lines containing 'conky' are 198715 out of 5771768. So roughly 4% While it is not a major part, it still is not nothing.

I tried solving this problem by using if_existing but it doesn't seem to work.

${if_existing /media/mimi}\
  EXISTS\
  ${if_mounted /media/mimi}\
    AND MOUNTED\
     ${fs_type /media/mimi}
  ${endif}\
${endif}

Neither EXISTS nor AND MOUNTED will be displayed, but it seems statfs64 will be called anyway. Note that commenting out fs_type will quelch that warning message. So it doesn't seem to stem from if_mounted. Instead it seems that if_mounted an if_existed control only what is displayed, but not what is executed. I think this should be changed.

Furthermore deleting e.g. the lines with mimi will still call statfs64 even after the config-file is autoreloaded. I have to restart conky completely to quelch that statfs64 call. I think this also is a very minor bug.

@mxmlnkn
Copy link
Contributor Author

mxmlnkn commented May 4, 2016

This bug becomes more important when considering this script: http://www.linuxforums.org/forum/ubuntu-linux/169744-conky-display-all-mounted-drives-post944444.html#post944444
If something was mounted once and then dismounted and the folder disappears, then the error message keeps coming, even though ${execpi} call doesn't return any fs_command anymore.

@mxmlnkn
Copy link
Contributor Author

mxmlnkn commented May 4, 2016

I looked at the code and the rest of this issue which is not covered in #205, would need a major(?) rewrite, because it seems that every fs_bar, fs_* calls update_fs_stats(void). At update_fs_stats checks the time difference, so that each fs_command doesn't initiate a complete update of all stats thereby slowing conky down. But it would be even better, if update_fs_stats was given the arguments of the config-file, so that it only could update only the file system given.

But that may not be the only problem. It seems like the if_command syntax doesn't skip callbacks of commands inside the if-block. But I'm not sure. In the first place, I only could fink cb_handle being set in core.cc, but I couldn't find where it actually is used / called.

Would such a rewrite even be welcome?

@ghost
Copy link

ghost commented May 5, 2016

I agree with adding the argument, as a matter of fact you could remove update_fs_stats(void) all together if you just call 'static void update_fs_stat(struct fs_stat *fs)' with the argument instead. But take my advice with a grain of salt since the inner workings of conky are not completely clear to me. It is hard to comment on the current situation without documentation on why they choose this particular option.

I can not comment on your second paragraph. If you feel like digging into this issue I would say a rewrite would be appreciated.

@AdriCS
Copy link

AdriCS commented Oct 7, 2017

I have encountered the same problem (conky 1.10.6).
Is there any progress on this?

@lasers lasers added the bug related to incorrect existing implementation of some functionality label Aug 5, 2018
@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

Duplicate #334. Closing.

@lasers lasers closed this as completed Aug 7, 2018
@Alexander-Shukaev
Copy link

Having the same problem with conky 1.10.8_pre compiled Wed Oct 24 19:50:26 CEST 2018 for Linux 4.18.16-arch1-1-ARCH x86_64:

${execpi 30 /usr/share/conkycolors/bin/conkyHD1}
#! /bin/sh
DIR=$(conky-colors --finddir=scripts/conkyHD1.py)
pythoncmd="$DIR/scripts/conkyHD1.py $@"

cmd="/usr/bin/python $pythoncmd"

exec $cmd
#!/usr/bin/env python3

import sys
from os.path import abspath, dirname

directory = dirname(abspath(__file__))
sys.path.insert(0, directory)

from hdcommon import get_partitions


print("${voffset 4}")

for device, devicename in get_partitions():
    var_map = {'device': device, 'devicename': devicename}
    print("${voffset -10}${offset 0}${color0}${font ConkyColors:size=15}i${font}${color}${offset 6}"
          "${voffset -10}%(devicename)s: ${font Ubuntu:style=Bold:size=8}${color1}"
          "${fs_free_perc %(device)s}%%${color}${font}\n" % var_map)
    print("${voffset -10}${offset 1}${color0}${fs_bar 4,17 %(device)s}${color}${offset 10}"
          "${voffset -2}F: ${font Ubuntu:style=Bold:size=8}${color2}${fs_free %(device)s}${color}"
          "${font} U: ${font Ubuntu:style=Bold:size=8}${color2}${fs_used %(device)s}${color}${font}\n" % var_map)

print("${voffset -10}")
#!/usr/bin/env python3

import os
from os.path import normpath, basename, ismount
from subprocess import Popen, PIPE

def get_partitions():
    p_lsblk = Popen(['lsblk'], stdout=PIPE)
    p_awk = Popen(['awk', '{print $7}'], stdin=p_lsblk.stdout, stdout=PIPE)
    p_grep = Popen(['grep', '/'], stdin=p_awk.stdout, stdout=PIPE)
    p_lsblk.stdout.close()
    p_awk.stdout.close()
    output = p_grep.communicate()[0]
    for line in output.splitlines():
        device = line.rstrip().decode('utf-8')
        if not ismount(device):
            continue
        if device.startswith('/snap/') or device == '/boot/efi':
            continue
        if (device == "/"):
            yield device, "Root"
        else:
            yield device, basename(normpath(device)).capitalize()

@Alexander-Shukaev
Copy link

texecpi suggestion from #334 did no help.

@Alexander-Shukaev
Copy link

Looks like the only workaround for now is

${texeci 30 killall -USR1 conky}

which is also annoying because it flickers.

quiescens added a commit to quiescens/conky that referenced this issue Aug 29, 2024
fixes brndnmtthws#208 hopefully properly by tracking which fs_stats entries are
actually being used

as an aside, also fixes the niche but possible issue of slowly running out of
fs_stats entries despite never having too many at one time
quiescens added a commit to quiescens/conky that referenced this issue Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug related to incorrect existing implementation of some functionality
Projects
None yet
4 participants