cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:log:test-remote-syslog.html



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



os/linux/log/test-remote-syslog.html.txt · Last modified: 2021/01/22 by admin

Page Tools