SSH_AGENT_PID remove superfluous grep, added print_psi to send()

This commit is contained in:
Trey Blancher 2023-08-27 18:16:56 -04:00
parent 23ab5a2371
commit e18e94bb23

View File

@ -61,7 +61,7 @@ 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 | \
export SSH_AGENT_PID=$(ps -eaf | grep '[s]sh-agent' | \
grep ${user} | awk '{print $2}')
export SSH_AUTH_SOCK=$(ls ${dir}/agent.* | tail -1)
fi
@ -186,11 +186,12 @@ send () {
subj="PSI on ${host} ${psi_type} triggered!"
current_alarms="${psi_type}"
fi
print_psi "${psi_type}" >> ${email}
printf "\n\n" >> ${email}
# is this an email or SMS?
if [[ ! "${dst}" =~ "@${sms_domain}" ]]; then
for p in $(tr '|' ' ' <<< "${current_alarms}"); do
printf "\nStatistics info for ${p}\n\n" >> ${email}
printf "\n\nStatistics info for ${p}\n\n" >> ${email}
print_stats "${p}" >> ${email}
printf "\n\n" >> ${email}
done