Pārlūkot izejas kodu

Replace slow lsof with procfs access

master
JustAnotherArchivist pirms 5 gadiem
vecāks
revīzija
e3a4bf6a47
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. +1
    -1
      archivebot-list-stuck-requests

+ 1
- 1
archivebot-list-stuck-requests Parādīt failu

@@ -1,3 +1,3 @@
#!/bin/bash
# For each ArchiveBot job running on the machine, list requests that are stuck, i.e. older than 6 hours
ps -C wpull --format 'cmd' --no-headers | sed 's,^\s*,,; s,/usr/bin/python3.*/data/[^/]\+/\([0-9a-z]\+\)/wpull\.log.*$,\1,' | while read -r jobid; do pid=$(pgrep -f $jobid); echo "$jobid (PID $pid)"; fs=$(find $(lsof -p $pid -F n | grep '^n.*tmp-wpull-warcsesreq-' | sed 's,^n,,') -mmin +360 2> >(grep -v ': No such file or directory$' >&2)); if [[ "${fs}" ]]; then forf in ${fs}; do mtime=$(date --date="@$(stat -c '%Y' ${f})" '+%Y-%m-%d %H:%M:%S %Z'); grep ^Host ${f} | while read -r outline; do echo "${mtime} ${f} ${outline}"; done; done | sort; else echo 'None'; fi; echo; done
ps -C wpull --format 'pid,cmd' --no-headers | sed 's,^\s*,,; s,\s*/usr/bin/python3.*/data/[^/]\+/\([0-9a-z]\+\)/wpull\.log.*$, \1,' | while read -r pid jobid; do echo "$jobid (PID $pid)"; fs=$(find /proc/${pid}/fd -lname '*/tmp-wpull-warcsesreq-*' -printf '%l\n' 2> >(grep -v ': No such file or directory$' >&2)); fs=$(find ${fs} -mmin +360); if [[ "${fs}" ]]; then for f in ${fs}; do mtime=$(date --date="@$(stat -c '%Y' ${f})" '+%Y-%m-%d %H:%M:%S %Z'); grep ^Host ${f} | while read -r outline; do echo "${mtime} ${f} ${outline}"; done; done | sort; else echo 'None'; fi; echo; done

Notiek ielāde…
Atcelt
Saglabāt