On 03/08/2019 05.33, L A Walsh wrote:
On 2019/08/02 05:07, Carlos E. R. wrote:
...
So I do:
Isengard:~ # ps afxu | grep rsyncd root 10824 0.0 0.0 7432 812 pts/29 S+ 13:57 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 760 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 8501 0.6 0.0 97452 4788 ? S 12:37 0:32 \_ /usr/sbin/rsyncd --daemon --no-detach root 8502 88.8 0.0 153260 5968 ? R 12:37 70:42 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ # cpulimit -e rsyncd -l 90 Warning: no target process found. Waiting for it... ^CExiting... Isengard:~ # cpulimit -p 8502 -l 90 Process 8502 detected
Why doesn't it act on the process by name "rsyncd"? It is obviously in the list of processes.. And I'm root.
---- It says it only acts on 1 process by that name, and to have it act on a specific one, use the pid. Which it did, you said 90%, and I see 88.8% So what's the problem?
Well... I need it to act on the last one, which is the one that does the job, and do it by name. You apparently found out why it doesn't act by name: only one process. More and it bails out.
I did it on a specific pid, and it seemed to keep it within 10%.
Problem is that it only seems to control one at a time.
You can call it several times, one per PID, then it acts on all of them: Isengard:~ # ps afxu | grep rsyncd root 14857 0.0 0.0 7432 888 pts/29 S+ 12:45 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 768 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 14843 8.1 0.0 90880 4980 ? S 12:45 0:00 \_ /usr/sbin/rsyncd --daemon --no-detach root 14844 56.2 0.0 94748 4004 ? R 12:45 0:04 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ # cpulimit --lazy --background -p 14843 -l 85 Isengard:~ # Process 14843 detected cpulimit --lazy --background -p 14844 -l 85 Isengard:~ # Process 14844 detected Isengard:~ # ps afxu | grep cpulimit root 14891 0.0 0.0 7432 884 pts/29 S+ 12:46 0:00 \_ grep --color=auto cpulimit root 21475 0.1 0.0 8556 28 pts/29 S< Aug02 1:15 cpulimit --lazy --background -p 4781 -l 85 root 14873 0.2 0.0 8556 108 pts/29 S< 12:45 0:00 cpulimit --lazy --background -p 14843 -l 85 root 14878 0.2 0.0 8556 108 pts/29 S< 12:45 0:00 cpulimit --lazy --background -p 14844 -l 85 Isengard:~ # This method I tried yesterday might be it: Isengard:~ # cpulimit -v -p `pidof rsyncd` -l 85 4 CPUs detected. Priority changed to -10 Process 20048 detected %CPU work quantum sleep quantum active rate 0.00% 100000 us 0 us 99.89% 1.11% 100000 us 0 us 99.90% 2.22% 100000 us 0 us 99.89% 2.22% 100000 us 0 us 99.89% 2.22% 100000 us 0 us 99.87% 2.22% 100000 us 0 us 99.89% 2.22% 100000 us 0 us 99.90% 2.22% 100000 us 0 us 99.91% ^CExiting... Isengard:~ # ps afxu | grep rsyncd root 20185 0.0 0.0 7432 904 pts/29 S+ 20:13 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 728 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 20047 34.9 0.7 114440 59936 ? S 20:08 1:54 \_ /usr/sbin/rsyncd --daemon --no-detach root 20048 3.9 0.8 146580 66200 ? S 20:08 0:13 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ #
Too bad there's no option for a process-group.
I wonder if systemd has something to limit total cpu load of a daemon, that would be the best thing. [...] (googling) Apparently there is: <https://stackoverflow.com/questions/29667758/use-of-cpuquota-in-systemd> [Service] CPUQuota=85% Doing it (systemctl edit rsyncd) Isengard:~ # systemctl status rsyncd ● rsyncd.service - Start the rsync server daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/rsyncd.service.d └─override.conf Active: active (running) since Sat 2019-08-03 13:11:26 CEST; 1s ago Main PID: 15728 (rsyncd) Tasks: 1 (limit: 4915) CPU: 73ms CGroup: /system.slice/rsyncd.service └─15728 /usr/sbin/rsyncd --daemon --no-detach Aug 03 13:11:26 Isengard systemd[1]: Started Start the rsync server daemon. Isengard:~ # Now call the script to do rsync job one more time. Check: Isengard:~ # systemctl status rsyncd ● rsyncd.service - Start the rsync server daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/rsyncd.service.d └─override.conf Active: active (running) since Sat 2019-08-03 13:11:26 CEST; 3min 37s ago Main PID: 15728 (rsyncd) Tasks: 3 (limit: 4915) <============= CPU: 2.066s CGroup: /system.slice/rsyncd.service ├─15728 /usr/sbin/rsyncd --daemon --no-detach ├─15796 /usr/sbin/rsyncd --daemon --no-detach └─15797 /usr/sbin/rsyncd --daemon --no-detach Aug 03 13:11:26 Isengard systemd[1]: Started Start the rsync server daemon. Isengard:~ # Bingo! :-D Sometimes I love systemd :-! :-) I was trying already a method when calling rsync job on the client to launch ssh to run cpulimit on the server and getting stump... when there was a systemd method nice and easy within a single google search :-D -- Cheers / Saludos, Carlos E. R. (from 15.0 x86_64 at Telcontar)