LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-31-2006, 09:10 AM   #1
DaHoe
LQ Newbie
 
Registered: Dec 2005
Location: Eskilstuna, Sweden
Distribution: suse 10.0 , AIX 5.2 etc
Posts: 7

Rep: Reputation: 0
Log netstat at interval


Hi, I'm about to go crazy over this shell script thingy and crontab editing.

My final goal besides taking over the world and crown me to ultimate ruler of my brain, is to log a simple NETSTAT to a file at a 2 second interval between 6am - 6pm.

I'm no good at programming so all help is appreciated!

from commandline the netstat would look someting like:

netstat >> /home/guest/netstat.txt

how do i get it to run every 2 seconds in above mentioned time-span?

I've tried to write my own shell script. It wouldn't even work from commandline, and crontab wont go every 2 seconds so I'm stuck.
 
Old 10-31-2006, 09:40 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Not to thwart your in your quest for Ultimate Brain Domination, but why do you actually want to do this?
If we know the reasons we might be able to suggest faster, more efficient and exisiting (reinvent wheel) solutions.
 
Old 11-01-2006, 02:47 AM   #3
DaHoe
LQ Newbie
 
Registered: Dec 2005
Location: Eskilstuna, Sweden
Distribution: suse 10.0 , AIX 5.2 etc
Posts: 7

Original Poster
Rep: Reputation: 0
uhm, well..

I got these 2 windows 2003 terminalservers and the AES 5.2 UNIX system.

When the guys at marketing uses the unix system wich they do all the time, they usually print to pdf via acrobat, when they log in to the unix system they have to tell wich port they want to request the acrobat trough. sometimes the acrobat port is used and they have to logout and then login with a different portnumber.
I have no lagal rights to alter the login to the UNIX server so I tought I could log the traffic and then maybe give the users a span of ports not used by the server.

thats why I need the netstat, or is there a really smart linux way of doing this? I've done the netstat on the two terminalservers just to check if it works.. results: on each TS there is a txt file @ 1.213GB :P

Got one of my co-workers fixxin a script to sort out the junk from the things I need.
 
Old 11-01-2006, 07:08 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
So we're talking about Adobe Distiller, right? And it is the UNIX version? Does the box run SNMP by any chance? If so, then it's easy to set up a line for showing ports in use by distiller. If there's no SNMP then it's still rather easy. While netstat is one way to list all ports in use it's way too broad (can't really select). So if you can grab the process ID of distiller (for instance with "pgrep" but a ps|grep should do too) it's easier to feed that info into a more selective app like "lsof" (in the GNU/Linux dialect "lsof -i -a -p $PID -Fn" should do) and parse that output into a list of used ports. If the box runs a webserver it's easy to make that a CGI that refreshes when asked for, which is better for performance, but that's icing on the cake.

So the yes/no questions are: distiller? UNIX? SNMP? lsof? And what is the process name called?
 
Old 11-06-2006, 03:11 AM   #5
DaHoe
LQ Newbie
 
Registered: Dec 2005
Location: Eskilstuna, Sweden
Distribution: suse 10.0 , AIX 5.2 etc
Posts: 7

Original Poster
Rep: Reputation: 0
No distiller found, yes, UNIX AIX 5.2, SNMP not foud either, no lsof either:/
process names, for each user instance: sh, todayx, crom.exe

apparently it also can export to exel and stuff, so not only pdf, tough when a user logs in to the unix system, it starts a couple of new processes, havent had the chans to test any pgrep yet.

I noticed in the config file each user has for the unix system, there is a row "crmrshdport=131177"
without a port number assigned the user cannot log in.
I think i only have to monitor the sh process for each user, right?

Last edited by DaHoe; 11-06-2006 at 07:46 AM.
 
  


Reply


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
ifup only connects on interval 13, how do I force this? unholy Linux - Wireless Networking 1 07-30-2006 09:19 PM
Sendmail, interval between mailsending? godzern Linux - General 1 05-02-2006 05:48 PM
hid interval patch some Linux - Newbie 5 12-04-2003 07:28 AM
NTP polling interval in Linux? oswald21 Linux - Networking 1 03-10-2003 04:20 PM
Programmable Interval Timers saintt Linux - General 0 10-19-2001 09:50 AM


All times are GMT -5. The time now is 02:55 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration