How to Configure Remote Syslog Logging: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
Line 1: Line 1:
== General Information ==
== General Information ==


'''syslogd''' is the Linux system logging utility that take care of filling up your files in /var/log when it is asked to.
'''syslogd''' is the Linux system logging utility that take manages files in the <tt>/var/log</tt> directory.


On a standard system, logging is only done on the local drive. But syslog can be configured to receive logging from a remote client, or to send logging to a remote syslog server.
On a typical desktop system, logging produced by local application and is saved to files on the local drive. But syslog can also be configured to receive logging from a remote client, or to send logging information to a remote syslog server.


This ''How to'' gives the basic procedure need it for configuring a remote syslog server (in your PC) and client (in your board with our SDK filesystem structure).
This ''How to'' gives the basic procedure for configuring a remote syslog server (e.g. your Ubuntu desktop PC) and a client (e.g. your target hardware running a RidgeRun SDK produced file system).


=== Configuring BusyBox for setting up the syslogd server  ===
=== Configuring host PC syslogd server  ===


The changes on this side are minimal. Basically you have to tell syslogd to listen for remote messages. To enable this you have to go and edit the following file in your host machine:
The changes on this side are minimal. Basically you have to tell syslogd to listen for remote messages. To enable your host computer's syslogd server to accept log data from a remote client, you need to edit the file <tt>/etc/default/syslogd</tt> and set


<pre>
<pre>
host$ sudo <Prefer text editor>/etc/default/syslogd
SYSLOGD="-r"
</pre>
</pre>
Make sure in this file SYSLOGD is set to:
SYSLOGD="-r"


Save the file and restart '''syslogd''' by doing:  
Save the file and restart '''syslogd''' by doing:  


<pre>
<pre>
host$ sudo /etc/init.d/syslogd restart  
sudo /etc/init.d/syslogd restart  
</pre>
</pre>


=== Configuring BusyBox for setting up the syslogd remote feature using our SDK FileSystem structure in the board===
You host syslogd server will now accept remove log messages.


This can be done in two ways.
=== Configuring BusyBox syslogd to send messages to remote logging service ===


1) The first one, it can be done when the board has boot up and Linux is also running up. Our file system initializes a default configuration for '''syslogd''', then for add the remote feature you have to stop this process and configure a new one following this steps:
==== Manual steps to verify functionality ====


<pre>
On your target hardware verify syslogd is not running
target# ps aux | grep syslogd
</pre>
 
If there is a '''syslogd''' process running then kill it.


<pre>
<pre>
Line 41: Line 33:
</pre>
</pre>


Create a new process of '''syslogd''' enabling the remote feature:
Manually start syslogd enabling remote logging


<pre>
<pre>
target#  /sbin/syslogd  -R <serverip>:<port using by UDP (default PORT=514/UDP)>  -L (this save the messages in the server and the client. Optional) -O <PATH where you want to send the log messages>
REMOTE_LOGGING_SERIVCE=10.111.0.3
</pre>
PORT=514


Example:
/sbin/syslogd -R $REMOTE_LOGGING_SERIVCE:$PORT -L -O /var/log/messages          
 
<pre>
target#  /sbin/syslogd -R 10.251.101.60  -L -O /var/log/messages                                          
</pre>
</pre>


==== Automatically starting remote logging ====


2) For the second way to this, the work should be done if you are familiar with our SDK build system and has to be set it before you create the images of the kernel and file system with it. If not just follow the first case, is the easy way to do this.  
You can configure your system to automatically start the remote logging service be editing the file <tt>$DEVDIR/fs/overlay/etc/init.d/syslogd</tt> and adding


Generally we have an script in our file system that initializes '''syslogd''' when the board boot up the kernel and the file system customized by us. For setting up the''' syslogd''' remote edit this file in the host side:
<pre>
REMOTE_LOGGING_SERIVCE=10.111.0.3
PORT=514


