LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-02-2012, 12:36 PM   #1
mgai7755
Member
 
Registered: Apr 2011
Posts: 51

Rep: Reputation: 10
Simple TCP/IP receiver


Hi,

I'm looking for a simple tool or way to receive and log a text stream (log file) send by a client (squid) on a TCP port.

The TCP server would need to be launched automatically at boot.

I also need to be able to rotate the generated log file using logrotate.

Anybody could point me to a solution ? FYI The server is a Debian.

Thanks

Matt

Last edited by mgai7755; 07-02-2012 at 12:49 PM.
 
Old 07-02-2012, 01:00 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,753

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by mgai7755 View Post
Hi,
I'm looking for a simple tool or way to receive and log a text stream (log file) send by a client (squid) on a TCP port.

The TCP server would need to be launched automatically at boot. I also need to be able to rotate the generated log file using logrotate. Anybody could point me to a solution ? FYI The server is a Debian.
Read about the access_log directive for squid:
http://www.squid-cache.org/Doc/config/access_log/

Set it to be "syslog"; anything logged to the squid logs will then be sent to your syslog server. Since you can send your syslog events to a REMOTE syslog server (preferably running syslog-ng, so you can separate things into different files for different servers), that will mean your squid events will go to a remote syslog server into a file. From there, set up logrotate to perform how you wish. Syslog servers should normally be started at boot time.
 
Old 07-02-2012, 03:39 PM   #3
zwcbz
LQ Newbie
 
Registered: Jul 2012
Distribution: Ubuntu 12.10, Back | Track 5
Posts: 2

Rep: Reputation: Disabled
Netcat

Hi there, have you checked out NetCat yet? It;s known as the TCP/IP swiss army knife
 
1 members found this post helpful.
Old 07-03-2012, 03:56 AM   #4
mgai7755
Member
 
Registered: Apr 2011
Posts: 51

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by TB0ne View Post
Read about the access_log directive for squid:
http://www.squid-cache.org/Doc/config/access_log/

Set it to be "syslog"; anything logged to the squid logs will then be sent to your syslog server. Since you can send your syslog events to a REMOTE syslog server (preferably running syslog-ng, so you can separate things into different files for different servers), that will mean your squid events will go to a remote syslog server into a file. From there, set up logrotate to perform how you wish. Syslog servers should normally be started at boot time.
Thanks TB0ne. I'm aware of this possibility and managed to get it work. However, there are multiple difficulties linked to this way of doing it :
  • PfSense's syslog server doesn't support sending messages over a TCP link. UDP isn't reliable enough in this case.
  • My file server is coming with an old rsyslog server which doesn't implement a way to send the remote messages in a particular file, meaning squid's messages are sent to the syslog.log file together with local events.
  • And last but not least, I think my version of rsyslog doesn't support the template system that is needed to remove the timestamps normally added before each message received. That means that a squid log analyzer would be unable to handle the log file.


Therefore, I thought is was easier and more reliable to use squid's ability to send the logs through a simple TCP link.

Last edited by mgai7755; 07-03-2012 at 03:58 AM.
 
Old 07-03-2012, 06:43 AM   #5
mgai7755
Member
 
Registered: Apr 2011
Posts: 51

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by zwcbz View Post
Hi there, have you checked out NetCat yet? It;s known as the TCP/IP swiss army knife
That's indeed a good direction ! I succeeded testing with nc -l -p 1698 > pfsense.log to open port 1698 to listen.

Two questions :

* I noticed the process quit when the connexion is closed from the client side. Is there a way to keep the server from closing ?
* I'm not so good at Linux... How can I add safely and reliably to the startup items ? (Automatic start at boot and restart in case of failure)

Thanks

Matt
 
  


Reply



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
Simple multi-threaded/forked TCP listener/server systemlordanubis Programming 2 08-12-2010 02:56 AM
Linux change TCP kernel Parameter for TCP DELAY ACK TICKS linux_mando Linux - Networking 5 08-22-2006 08:20 AM
Simple TCP proxy Bopi Linux - Networking 9 07-24-2006 01:47 PM
tcp ---I just need a simple explaination what this means--going to install mail serve xstation Linux - Networking 1 12-25-2005 03:48 PM
tough question about receiver window in TCP djcham Linux - Networking 0 09-20-2005 07:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:55 AM.

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
Open Source Consulting | Domain Registration