def main(in_sar_log, output_path): insar = parser.Parser(in_sar_log) sar_viz = viz.Visualization(insar.get_sar_info(), paging=True, network=True, disk=True) sar_viz.save(output_path, output_type=viz.Visualization.PDF_OUTPUT)
def main(): directory = os.path.dirname(os.path.realpath(__file__)) for item in os.listdir(directory): full_path = os.path.join(directory, item) if os.path.isfile(full_path) and item != __file__ and item.endswith('.log'): insar=parser.Parser(full_path) sar_viz=viz.Visualization(insar.get_sar_info(),paging=True,network=True,disk=True) sar_viz.save(full_path+'.pdf')
def main(): from sar import parser sysstat_dir = '/var/log/sa' single_file = ('%s/%s' % (sysstat_dir, 'sar21')) # Single SAR file parsing insar = parser.Parser(single_file) print(("SAR file date: %s" % (insar.get_filedate()))) print("Content:\n") pprint.pprint(insar.get_sar_info()) print(("-" * 78)) # Id you want to test his, please run something like # $ cat /var/log/sa/sar* > sarcombined # to create "combined" SAR file. Then uncomment the following: '''
def load_file(self): ''' Loads combined SAR format logfile in ASCII format. :return: ``True`` if loading and parsing of file went fine, \ ``False`` if it failed (at any point) ''' daychunks = self.__split_file() if (daychunks): maxcount = len(self.__splitpointers) for i in range(maxcount): start = self.__splitpointers[i] end = None if (i < (maxcount - 1)): end = self.__splitpointers[i + 1] chunk = self.__get_chunk(start, end) parser = sarparse.Parser() cpu_usage, mem_usage, swp_usage, io_usage = \ parser._parse_file(parser._split_file(chunk)) self.__sarinfos[self.__get_part_date(chunk)] = { "cpu": cpu_usage, "mem": mem_usage, "swap": swp_usage, "io": io_usage } del (cpu_usage) del (mem_usage) del (swp_usage) del (io_usage) del (parser) return (True)
def main(log_type, in_sar_log, output_path): insar = parser.Parser(in_sar_log) sar_viz = viz.Visualization(insar.get_sar_info(), **{log_type: True}) sar_viz.save(output_path, output_type=viz.Visualization.PDF_OUTPUT)