<pre>
/sbin/syslogd -R $REMOTE_LOGGING_SERIVCE:$PORT -L -O /var/log/messages         
host$ <Prefer text editor> $(DEVDIR)/fs/overlay/etc/init.d/ syslogd
</pre>
</pre>


As the first way described above, add the following line:
=== Verifying proper operation ====
 
<pre>
/sbin/syslogd  -R <serverip>:<port using by UDP (default PORT=514/UDP)>  -L (this save the messages in the server and the client. Optional) -O <PATH where you want to send the log messages>
</pre>


Save the file and build and install the images create it by our SDK build system.
A simple way to add a log message every few seconds is using the Busybox logger utility.  You man need to reconfigure your SDK to enable the building of the Busybox logger utility.


This will automatically execute the syslogd with the remote feature anytime the board is boot up and the file system loads.


You can check it by doing:
On the target, start a simple script that add a message to the log every two seconds.


<pre>
<pre>
target# ps aux | grep syslogd
( while sleep 2 ; do date ; done | logger -t "DATE:" ) &
</pre>
</pre>


==== Logging on target hardware ====


For checking configuration has successfully done, try the following:
If you used the <tt>-L</tt> option with syslogd on the target hardware, then you can verify local logging is occurring as expected.


<pre>
<pre>
target# while sleep 2 ; do date ; done | logger -t "DATE:"
tail -f /var/log/messages
target# tail -f <PATH (Default:/var/log/messages)>
</pre>
</pre>
==== Logging on host PC  ====


To check the messages are been sent to the server:
To check the messages are been sent to the server:


<pre>
<pre>
host# tail -f <PATH (Default:/var/log/messages)
tail -f /var/log/messages
</pre>
</pre>
=== Debugging ===
If remote logging is not working, use ''wireshark'' to watch the network traffic to verify that the target hardware is sending the msesages to the host computer.

Revision as of 17:42, 3 September 2010

General Information

syslogd is the Linux system logging utility that take manages files in the /var/log directory.

On a typical desktop system, logging produced by local application and is saved to files on the local drive. But syslog can also be configured to receive logging from a remote client, or to send logging information to a remote syslog server.

This How to gives the basic procedure for configuring a remote syslog server (e.g. your Ubuntu desktop PC) and a client (e.g. your target hardware running a RidgeRun SDK produced file system).

Configuring host PC syslogd server

The changes on this side are minimal. Basically you have to tell syslogd to listen for remote messages. To enable your host computer's syslogd server to accept log data from a remote client, you need to edit the file /etc/default/syslogd and set

SYSLOGD="-r" 

Save the file and restart syslogd by doing:

sudo /etc/init.d/syslogd restart 

You host syslogd server will now accept remove log messages.

Configuring BusyBox syslogd to send messages to remote logging service

Manual steps to verify functionality

On your target hardware verify syslogd is not running

target# killall -9 syslogd

Manually start syslogd enabling remote logging

REMOTE_LOGGING_SERIVCE=10.111.0.3
PORT=514

/sbin/syslogd -R $REMOTE_LOGGING_SERIVCE:$PORT -L -O /var/log/messages           

Automatically starting remote logging

You can configure your system to automatically start the remote logging service be editing the file $DEVDIR/fs/overlay/etc/init.d/syslogd and adding

REMOTE_LOGGING_SERIVCE=10.111.0.3
PORT=514

/sbin/syslogd -R $REMOTE_LOGGING_SERIVCE:$PORT -L -O /var/log/messages           

Verifying proper operation =

A simple way to add a log message every few seconds is using the Busybox logger utility. You man need to reconfigure your SDK to enable the building of the Busybox logger utility.


On the target, start a simple script that add a message to the log every two seconds.

( while sleep 2 ; do date ; done | logger -t "DATE:" ) &

Logging on target hardware

If you used the -L option with syslogd on the target hardware, then you can verify local logging is occurring as expected.

tail -f /var/log/messages

Logging on host PC

To check the messages are been sent to the server:

tail -f /var/log/messages

Debugging

If remote logging is not working, use wireshark to watch the network traffic to verify that the target hardware is sending the msesages to the host computer.