'from': '',
'subject': 'logparse from $hostname$'
},
+ 'rotate': 1,
'hddtemp': {
'drives': ['/dev/sda'],
'port': 7634
to = parser.parse_args().to
def __main__():
- logger.info("Beginning log analysis at " + str(timenow))
+ logger.info("Beginning log analysis at " + str(datenow) + ' ' + str(timenow))
if (to == None):
logger.info("no recipient address provided, outputting to stdout")
else:
try:
__main__()
finally:
- subprocess.call("/usr/sbin/logrotate -f /etc/logrotate.conf", shell=True)
- logger.info("rotated logfiles")
+ # rotate logs using systemd logrotate
+ if (config['rotate'] == 1):
+ subprocess.call("/usr/sbin/logrotate -f /etc/logrotate.conf", shell=True)
+ logger.info("rotated logfiles")
+ else:
+ logger.info("user doesn't want to rotate logs")
+ logger.debug("Here is the output of `logrotate -d /etc/logrotate.conf` (simulated):")
+ sim = subprocess.check_output("/usr/sbin/logrotate -d /etc/logrotate.conf", shell=True)
+ logger.debug(sim)
+ timenow = time.strftime("%H:%M:%S")
+ datenow = time.strftime("%x")
+ logger.info("finished parsing logs at " + str(datenow) + ' ' + str(timenow))