#!/bin/bash
# ------------------------------------------------------------------------------
# Copyright (c) 2011-2016 SUSE Linux GmbH, Nuernberg, Germany.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 2 of the GNU General Public License as published by the
# Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, contact SUSE Linux GmbH.
#
# ------------------------------------------------------------------------------
# lsoflog
#	log the open file list with timestamp
# Author: L.Pinne.
# Version: 0.1 2011-10-17

D=$(date +"%F %T")
E="/dev/null"
L=${1:-"/var/log/lsof.log"}
P=${2:-"+D/opt +D/srv"}
T=${3:-"42"}

lsof -n -P -X -w -S $T +fg +x ${P} 2>$E | while read; do
	echo $D: $REPLY
done >>$L
#
