mirror of
https://github.com/AG7GN/nexus-utilities.git
synced 2025-05-15 22:20:09 -07:00
Fix date calculation in vnc-server-activity.sh
This commit is contained in:
parent
818f2b2774
commit
8815b0cabd
@ -6,7 +6,7 @@
|
|||||||
# Usage: vnc-server-activity.sh [email-address[,email-address]...]
|
# Usage: vnc-server-activity.sh [email-address[,email-address]...]
|
||||||
#
|
#
|
||||||
|
|
||||||
VERSION="1.2.0"
|
VERSION="1.2.1"
|
||||||
|
|
||||||
# Pat and patmail.sh must be installed. If they are not, exit.
|
# Pat and patmail.sh must be installed. If they are not, exit.
|
||||||
command -v pat >/dev/null 2>&1 || exit 1
|
command -v pat >/dev/null 2>&1 || exit 1
|
||||||
@ -28,13 +28,13 @@ if [[ -s $FILES ]]
|
|||||||
then
|
then
|
||||||
echo "VNC Activity" > $OUTFILE
|
echo "VNC Activity" > $OUTFILE
|
||||||
grep -h Connections $FILES* 2>/dev/null 1>$FILTERED
|
grep -h Connections $FILES* 2>/dev/null 1>$FILTERED
|
||||||
if [ -s $FILTERED ]
|
if [[ -s $FILTERED ]]
|
||||||
then
|
then
|
||||||
while IFS= read -r LINE
|
while IFS= read -r LINE
|
||||||
do
|
do
|
||||||
D="${LINE%% $HOSTNAME*}" # Extract date from log message
|
D="${LINE%% $HOSTNAME*}" # Extract date from log message
|
||||||
E="$(date --date="$D" +'%s')" # Convert date to epoch
|
E="$(date --date="$D" +'%s')" # Convert date to epoch
|
||||||
if [ $E -gt $NOW ]
|
if (( $E > $NOW ))
|
||||||
then # Now in new year. (Log messages don't include year, so it's a problem going from December to January.)
|
then # Now in new year. (Log messages don't include year, so it's a problem going from December to January.)
|
||||||
# Account for leap years
|
# Account for leap years
|
||||||
date -d $(date +%Y)-02-29 >/dev/null 2>&1 && SEC_IN_YEAR=$((60 * 60 * 24 * 366)) || SEC_IN_YEAR=$((60 * 60 * 24 * 365))
|
date -d $(date +%Y)-02-29 >/dev/null 2>&1 && SEC_IN_YEAR=$((60 * 60 * 24 * 366)) || SEC_IN_YEAR=$((60 * 60 * 24 * 365))
|
||||||
@ -65,8 +65,8 @@ FILES="/usr/share/dwagent/dwagent.log"
|
|||||||
if [[ -s $FILES ]]
|
if [[ -s $FILES ]]
|
||||||
then
|
then
|
||||||
echo -e "\nDWService Activity" >> $OUTFILE
|
echo -e "\nDWService Activity" >> $OUTFILE
|
||||||
grep -h session $FILES* 2>/dev/null 1>$FILTERED
|
grep -Ihs session $FILES* | grep "^[0-9]*" 2>/dev/null 1>$FILTERED
|
||||||
if [ -s $FILTERED ]
|
if [[ -s $FILTERED ]]
|
||||||
then
|
then
|
||||||
while IFS= read -r LINE
|
while IFS= read -r LINE
|
||||||
do
|
do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user