- you can populate a database,
- you can write to log files
The Environment variable to use for an event for control panel:
- login would be ${NEW_CONTACT_NAME}
- logout would be ${OLD_CONTACT_NAME}
one simple script to save some information in database and log some info in /var/log/syslog follows.
#!/bin/bash
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
myTimeStamp=$(date +%Y-%m-%d-%T--%N)
myFullPath=/var/log/events.log/client-cp-login-$myTimeStamp.eml
echo ""--------------"" >> $myFullPath
/bin/date >> $myFullPath
/usr/bin/id >> $myFullPath
echo ""client just logged in"" >> $myFullPath
echo ""name: ${NEW_CONTACT_NAME}"" >> $myFullPath
echo ""--------------"" >> $myFullPath
dbuser='username';
dbpass='secret';
LOG=$(mysql -u$dbuser -p$dbpass psa --batch -N -e "SET NAMES 'utf8'; SELECT CONCAT('user ',s.login,' logged in from ', s.ip_address,' moreUserInfo: ', c.pname) FROM sessions s join clients c WHERE s.login=c.login AND c.pname ='${NEW_CONTACT_NAME}' LIMIT 1;")
logger -t "plesk-client-login" "$LOG"
echo $LOG >> $myFullPath
myTimeStamp=$(date +%Y-%m-%d-%T)
#mail -a "Content-Type: text/plain; charset=UTF-8" -s "PLESK CP LOGIN: ${NEW_CONTACT_NAME} - $myTimeStamp" -b jkara@ccf.auth.gr -c fpapaste@ccf.auth.gr gkougiou@ccf.auth.gr < $myFullPath
mail -S sendcharsets=utf-8 -s "PLESK CP LOGIN: ${NEW_CONTACT_NAME} - $myTimeStamp" -b jkara@ccf.auth.gr -c fpapaste@ccf.auth.gr gkougiou@ccf.auth.gr < $myFullPath