Added user variable, and SSH_AGENT_PID

This commit is contained in:
Trey Blancher 2023-08-26 09:17:08 -04:00
parent 030f4f34f1
commit 23ab5a2371

View File

@ -42,6 +42,7 @@ svc="psi-monitor.service"
cpu="/proc/pressure/cpu"
mem="/proc/pressure/memory"
io="/proc/pressure/io"
user="$(whoami)"
host="$(hostname)"
email_to="${EMAIL_TO}"
sms_dst="${SMS_DST}"
@ -60,6 +61,8 @@ get_ssh_agent () {
for dir in /tmp/ssh-*; do
if [[ -O ${dir} ]]; then
# only choose the last agent
export SSH_AGENT_PID=$(ps -eaf | grep ssh-agent | grep -v grep | \
grep ${user} | awk '{print $2}')
export SSH_AUTH_SOCK=$(ls ${dir}/agent.* | tail -1)
fi
done