From e18e94bb2323e391ba8235294a61129b9ad9cb7a Mon Sep 17 00:00:00 2001 From: Trey Blancher Date: Sun, 27 Aug 2023 18:16:56 -0400 Subject: [PATCH] SSH_AGENT_PID remove superfluous grep, added print_psi to send() --- psi-alerts.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/psi-alerts.sh b/psi-alerts.sh index baaa8ea..171ea11 100755 --- a/psi-alerts.sh +++ b/psi-alerts.sh @@ -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