MCPcopy Create free account
hub / github.com/jipegit/OSXAuditor / AggregateLogs

Function AggregateLogs

osxauditor.py:875–897  ·  view source on GitHub ↗

Walk in the different log directories to add all logs to a zipball

(ZipLogsFile)

Source from the content-addressed store, hash-verified

873 PrintAndLog(LogDirPath.decode('utf-8') + u' is empty', 'INFO')
874
875def AggregateLogs(ZipLogsFile):
876 ''' Walk in the different log directories to add all logs to a zipball '''
877
878 PrintAndLog(u'Log files aggregation', 'SECTION')
879
880 if not os.path.isdir(ZipLogsFile):
881 os.makedirs(ZipLogsFile)
882
883 ZipLogsFilePath = os.path.join(ZipLogsFile, 'OSXAuditor_report_' + HOSTNAME + '_' + time.strftime('%Y%m%d-%H%M%S', time.gmtime()) + '.zip')
884 PrintAndLog(u'All log files are aggregated in ' + ZipLogsFilePath.decode('utf-8'), 'DEBUG')
885
886 try:
887 with zipfile.ZipFile(ZipLogsFilePath, 'w') as ZipLogsFile:
888 PrintAndLog(os.path.join(ROOT_PATH, 'var/log').decode('utf-8') + u' files aggregation', 'SUBSECTION')
889 AggregateLogsDir(ZipLogsFile, os.path.join(ROOT_PATH, 'var/log'))
890 PrintAndLog(os.path.join(ROOT_PATH, 'Library/logs').decode('utf-8') + u' files aggregation', 'SUBSECTION')
891 AggregateLogsDir(ZipLogsFile, os.path.join(ROOT_PATH, 'Library/logs'))
892 for User in os.listdir(os.path.join(ROOT_PATH, 'Users')):
893 if User[0] != '.':
894 PrintAndLog(os.path.join(ROOT_PATH, 'Users', User, 'Library/logs').decode('utf-8') + u' files aggregation', 'SUBSECTION')
895 AggregateLogsDir(ZipLogsFile, os.path.join(ROOT_PATH, 'Users', User, 'Library/logs'))
896 except Exception as e:
897 PrintAndLog(u'Log files aggregation FAILED ' + str(e.args).decode('utf-8'), 'ERROR')
898
899def GeomenaApiLocation(Ssid):
900 ''' Perform a geolocation query on Geomena'''

Callers 1

MainFunction · 0.85

Calls 2

PrintAndLogFunction · 0.85
AggregateLogsDirFunction · 0.85

Tested by

no test coverage detected