Simple script for monitoring stats by active sessions of Terminal Server Identity Agent:
#!/bin/bash
# Gaia 77.10
clear
echo Statistics for Terminal Server Identity Agent
echo
echo -------------------------------
pdp connections ts
echo -------------------------------
ts_list=( `pdp connections ts | grep -P "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"` )
for ts in "${ts_list[@]}"
do
echo
echo
echo Stats for $ts
echo -------------------------------
active_session=`pdp monitor ip $ts | grep Client | awk '{ print $1 }' | wc -l`
session_without_assigned_tcp_ports=`pdp monitor ip $ts | grep -B 3 "Tcp Ports: -" | grep @ | awk '{ print $1 }' | wc -l`
session_without_assigned_udp_ports=`pdp monitor ip $ts | grep -B 3 "Udp Ports: -" | grep @ | awk '{ print $1 }' | wc -l`
#echo $active_session
echo Active Session: $active_session
echo Sessions without assigned Tcp Ports: $session_without_assigned_tcp_ports
echo Sessions without assigned Udp Ports: $session_without_assigned_udp_ports
done
echo -------------------------------
and simple script for send stats to predefined syslog server:
#!/bin/bash
# Gaia 77.10
state=`cphaprob stat | grep local.*Active`
if [ "$state" ]; then
ts_list=( `pdp connections ts | grep -P "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"` )
for ts in "${ts_list[@]}"
do
active_session=`pdp monitor ip $ts | grep Client | awk '{ print $1 }' | wc -l`
session_without_assigned_tcp_ports=`pdp monitor ip $ts | grep -B 3 "Tcp Ports: -" | grep @ | awk '{ print $1 }' | wc -l`
session_without_assigned_udp_ports=`pdp monitor ip $ts | grep -B 3 "Udp Ports: -" | grep @ | awk '{ print $1 }' | wc -l`
echo "TSIA stats for $ts: ts=$ts active_session=$active_session session_without_assigned_tcp_ports=$session_without_assigned_tcp_ports session_without_assigned_udp_ports=$session_without_assigned_udp_ports" 2>&1 | logger -t CheckPoint -p local3.warning &
done
fi