LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 01-20-2010, 09:03 PM   #1
baracooda
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 0
Is there a cli command for logging the status of a NIC - eth0


I would like to know if it's possible to create a continual log for a network interface card's status. That is whether it's up or down and time and date stamped if possible.
I'm wondering if there is a cli command that exists to do this
I've looked at "ethtool" but this only sets the parameters of the nic.
Also looked at the log files that I could find /dev/log var/log, but there is no mention of a status for eth0.
 
Old 01-20-2010, 09:23 PM   #2
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,590

Rep: Reputation: 1233Reputation: 1233Reputation: 1233Reputation: 1233Reputation: 1233Reputation: 1233Reputation: 1233Reputation: 1233Reputation: 1233
The sys file system provides *heaps* of information. For example /sys/class/net/eth1/operstate for up/down information
Or for a whole bunch of detailed information have a look at the files in /sys/class/net/eth0/statistics/

Cheers,

Evo2.
 
Old 01-20-2010, 10:23 PM   #3
baracooda
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you for the info evo2, certainly put me in the right direction.
Unfortunately /sys/class/net/eth0/operstate only provides the status of the
eth0 at the time of viewing and is not appended but update as the state changes.

I was hoping more along the lines of date and time stamp for status change,
similar to a startup / shutdown log under sys.
 
Old 01-20-2010, 11:01 PM   #4
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: *buntu, Vector
Posts: 499

Rep: Reputation: 102Reputation: 102
Depending on time interval, you could either create a cron job, or run a bash script.
For example
Code:
while true ; do cat /sys/class/net/eth0/operstate >> network_stats ; sleep 60 ; done
The number after sleep is the time to wait in seconds. So this example takes the stats every minute.
If you only want to log changes, you could do more sophisticated stuff, probably using grep and sed.
 
  


Reply

Tags
eth0, logging, stamp, status


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
eth0 NIC Card Not Working! 3com 3c501 NIC. Mustard010 Linux - Networking 16 08-15-2007 03:22 AM
CLI -- Logging Out and Logging In StyngerSmash Linux - Newbie 1 09-05-2006 05:23 AM
User logging status shankarjha Linux - Newbie 2 04-17-2006 04:14 PM
Starting CLI programs in aterm when logging in ethics Linux - General 0 11-29-2005 07:34 PM
Redhat 8 and eth0 (NIC) status nathanv117 Linux - Newbie 8 01-02-2003 09:19 PM


All times are GMT -5. The time now is 07:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration