Script for GWWeb monitoring. Who is on a given instance right now?

2 Likes

Script to get current Soap connections of a POA (relating to Idea Exchange: GWWeb monitoring. Who is on a given instance right now?

This script will scrape the POAs Soap connections HTTP page and output a CSV file with the info:

#!/bin/bash

#POA HTTP address
POA_HTTP_ADDR=

#POA HTTP Port
POA_HTTP_PORT=

#User ID to connect with
USER=

#User ID Password
USER_PWD=

#POA Web Console URL
URL="https://$POA_HTTP_ADDR:$POA_HTTP_PORT/dsoaps"

TMP_FILE="/tmp/gwsoap_conns_$(date +%Y-%m-%d-%H.%M.%S).txt"
CSV_FILE="/tmp/gwsoap_conns_$(date +%Y-%m-%d-%H.%M.%S).csv"

CSV_HEADER="GroupWise User ID,Directory Login Name,User IP Address,Login Time,Last Activity Time,Access Mode,User Agent"

echo "$CSV_HEADER" > $CSV_FILE

#get soap connections page and save to tmp file
curl -s -k $URL -u $USER:$USER_PWD > $TMP_FILE

#loop through the lines looking for the lines matching GroupWise User
while read -r line; do
    result=`echo "$line" |grep -c -i "GroupWise User"`
    if [[ $result -eq 1 ]]; then
        GWUSERID=`echo $line |awk -F'</TD>' '{print $2}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`
        DLN=`echo $line |awk -F'</TD>' '{print $4}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`
        IPADDR=`echo $line |awk -F'</TD>' '{print $6}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`
        LOGINTIME=`echo $line |awk -F'</TD>' '{print $8}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`
        LASTACTIV=`echo $line |awk -F'</TD>' '{print $10}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`
        ACCMODE=`echo $line |awk -F'</TD>' '{print $12}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`
        USERAGENT=`echo $line |awk -F'</TD>' '{print $14}' |grep -o -P '(?<=\-1\>).*(?=\<\/FONT\>)'`

        echo "$GWUSERID,$DLN,$IPADDR,$LOGINTIME,$LASTACTIV,$ACCMODE,$USERAGENT" >> $CSV_FILE
    fi
done < $TMP_FILE

rm -f $TMP_FILE
echo "Output File: $CSV_FILE"

Labels:

Other
Support Tip
Comment List
Related
Recommended