summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2021-10-19 08:50:58 -0400
committerAndrew Cady <d@cryptonomic.net>2021-10-19 08:51:53 -0400
commit3b3d7d7f9a1d607241ba5b8e1cb7f36fbf710575 (patch)
tree0b29aa0945b35227bca0902209eb9bdc57eb5cf0
parent47c72d59b2fe1234df8fad442f2ad26c2f84fab9 (diff)
new command ioslay-firefox
it fucking works it actually fucking works keep this command running and firefox won't make the system unresponsive -- AND it won't make itself unresponsive for more than a few seconds.
-rw-r--r--Makefile2
-rwxr-xr-xioslay-firefox53
2 files changed, 54 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3d6a476..498afa8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
1BINDIR = /usr/local/bin 1BINDIR = /usr/local/bin
2BINARIES = sliceweasel fireslay 2BINARIES = sliceweasel fireslay ioslay-firefox
3SUDO != [ "$$(id -u)" = 0 ] || echo sudo 3SUDO != [ "$$(id -u)" = 0 ] || echo sudo
4 4
5.PHONY: install install-bin 5.PHONY: install install-bin
diff --git a/ioslay-firefox b/ioslay-firefox
new file mode 100755
index 0000000..eac3184
--- /dev/null
+++ b/ioslay-firefox
@@ -0,0 +1,53 @@
1#!/bin/sh
2
3if [ "$1" = -q ]
4then
5 exec 2>/dev/null
6 shift
7fi
8
9web_content_pids()
10{
11 top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | {
12 while read line
13 do set -- $line
14 [ "${12} ${13}" = "Web Content" ] || continue
15 echo $1
16 done
17 }
18}
19
20set -- $(web_content_pids | tac)
21
22set -- $(printf "\055\055pid=%s " $*)
23
24over_count=0
25sudo -- iotop -qq -b "$@" |
26 while read line
27 do
28 case "$line" in
29 "Total DISK"*)
30 if [ "$OVER" ]
31 then
32 over_count=$((over_count + 1))
33 if [ "$over_count" -gt 3 ]
34 then
35 fireslay
36 fi
37 over=
38 else
39 over_count=0
40 fi
41 ;;
42 "Current DISK"*) continue ;;
43 *)
44 set -- $line
45 pct=${10%.*}
46 if [ $pct -gt 90 ]
47 then
48 printf '[%d] %s%% %s\n' "$over_count" "${10}" "${12}" >&2
49 over=y
50 fi
51 ;;
52 esac
53 done