Table of Contents

Linux

How to test remote syslog in linux



Perl Script

Execute

$ ./send_syslog.pl syslog_server "test message"

$ ./send_syslog.pl xx.xx.xx.xx "test message"

Script

#!/usr/bin/perl
use strict;
use warnings;
use Sys::Syslog qw(:DEFAULT setlogsock);

my $ident    = "test";
my $logopt   = "pid";
my $facility = "local0";
my $priority = "info";

my ($sv, $msg) = @ARGV;

setlogsock("udp");
$Sys::Syslog::host = $sv;

openlog($ident, $logopt, $facility);
syslog($priority, $msg);
closelog();
References