Xfce Forum

Sub domains
 

You are not logged in.

#1 2014-03-22 02:18:53

wchouser3
Member
From: Indiana USA
Registered: 2014-03-22
Posts: 2

Tumblerd using up CPU, and memory on Xfce and thunar

Recently, I've had some trouble with tumblerd using a lot more resources than it should. I did some research and found this script that basically puts a leache on tumbler, while allowing you to keep using it to make thumbnails.

Copy and paste this script into a blank file, mark it executable, and set up Xfce to run it at startup...problem solved!

#!/bin/bash
# Tumblerdwatcher v 1.0
# Script to check and kill tumblerd process if a loop is suspected. To be automatically scheduled at user session start.
# Homemade workaround for bug: http://forums.linuxmint.com/viewtopic.php?f=110&t=97079&p=767460&hilit=tumblerd#p554241
# The author has no responsibility for the execution. Feel free to distribute and modify it.
# Advice are welcome to rs2809@yahoo.it.

period=60                  # check period (sec)
process="/usr/lib/i386-linux-gnu/tumbler-1/tumblerd"   # tumblerd binary path
Pcpu=20                     # tolerated cpu usage (%)
Pmem=25                     # tolerated memory usage (%)
mountpath="/media"               # automatic mount point for removable storage
sec=10                     # time limit (sec) for opened file at $mountpath for thumbnail generation
sg="-15"                  # process termination signal (-15 is OK)
logpath="/tmp/Tumblerdwatcher.log"         # log path                     

cat /dev/null > $logpath
exec >$logpath 2>&1
# reset log file

while true
# execute endlessly

 do

 sleep $period
# wait a set period of time

 [[ `ps -ef | grep $process | grep -v 'grep' | wc -l` -eq 0 ]] && continue
# skip to next period if not executing

 ps -eo pcpu,pid,pmem,args | grep $process | grep -v 'grep' | while read dpcpu pid dpmem
# catch proccess id, cpu usage and memory usage

  do

  pcpu=`echo $dpcpu | cut -d'.' -f1`
  pmem=`echo $dpmem | cut -d'.' -f1`

  [[ $pcpu -gt $Pcpu ]] || [[ $pmem -gt $Pmem ]] && kill $sg $pid && echo "`date` PID $pid $pcpu/$Pcpu %cpu $pmem/$Pmem %mem" && continue
# if cpu usage or memory usage exceed, kill it and report values in the log file

  [[ `lsof -p $pid | grep $mountpath | wc -l` -eq 0 ]] && continue
# if no opened file by tumblerd at removable storage mountpoint, skip to next period

  lsof -p $pid | grep $mountpath | tr -s ' ' | cut -d' ' -f9 > /tmp/tumblerd.lsof.old
# list opened files

  sleep $sec
# wait for tolerated time limit

  [[ `lsof -p $pid | grep $mountpath | wc -l` -eq 0 ]] && continue
# if no more opened file skip to next period

  lsof -p $pid | grep $mountpath | tr -s ' ' | cut -d' ' -f9 > /tmp/tumblerd.lsof.new
# list opened files again

  for opened_file in `cat /tmp/tumblerd.lsof.old`
# if some file was open before....
   do

     grep $opened_file /tmp/tumblerd.lsof.new && kill $sg $pid && echo "`date` PID $pid ^^^^^^^^^^^^^^^^^^^^^^^^" && continue
# ...and it's still hung open, kill tumblerd
   done

  done

done

Offline

#2 2014-07-01 21:24:37

gxagar
Member
Registered: 2012-03-14
Posts: 86

Re: Tumblerd using up CPU, and memory on Xfce and thunar

A good and helpful solution.

Thanks for your contribution, wchouser3.

You script writers amaze me!


Linuxers Live by a CODE!

Offline

#3 2014-07-11 14:31:06

wchouser3
Member
From: Indiana USA
Registered: 2014-03-22
Posts: 2

Re: Tumblerd using up CPU, and memory on Xfce and thunar

gxagar wrote:

A good and helpful solution.

Thanks for your contribution, wchouser3.

You script writers amaze me!

Certainly! I can't take all the credit, though. I found the script on a LinuxMint forum. It was written by one of their developers, I think.

Offline

#4 2016-04-16 04:27:28

Rava
Member
Registered: 2007-03-06
Posts: 9

Re: Tumblerd using up CPU, and memory on Xfce and thunar

I currently run  Porteus 3.1 with XFCe 4.10, and the bug is still there.

Soon, there will be the rc1 of Porteus 3.2 (then the rc2, then hopefully the final version, you know the drill)
I presume that then XFCe 4.12 will be included with Porteus,


Does anyone of you know if with 4.12 XFCe this bug workaround is still necessary, or is the CPU hogging bug still there?



I also found another script here https://wiki.archlinux.org/index.php/th … o_much_CPU

#!/bin/bash
period=20
tumblerpath="/usr/lib/*/tumbler-1/tumblerd" # The * here should find the right one, whether 32 and 64-bit
cpu_threshold=50
mem_threshold=20
max_strikes=2                               # max number of above cpu/mem-threshold's in a row
log="/tmp/tumblerd-watcher.log"

if [[ -n "${log}" ]]; then
    cat /dev/null > "${log}"
    exec >"${log}" 2>&1
fi


strikes=0
while sleep "${period}"; do
    while read pid; do
	cpu_usage=$(ps --no-headers -o pcpu -f "${pid}"|cut -f1 -d.)
	mem_usage=$(ps --no-headers -o pmem -f "${pid}"|cut -f1 -d.)

	if [[ $cpu_usage -gt $cpu_threshold ]] || [[ $mem_usage -gt $mem_threshold ]]; then
	    echo "$(date +"%F %T") PID: $pid CPU: $cpu_usage/$cpu_threshold %cpu MEM: $mem_usage/$mem_threshold STRIKES: ${strikes} NPROCS: $(pgrep -c -f ${tumblerpath})"
	    (( strikes++ ))
	    if [[ ${strikes} -ge ${max_strikes} ]]; then
		kill "${pid}"
		echo "$(date +"%F %T") PID: $pid KILLED; NPROCS: $(pgrep -c -f ${tumblerpath})"
		strikes=0
	    fi
	else
	    strikes=0
	fi
    done < <(pgrep -f ${tumblerpath})
done

Unfortunately it won't work with the 64 bit path of my tumblerd:

root@porteus:/# l /usr/lib/*/tumbler-1/tumblerd
ls: cannot access /usr/lib/*/tumbler-1/tumblerd: No such file or directory
root@porteus:/# l /usr/lib64/tumbler-1/tumblerd
-rwxr-xr-x 1 root 91104 2014-10-19 15:15 /usr/lib64/tumbler-1/tumblerd
root@porteus:/# l /usr/lib*/*/tumbler-1/tumblerd
ls: cannot access /usr/lib*/*/tumbler-1/tumblerd: No such file or directory
root@porteus:/# l /usr/lib*/tumbler-1/tumblerd
-rwxr-xr-x 1 root 91104 2014-10-19 15:15 /usr/lib64/tumbler-1/tumblerd

I have not run both scripts to get a good comparison, but by the code alone it seems the wiki.archlinux.org version is more "compact" or "slim-coded" and might be more CPU and RAM friendly.

Last edited by Rava (2016-04-16 04:42:16)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.014 seconds, 9 queries executed - Memory usage: 535.09 KiB (Peak: 535.94 KiB) ]