Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
log file
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
john7002
Apprentice
Apprentice


Joined: 21 Jan 2004
Posts: 238
Location: United Kingdom

PostPosted: Tue Jan 27, 2004 11:36 pm    Post subject: log file Reply with quote

Hi,

I'd like to create a log file which can allow me to know when my provider change my IP. I just need to know the date and the hour of the disconnection. Does anyone know?

Thanks
Back to top
View user's profile Send private message
hadfield
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 308
Location: Vancouver, BC, Canada

PostPosted: Wed Jan 28, 2004 12:00 am    Post subject: Reply with quote

The dhcp information your looking for is located at /etc/dhcpc/. I'm not sure if these files are only modified on reboot or by the dhcpc daemon, but I think they're modified by the daemon. You could make a copy of the current files and put them into a log, say at /var/log/dhcpc. You could have a log file for every interface using dhcp. So one might look like /var/log/dhcpc/dhcpcd-eth0.log. It would contain the concatenation of all changed dhcpcd-eth0.info files. Then write a small cron job that gets executed on an hourly basis it would just need to check the timestamp on the dhcpcd-eth0.info file and compare it with the dhcpcd-eth0.log file, if the info file is newer, then concatenate the new info file to the log. I'll see if I can come up with something and post it here if I do.
Back to top
View user's profile Send private message
hadfield
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 308
Location: Vancouver, BC, Canada

PostPosted: Wed Jan 28, 2004 12:25 am    Post subject: Reply with quote

Ok, this might work:

Code:

#!/bin/bash
if [ /etc/dhcpc/dhcpcd-eth0.info -nt /var/log/dhcpc/dhcpcd-eth0.log ]; then
   echo -e "\ndhcpcd info added at `date`"
   cat /etc/dhcpc/dhcpcd-eth0.info >> /var/log/dhcpc/dhcpcd-eth0.log
fi


I haven't actually tested this, but it should work. Just put it in a file in cron.hourly and it should get executed every hour.

Hope this helps.[/code]
Back to top
View user's profile Send private message
john7002
Apprentice
Apprentice


Joined: 21 Jan 2004
Posts: 238
Location: United Kingdom

PostPosted: Wed Jan 28, 2004 12:28 am    Post subject: Reply with quote

thank you very much ! I'll test it tomorrow...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum