Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Sys::Syslog question

Reply
Thread Tools

Sys::Syslog question

 
 
Dave Saville
Guest
Posts: n/a
 
      02-04-2011
I am writing a script that takes a named pipe as input, does a little
massaging of the text and then writes it to syslog. The data could
come infrequently or in bursts depending on the output of the daemon
whose pipe I am reading.

The question is, which is best practice?

1) Inside the read pipe loop - openlog, write, close log for every
line.
2) Openlog outside the pipe read loop and write each line as it comes?
ie keep the file open.

Google does not suggest an answer. I tend to 1) but it is a heck of an
overhead if a few thousand lines hits the fan.

TIA

--
Regards
Dave Saville
 
Reply With Quote
 
 
 
 
Martijn Lievaart
Guest
Posts: n/a
 
      02-04-2011
On Fri, 04 Feb 2011 11:50:46 +0000, Dave Saville wrote:

> I am writing a script that takes a named pipe as input, does a little
> massaging of the text and then writes it to syslog. The data could come
> infrequently or in bursts depending on the output of the daemon whose
> pipe I am reading.
>
> The question is, which is best practice?
>
> 1) Inside the read pipe loop - openlog, write, close log for every line.
> 2) Openlog outside the pipe read loop and write each line as it comes?
> ie keep the file open.


What's wrong with option 2?

M4
 
Reply With Quote
 
 
 
 
Dave Saville
Guest
Posts: n/a
 
      02-04-2011
On Fri, 4 Feb 2011 12:36:06 UTC, Martijn Lievaart <(E-Mail Removed)>
wrote:

> On Fri, 04 Feb 2011 11:50:46 +0000, Dave Saville wrote:
>
> > I am writing a script that takes a named pipe as input, does a little
> > massaging of the text and then writes it to syslog. The data could come
> > infrequently or in bursts depending on the output of the daemon whose
> > pipe I am reading.
> >
> > The question is, which is best practice?
> >
> > 1) Inside the read pipe loop - openlog, write, close log for every line.
> > 2) Openlog outside the pipe read loop and write each line as it comes?
> > ie keep the file open.

>
> What's wrong with option 2?
>


Well I am not sure if keeping an open connection to the syslogd daemon
for days on end is a good idea


--
Regards
Dave Saville
 
Reply With Quote
 
Martijn Lievaart
Guest
Posts: n/a
 
      02-04-2011
On Fri, 04 Feb 2011 13:01:45 +0000, Dave Saville wrote:

> On Fri, 4 Feb 2011 12:36:06 UTC, Martijn Lievaart <(E-Mail Removed)>
> wrote:
>
>> On Fri, 04 Feb 2011 11:50:46 +0000, Dave Saville wrote:
>>
>> > I am writing a script that takes a named pipe as input, does a little
>> > massaging of the text and then writes it to syslog. The data could
>> > come infrequently or in bursts depending on the output of the daemon
>> > whose pipe I am reading.
>> >
>> > The question is, which is best practice?
>> >
>> > 1) Inside the read pipe loop - openlog, write, close log for every
>> > line. 2) Openlog outside the pipe read loop and write each line as it
>> > comes? ie keep the file open.

>>
>> What's wrong with option 2?
>>
>>

> Well I am not sure if keeping an open connection to the syslogd daemon
> for days on end is a good idea


Think about it this way (although I may be wrong). The only real problem
that can occur is restarting the syslog deamon and thus losing the
connection. But if that was a real problem, it can happen anytime between
opening syslog and writing to it. So Either there is no problem, or the
problem must be addressed anyhow.

But maybe someone else knows more? You could also ask in a Unix group, as
this is actually more about the clib functionality than the perl wrapper
around it.

HTH,
M4
 
Reply With Quote
 
Eric Pozharski
Guest
Posts: n/a
 
      02-05-2011
with <fV45K0OBJxbE-pn2-djbSFegGnbeu@localhost> Dave Saville wrote:
> On Fri, 4 Feb 2011 12:36:06 UTC, Martijn Lievaart <(E-Mail Removed)>
> wrote:
>
>> On Fri, 04 Feb 2011 11:50:46 +0000, Dave Saville wrote:

*SKIP*
>> > The question is, which is best practice?
>> >
>> > 1) Inside the read pipe loop - openlog, write, close log for every
>> > line.
>> > 2) Openlog outside the pipe read loop and write each line as it
>> > comes? ie keep the file open.

>>
>> What's wrong with option 2?
>>

>
> Well I am not sure if keeping an open connection to the syslogd daemon
> for days on end is a good idea


Sysloging over network is of UDP kind, thus no-connection. OTOH, if
there's any connection with /dev/log I can't say without investigation
(and, honestly, I'm not interested). And please note, fork(2) is
costly. open(2) isn't. You can safely (if you wish) open-write-close.
With amounts of bytes you're going to syslog you'll see no problems.

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
 
Reply With Quote
 
Dave Saville
Guest
Posts: n/a
 
      02-06-2011
On Sat, 5 Feb 2011 10:42:31 UTC, Eric Pozharski
<(E-Mail Removed)> wrote:

> with <fV45K0OBJxbE-pn2-djbSFegGnbeu@localhost> Dave Saville wrote:
> > On Fri, 4 Feb 2011 12:36:06 UTC, Martijn Lievaart <(E-Mail Removed)>
> > wrote:
> >
> >> On Fri, 04 Feb 2011 11:50:46 +0000, Dave Saville wrote:

> *SKIP*
> >> > The question is, which is best practice?
> >> >
> >> > 1) Inside the read pipe loop - openlog, write, close log for every
> >> > line.
> >> > 2) Openlog outside the pipe read loop and write each line as it
> >> > comes? ie keep the file open.
> >>
> >> What's wrong with option 2?
> >>

> >
> > Well I am not sure if keeping an open connection to the syslogd daemon
> > for days on end is a good idea

>
> Sysloging over network is of UDP kind, thus no-connection. OTOH, if
> there's any connection with /dev/log I can't say without investigation
> (and, honestly, I'm not interested). And please note, fork(2) is
> costly. open(2) isn't. You can safely (if you wish) open-write-close.
> With amounts of bytes you're going to syslog you'll see no problems.
>


Thanks - going for option 2 and see if I get any problems.
--
Regards
Dave Saville
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments