Skip to content
Snippets Groups Projects
Verified Commit 2dc3716c authored by David Beniamine's avatar David Beniamine
Browse files

Timestamp hosts

parent 80bcc644
Branches
No related tags found
No related merge requests found
...@@ -22,15 +22,24 @@ getip(){ ...@@ -22,15 +22,24 @@ getip(){
} }
IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1) IP=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1)
# broadcast=$(ip a | awk '/inet.*eth1/ {print $4}' | cut -d / -f 1)
# subnet=$(ip a | awk '/inet.*containers/ {print $2}' | cut -d / -f 1 | cut -d . -f 1-3)
# host=$subnet.51
port=9998 port=9998
conf_dir="/etc/registry" conf_dir="/etc/registry"
conf_file="$conf_dir/hosts"
if [ ! -d $conf_dir ] if [ ! -d $conf_dir ]
then then
# Init
mkdir $conf_dir mkdir $conf_dir
else
# Clean
while read line
do
if [ "$(echo $line | cut -d ' ' -f 1)" -gt "$(date -d '-6 month' +%Y%m%d)" ]
then
LINES="$LINES\n$(date +%Y%m%d) $(echo $line | cut -d ' ' -f 2-)"
fi
done < $conf_file
echo $LINES > $conf_file
fi fi
while true while true
...@@ -38,7 +47,7 @@ do ...@@ -38,7 +47,7 @@ do
line=`netcat -l $IP $port` line=`netcat -l $IP $port`
if [ $(echo "$line" | egrep -c "^([0-9a-f]{2}:?){6} .*$") -eq 1 ] if [ $(echo "$line" | egrep -c "^([0-9a-f]{2}:?){6} .*$") -eq 1 ]
then then
echo $line >> $conf_dir echo "$(date +%Y%m%d) $line" >> $conf_file
fi fi
done done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment