LogrotateConf - files /etc/logrotate.conf
and others¶
Class to parse logrotate confuration files:
- /etc/logrotate.conf
- /etc/logrotate.d/*
- class insights.parsers.logrotate_conf.LogRotateConfPEG(context)[source]¶
Bases:
ConfigParser
Sample logrotate configuration file:
# sample file compress /var/log/messages { rotate 5 weekly postrotate /sbin/killall -HUP syslogd endscript } "/var/log/httpd/access.log" /var/log/httpd/error.log { rotate 5 mail www@my.org size=100k sharedscripts postrotate /sbin/killall -HUP httpd endscript } /var/log/news/news.crit /var/log/news/olds.crit { monthly rotate 2 olddir /var/log/news/old missingok postrotate kill -HUP `cat /var/run/inn.pid` endscript nocompress }
Examples
>>> type(log_rt_peg) <class 'insights.parsers.logrotate_conf.LogRotateConfPEG'> >>> 'compress' in log_rt_peg True >>> 'weekly' in log_rt['/var/log/messages'] True >>> log_rt_peg['/var/log/messages']['postrotate'][-1].value '/sbin/killall -HUP syslogd'
- class insights.parsers.logrotate_conf.LogrotateConf(context)[source]¶
Bases:
Parser
,LegacyItemAccess
Class for parsing
/etc/logrotate.conf
and/etc/logrotate.d/*
configuration files.Sample logrotate configuration file:
# sample file compress /var/log/messages { rotate 5 weekly postrotate /sbin/killall -HUP syslogd endscript } "/var/log/httpd/access.log" /var/log/httpd/error.log { rotate 5 mail www@my.org size=100k sharedscripts postrotate /sbin/killall -HUP httpd endscript } /var/log/news/news.crit /var/log/news/olds.crit { monthly rotate 2 olddir /var/log/news/old missingok postrotate kill -HUP `cat /var/run/inn.pid` endscript nocompress }
Examples
>>> type(log_rt) <class 'insights.parsers.logrotate_conf.LogrotateConf'> >>> log_rt.options ['compress'] >>> log_rt.log_files ['/var/log/messages', '/var/log/httpd/access.log', '/var/log/httpd/error.log', '/var/log/news/news.crit', '/var/log/news/olds.crit'] >>> log_rt['compress'] True >>> 'weekly' in log_rt['/var/log/messages'] True >>> log_rt['/var/log/messages']['postrotate'] ['/sbin/killall -HUP syslogd']
- data¶
All parsed options and log files are stored in this dictionary
- Type:
dict
- options¶
List of global options in the configuration file
- Type:
list
- log_files¶
List of log files in the configuration file
- Type:
list