Logrotate in Yate

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Created page with " The file “yate.logrotate” is a configuration file that uses the same options and directives as UNIX's logrotate. Just type “man logrotate” in the command line to con...")
 
(How does it work?: explanation of config file as a table)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
[https://fedorahosted.org/logrotate/ logrotate] is a UNIX program that eases the management of log files by automatically compressing, rotating, removing and emailing the logs as specified in the configuration. It runs as a daily cron job. Yate doesn't rotate its own logs, but integrates into "logrotate" by providing a configuration file for it.
  
 +
===logrotate and Yate===
  
The file “yate.logrotate” is a configuration file that uses the same options and directives as UNIX's logrotate.
+
If you decide that you want to take a look, you can find the logrotate configuration as "yate.logrotate" in the packing/ subdirectory in the Yate source. When you install Yate as a service, this file will be installed as /etc/logrotate.d/yate/, along with the configuration files for all the other services and programs installed on your system.
Just type “man logrotate” in the command line to convince yourself. If you decide that you want to take a look, you can find yate.logrotate in the packing/ subdirectory of Yate. When you install Yate as a service, the configuration file will be installed as /etc/logrotate.d/yate, along with the configuration files for all the other services and programs installed on your system.
+
 
+
===Why use logrotate?===
+
 
+
Logrotate is an application that runs as a daily cron job. It eases the management of system logs. You can compress, rotate,remove and email file logs of your system as well as for other processes.
+
  
 +
Type “<code>man logrotate</code>” in the command line for an explanation of logrotate options and configuration file syntax. 
  
 
===Prepare logs rotation===
 
===Prepare logs rotation===
Line 22: Line 20:
 
===How does it work?===
 
===How does it work?===
  
The logrotate configuration file, etc/logrotate.conf, besides the usual options and directives, includes other configuration files found in /etc/logrotate.d. Various packages will install their own configuration file that ensures their logs are properly rotated. This also applies for yate.logrotate, which will rotate yate's log file.
+
The logrotate configuration file, /etc/logrotate.conf, besides the usual options and directives, includes other configuration files found in /etc/logrotate.d/. Various packages will install their own configuration file that ensures their logs are properly rotated. This also applies for yate.logrotate, which will rotate yate's log file.
  
 
Below you can see the content of the configuration file:
 
Below you can see the content of the configuration file:
Line 34: Line 32:
 
     rotate 5
 
     rotate 5
 
     missingok
 
     missingok
 +
    sharedscripts
 
     notifempty
 
     notifempty
 
     postrotate
 
     postrotate
Line 40: Line 39:
 
  }
 
  }
  
