For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2005 > Re: Sys::Syslog problems









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Sys::Syslog problems
Otto J. Makela

2005-01-26, 8:55 am

"Karen Wieprecht" <karen.wieprecht@jhuapl.edu> wrote:

> 1. If you are using perl prior to version 5.6, something special had
> to be done to build syslog.ph in order to be able to use Sys::Syslog
> (you'll need to google to find these instructions)


Nope, I've tried this out on Solaris 5.8 with both perl 5.8.0 and
5.8.6; also, it worked when I tried it on a Solaris 5.9 (perl 5.6.1)
and a FC3 Linux (perl 5.8.5) machine; also, I wrote a almost identical
tester program in C and it worked fine.

I've Googled relevant keywords, to find several cursings about similar
problems, but no obvious workable solutions. Suggestions on what to try,
before I just give up and build a wrapper around /usr/bin/logger?

Summary: The following ultra-simple syslog test program seems to fail
on Solaris 5.8 (all perl version tried) for unknown (complex) reasons.

Followup-to: comp.lang.perl.modules

----

#!/usr/bin/perl -w

use strict;

$0 =~ s,^.*\/,,o;

sub LOG {
use Sys::Syslog;
openlog($0,'pid','mail');
syslog('info',@_) || die "error in syslog: $!\n";
}

LOG("mail informational message");

--
/* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */
/* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */
/* Mail: Mechelininkatu 26 B 27, FIN-00100 Helsinki, FINLAND */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */
hume.spamfilter@bofh.halifax.ns.ca

2005-01-26, 3:56 pm

In comp.unix.solaris Otto J. Makela <om@iki.fi> wrote:
> Summary: The following ultra-simple syslog test program seems to fail
> on Solaris 5.8 (all perl version tried) for unknown (complex) reasons.


Is your copy of syslogd running with -t, to disable network syslogging?
Sys::Syslog doesn't appear to understand logging through /dev/log.

I use Unix::Syslog myself, although it doesn't come with Perl.

--
Brandon Hume - hume -> BOFH.Halifax.NS.Ca, http://WWW.BOFH.Halifax.NS.Ca/
Karen Wieprecht

2005-01-27, 8:56 pm

> I use Unix::Syslog myself, although it doesn't come with Perl.

OK, I found, rtfm'ed, downloaded, built, and installed Unix::Syslog.
Gues what? This works (Yey!) and I get output into the system log.
Guess what else? I still have logger delays (*sniff*). UGH.

So, have any idea if there is a way to use Unix::Syslog and configure it to
fluch the write buffer immediately? I couldn't find a lot of example code
or man pages on the nmodule.

Thanks for the lead, wich I could get the kinks out though.

Karen Wieprecht


Otto J. Makela

2005-01-28, 3:57 pm

hume.spamfilter@bofh.halifax.ns.ca wrote:

> I use Unix::Syslog myself, although it doesn't come with Perl.


Tried installing it. What a strange way to fail:

#/usr/bin/perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.76)
ReadLine support enabled

cpan> install Unix::Syslog
CPAN: Storable loaded ok
Going to read /home/makelot1/.cpan/Metadata
Database was generated on Fri, 28 Jan 2005 08:37:28 GMT
Running install for module Unix::Syslog
Running make for M/MH/MHARNISCH/Unix-Syslog-0.99.tar.gz
CPAN: Digest::MD5 loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for /home/makelot1/.cpan/sources/authors/id/M/MH/MHARNISCH/Unix-Syslog-0.99.tar.gz ok
Scanning cache /home/makelot1/.cpan/build for sizes
x Unix-Syslog-0.99, 0 bytes, 0 tape blocks
x Unix-Syslog-0.99/Syslog.xs, 3873 bytes, 8 tape blocks
x Unix-Syslog-0.99/README, 5322 bytes, 11 tape blocks
x Unix-Syslog-0.99/Artistic, 6111 bytes, 12 tape blocks
x Unix-Syslog-0.99/MANIFEST, 73 bytes, 1 tape blocks
x Unix-Syslog-0.99/test.pl, 9426 bytes, 19 tape blocks
x Unix-Syslog-0.99/Changes, 2996 bytes, 6 tape blocks
x Unix-Syslog-0.99/Makefile.PL, 449 bytes, 1 tape blocks
x Unix-Syslog-0.99/Syslog.pm, 9287 bytes, 19 tape blocks
Removing previously used /home/makelot1/.cpan/build/Unix-Syslog-0.99

CPAN.pm: Going to build M/MH/MHARNISCH/Unix-Syslog-0.99.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Unix::Syslog
cp Syslog.pm blib/lib/Unix/Syslog.pm
AutoSplitting blib/lib/Unix/Syslog.pm (blib/lib/auto/Unix/Syslog)
/usr/bin/perl /opt/local/lib/perl5/5.8.0/ExtUtils/xsubpp -typemap /opt/local/lib/perl5/5.8.0/ExtUtils/typemap Syslog.xs > Syslog.xsc && mv Syslog.xsc Syslog.cgcc -c -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-O -DVERSION=\"0.99\" -DXS_VERSION=\"0.99\" -fPIC "-I/opt/local/lib/perl5/5.8.0/sun4-solaris/CORE" Syslog.c
Running Mkbootstrap for Unix::Syslog ()
chmod 644 Syslog.bs
rm -f blib/arch/auto/Unix/Syslog/Syslog.so
LD_RUN_PATH="/usr/lib" gcc -G -L/usr/local/lib -L/opt/local/lib Syslog.o -o blib/arch/auto/Unix/Syslog/Syslog.so -lc
chmod 755 blib/arch/auto/Unix/Syslog/Syslog.so
cp Syslog.bs blib/arch/auto/Unix/Syslog/Syslog.bs
chmod 644 blib/arch/auto/Unix/Syslog/Syslog.bs
Manifying blib/man3/Unix::Syslog.3
/usr/ccs/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
1..
ok 1
Testing priorities:
LOG_EMERG ok 2
LOG_ALERT ok 3
LOG_CRIT ok 4
LOG_ERR ok 5
LOG_WARNING ok 6
LOG_NOTICE ok 7
LOG_INFO ok 8
LOG_DEBUG ok 9

Testing facilities
LOG_KERN ok 10
LOG_USER ok 11
LOG_MAIL ok 12
LOG_DAEMON ok 13
LOG_AUTH ok 14
LOG_SYSLOG ok 15
LOG_LPR ok 16
LOG_NEWS ok 17
LOG_UUCP ok 18
LOG_CRON ok 19
LOG_LOCAL0 ok 20
LOG_LOCAL1 ok 21
LOG_LOCAL2 ok 22
LOG_LOCAL3 ok 23
LOG_LOCAL4 ok 24
LOG_LOCAL5 ok 25
LOG_LOCAL6 ok 26
LOG_LOCAL7 ok 27

These facilities are not defined on all systems:
LOG_AUTHPRIV not ok 28
LOG_FTP not ok 29

The number of available facilities is:
LOG_NFACILITIES ok 30
LOG_FACMASK ok 31

Testing options
LOG_PID ok 32
LOG_CONS ok 33
LOG_ODELAY ok 34
LOG_NDELAY ok 35
LOG_NOWAIT ok 36

These options are not defined on all systems:
LOG_PERROR not ok 37

Testing macros for setlogmask()
LOG_MASK ok 38
LOG_UPTO ok 39

These macros are not defined on all systems:
LOG_PRI not ok 40
LOG_MAKEPRI not ok 41
LOG_FAC not ok 42

On some systems these functions return just empty strings:
priorityname(LOG_EMERG): not defined. skipped 43
priorityname(LOG_ALERT): not defined. skipped 44
priorityname(LOG_CRIT): not defined. skipped 45
priorityname(LOG_ERR): not defined. skipped 46
priorityname(LOG_WARNING): not defined. skipped 47
priorityname(LOG_NOTICE): not defined. skipped 48
priorityname(LOG_INFO): not defined. skipped 49
priorityname(LOG_DEBUG): not defined. skipped 50

facilityname(LOG_KERN): not defined. skipped 51
facilityname(LOG_USER): not defined. skipped 52
facilityname(LOG_MAIL): not defined. skipped 53
facilityname(LOG_DAEMON): not defined. skipped 54
facilityname(LOG_AUTH): not defined. skipped 55
facilityname(LOG_SYSLOG): not defined. skipped 56
facilityname(LOG_LPR): not defined. skipped 57
facilityname(LOG_NEWS): not defined. skipped 58
facilityname(LOG_UUCP): not defined. skipped 59
facilityname(LOG_CRON): not defined. skipped 60
Can't locate auto/Unix/Syslog/LOG_AUTHPRI.al in @INC (@INC contains: blib/lib blib/arch /opt/local/lib/perl5/5.8.0/sun4-solaris /opt/local/lib/perl5/5.8.0 /opt/local/lib/perl5/site_perl/5.8.0/sun4-solaris /opt/local/lib/perl5/site_perl/5.8.0 /opt/local/li
b/perl5/site_perl .) at test.pl line 110
*** Error code 2
make: Fatal error: Command failed for target `test_dynamic'
/usr/ccs/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force

--
/* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */
/* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */
/* Mail: Mechelininkatu 26 B 27, FIN-00100 Helsinki, FINLAND */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */
Otto J. Makela

2005-01-28, 3:57 pm

hume.spamfilter@bofh.halifax.ns.ca wrote:

> I use Unix::Syslog myself, although it doesn't come with Perl.


Tried installing it, but unfortunately initially got version 0.99.

Installing M/MH/MHARNISCH/Unix-Syslog-0.100.tar.gz got me version
0.100 and everything is fine now.
--
/* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */
/* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */
/* Mail: Mechelininkatu 26 B 27, FIN-00100 Helsinki, FINLAND */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */
Karen Wieprecht

2005-01-28, 3:57 pm

> Tried installing it, but unfortunately initially got version 0.99.
>
> Installing M/MH/MHARNISCH/Unix-Syslog-0.100.tar.gz got me version
> 0.100 and everything is fine now.


I believe I got version 0.100 (I'll have to double check). When you had
version 0.99, what was the problem?

1. Was it simply not working? Or

2. Was stuff going into the system log, but with "delays" ?

With the newer version, I assume stuff is coming into the system log now,
but are you getting delays or is it coming in pretty steadily?

Thanks,

Karen Wieprecht


Otto J. Makela

2005-02-04, 8:55 pm

"Karen Wieprecht" <karen.wieprecht@jhuapl.edu> wrote:

>
> I believe I got version 0.100 (I'll have to double check). When you
> had version 0.99, what was the problem?
>
> 1. Was it simply not working? Or
>
> 2. Was stuff going into the system log, but with "delays" ?
>
> With the newer version, I assume stuff is coming into the system log
> now, but are you getting delays or is it coming in pretty steadily?


Version 0.99 did not properly build on Solaris 5.8, but I discovered
that the author had changed and installed the latest version by
specifying the proper version directly, as described above.

Unfortunately, on further testing, seems Unix::Syslog fails rather
mysteriously with "bad file number" and the message being lost:

% cat logtest.pl
#!/usr/bin/perl -w

use strict;
use Unix::Syslog qw(:macros);

$0 =~ s,^.*\/,,o;

sub LOG {
# use Sys::Syslog;
# openlog($0,'pid','mail');
# syslog('info',@_) || die "error in syslog: $!\n";

use Unix::Syslog qw(:subs);
openlog($0,LOG_PID|LOG_NDELAY,LOG_MAIL);

syslog(LOG_INFO,@_) || die "error in syslog: $!\n";
closelog();
}

LOG("mail informational message");

% ./logtest.pl
error in syslog: Bad file number

% tail -1 /var/log/maillog
Feb 4 23:04:30 green logtest.pl[25517]: [ID 702911 mail.info] 1

--
/* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */
/* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */
/* Mail: Mechelininkatu 26 B 27, FIN-00100 Helsinki, FINLAND */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */
Otto J. Makela

2005-02-12, 8:55 pm

om@iki.fi (Otto J. Makela) wrote:

> Unfortunately, on further testing, seems Unix::Syslog fails rather
> mysteriously with "bad file number" and the message being lost:
>
> % cat logtest.pl
> #!/usr/bin/perl -w
>
> use strict;
> use Unix::Syslog qw(:macros);
>
> $0 =~ s,^.*\/,,o;
>
> sub LOG {
> use Unix::Syslog qw(:subs);
> openlog($0,LOG_PID|LOG_NDELAY,LOG_MAIL);

> syslog(LOG_INFO,@_) || die "error in syslog: $!\n";
> closelog();
> }
>
> LOG("mail informational message");


My two goofs:

1) syslog(3c) does not have a return value

2) the perl/c interface does not allow one to omit arguments and expect
them to be obtainable from @_, they need to be given explicitly

Thus, the following code snippet works just fine, and without delays:

sub LOG {
use Unix::Syslog qw(:subs);
my $format=shift;
openlog($0,LOG_PID|LOG_NDELAY,LOG_MAIL);

syslog(LOG_INFO,$format,@_);
closelog();
}
--
/* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */
/* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */
/* Mail: Mechelininkatu 26 B 27, FIN-00100 Helsinki, FINLAND */
/* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com