File yate.logrotate handles the file yate and yate-cdr.tsv by rotating it each time its' size reaches 100 M.
+
According to this configuration file, logrotate handles the files yate and yate-cdr.tsv by rotating them each time their size reach 100 M.<br>
Each day cron will start the logrotate configuration files for each installed program and service.
+
{|class="wikitable"
Each day, yate.logrotate will compare the size of /var/log/yate with 100 M. If its' size is 100 M or bigger, the log file will be rotated.
+
! Directive
The number of rotations is 5.
+
! Meaning
After a running period of time, yate.logrotate will start overwriting the rotated files. This measure is meant to prevent Yate's crush due to reaching of /var/log/yate to 2 GB in size.  
+
|-
You won't receive an error message if the log file is missing but the file will not be rotated if it is empty.
+
| <tt>size=100M</tt>
The command “kill -HUP” sends a SIGHUP signal to Yate's supervisor each time yate.logrotate has finished rotating the log file.
+
| Each day, logrotate will compare the size of /var/log/yate with 100 M. If its size is 100 M or bigger, the log file will be rotated.
 +
|-
 +
| <tt>rotate 5</tt>
 +
| The number of rotations is 5, i.e. 5 generations of rotated log files will be kept. After this number is reached, logrotate will start overwriting the rotated files. This measure is meant to prevent Yate's crash due to /var/log/yate reaching a file size of 2 GB.
 +
|-
 +
| <tt>missingok</tt>
 +
| You won't receive an error message if the log file is missing.
 +
|-
 +
| <tt>sharedscripts</tt>
 +
| This tells logrotate to run the <tt>postrotate</tt> script only once for all the files in the section
 +
|-
 +
| <tt>notifempty</tt>
 +
| A file will not be rotated if it is empty. This avoids replacing an already rotated file with a 0-byte file.
 +
|-
 +
| <tt>postrotate</tt>&nbsp;&hellip;&nbsp;<tt>endscript</tt>
 +
| After rotation the log files have to be re-opened by Yate to avoid writing into a deleted log file. To accomplish this, the shell command “kill -HUP” sends a [[wikipedia:Unix signal#SIGHUP|SIGHUP signal]] to Yate's supervisor each time yate.logrotate has finished rotating the log file.
 +
|}
 +
 
 +
===Prepare the init script===
 +
 
 +
You need to copy and rename the proper '''yate.init''' from a subdirectory of packing/ to '''/etc/init.d''' where all service start scripts are installed. Note that the script and additional tools depend on the Linux distribution used so take the correct one.
 +
 
 +
This operation needs that you run as root:
 +
 +
cp packing/rpm/yate.init /etc/init.d/yate
 +
chown root.root /etc/init.d/yate
 +
 
 +
Replace ''rpm'' with what matches best your distribution's package manager.
 +
 
 +
You will then need to edit the init file and change the path to the executable from '''/usr/bin''' to '''/usr/local/bin'''
 +
 
 +
You may also alter the [[Starting Yate|command line options]] to get more debugging. Is is recommended to enable timestamping the log messages.
  
 
===How to use it?===
 
===How to use it?===
  
To use yate.logrotate, you must enable the rotate option when you start Yate as a service. The -r option requires enabling the supervised mode and naming a log file. So run Yate including -s -r -l to the command “yate”. When running yate as a service with rotation enabled, you will find the log files in /var/log/yate. Otherwise, the log files are found in the build directory. For more information related to Yate's start command, type yate --help.
+
To use yate.logrotate, you must enable the rotate option when you start Yate as a service. <br>
 +
The -r option requires enabling the supervised mode and naming a log file. So run Yate including -s -r -l to the command “yate”.<br>
 +
When running yate as a service with rotation enabled, you will find the log files in /var/log/yate. Otherwise, the log files are found in the build directory. For more information related to Yate's start command, type yate --help.<br>
  
  
 
'''See also'''
 
'''See also'''
  
*
+
* [[Starting Yate]]
 +
 
 +
[[Category:Administrate]] [[Category:Log rotation]]

Latest revision as of 00:57, 13 March 2014

logrotate is a UNIX program that eases the management of log files by automatically compressing, rotating, removing and emailing the logs as specified in the configuration. It runs as a daily cron job. Yate doesn't rotate its own logs, but integrates into "logrotate" by providing a configuration file for it.

Contents

[edit] logrotate and Yate

If you decide that you want to take a look, you can find the logrotate configuration as "yate.logrotate" in the packing/ subdirectory in the Yate source. When you install Yate as a service, this file will be installed as /etc/logrotate.d/yate/, along with the configuration files for all the other services and programs installed on your system.

Type “man logrotate” in the command line for an explanation of logrotate options and configuration file syntax.

[edit] Prepare logs rotation

Copy packing/yate.logrotate as /etc/logrotate.d/yate and optionally edit it to adjust the limits. Note that logrotate normally runs daily so make sure you collect signifficantly less than 2GB of logs in 24 hours.

You will also need to make the file owned by root:

cp packing/yate.logrotate /etc/logrotate.d/yate
chown root.root /etc/logrotate.d/yate

If your logs grow too fast you have to either reduce the logging level - eventually per module - or set up logrotate to run more often. For example you can move the logrotate script from /etc/cron.daily to /etc/cron.hourly

[edit] How does it work?

The logrotate configuration file, /etc/logrotate.conf, besides the usual options and directives, includes other configuration files found in /etc/logrotate.d/. Various packages will install their own configuration file that ensures their logs are properly rotated. This also applies for yate.logrotate, which will rotate yate's log file.

Below you can see the content of the configuration file:

Content of /etc/logrotate.d/yate

# Have to rotate the log and CDR files before each reaches 2GB in size

/var/log/yate /var/log/yate-cdr.tsv {
    size=100M
    rotate 5
    missingok
    sharedscripts
    notifempty
    postrotate
    /bin/kill -HUP `/bin/cat /var/run/yate.pid`
    endscript
}

According to this configuration file, logrotate handles the files yate and yate-cdr.tsv by rotating them each time their size reach 100 M.

Directive Meaning
size=100M Each day, logrotate will compare the size of /var/log/yate with 100 M. If its size is 100 M or bigger, the log file will be rotated.
rotate 5 The number of rotations is 5, i.e. 5 generations of rotated log files will be kept. After this number is reached, logrotate will start overwriting the rotated files. This measure is meant to prevent Yate's crash due to /var/log/yate reaching a file size of 2 GB.
missingok You won't receive an error message if the log file is missing.
sharedscripts This tells logrotate to run the postrotate script only once for all the files in the section
notifempty A file will not be rotated if it is empty. This avoids replacing an already rotated file with a 0-byte file.
postrotate … endscript After rotation the log files have to be re-opened by Yate to avoid writing into a deleted log file. To accomplish this, the shell command “kill -HUP” sends a SIGHUP signal to Yate's supervisor each time yate.logrotate has finished rotating the log file.

[edit] Prepare the init script

You need to copy and rename the proper yate.init from a subdirectory of packing/ to /etc/init.d where all service start scripts are installed. Note that the script and additional tools depend on the Linux distribution used so take the correct one.

This operation needs that you run as root:

cp packing/rpm/yate.init /etc/init.d/yate
chown root.root /etc/init.d/yate

Replace rpm with what matches best your distribution's package manager.

You will then need to edit the init file and change the path to the executable from /usr/bin to /usr/local/bin

You may also alter the command line options to get more debugging. Is is recommended to enable timestamping the log messages.

[edit] How to use it?

To use yate.logrotate, you must enable the rotate option when you start Yate as a service.
The -r option requires enabling the supervised mode and naming a log file. So run Yate including -s -r -l to the command “yate”.
When running yate as a service with rotation enabled, you will find the log files in /var/log/yate. Otherwise, the log files are found in the build directory. For more information related to Yate's start command, type yate --help.


See also

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers