Import version 1.8.3
[s390-tools.git] / ziomon / ziorep_utils.hpp
blobea5998779581bdd1b59b370c723fbb51304b8e03
1 /*
2 * FCP report generators
4 * Utility functions
6 * Copyright IBM Corp. 2008
7 * Author(s): Stefan Raspl <raspl@linux.vnet.ibm.com>
8 */
10 #ifndef ZIOREP_UTILS_HPP
11 #define ZIOREP_UTILS_HPP
13 #include "ziorep_framer.hpp"
14 #include "ziorep_cfgreader.hpp"
15 #include "ziorep_printers.hpp"
16 #include "ziorep_collapser.hpp"
18 extern "C" {
19 #include "ziomon_dacc.h"
23 #include <linux/types.h>
25 /**
26 * Parse date provided in 'str' and store as seconds since 1970 in 'tgt'. */
27 int get_datetime_val(const char *str, __u64 *tgt);
30 /**
31 * Print the provided value (seconds since 1970) in our common style. */
32 const char* print_time_formatted(__u64 timestamp);
34 /**
35 * Print the provided value (seconds since 1970) in our common style. */
36 const char* print_time_formatted_short(__u64 timestamp);
38 /**
39 * Adjust the timeframe to appropriate interval boundaries */
40 int adjust_timeframe(const char* filename, __u64 *begin, __u64 *end,
41 __u32 *interval);
44 /**
45 * Add all present devices to the device filter */
46 int add_all_devices(ConfigReader &cfg, DeviceFilter &dev_filt);
49 /**
50 * Utility function to retrieve a list of all devices that we have data for.
51 * Result is put into 'dev_filt'.
53 int get_all_devices(const char *filename, DeviceFilter &dev_filt,
54 ConfigReader &cfg);
56 /**
57 * Run over frames and print each one.
58 * Returns <0 in case of error and number of frames printed otherwise.
60 int print_report(FILE *fp, __u64 begin, __u64 end,
61 __u32 interval,
62 char *filename, __u64 topline,
63 list<MsgTypes> *filter_types,
64 DeviceFilter &dev_filter, Collapser &col,
65 Printer &printer);
67 /**
68 * Print summary of available data.
69 * 'fp' is the file to write all output to, 'filename' the standard
70 * basename.
71 * Returns number of characters printed.
73 int print_summary_report(FILE *fp, char *filename, ConfigReader &cfg);
76 /**
77 * Minor help function to parse a string into a __u64 and check
78 * that it is >= 0 */
79 int parse_topline_arg(char *str, __u64 *arg);
81 FILE* open_csv_output_file(const char *filename, const char *extension,
82 int *rc);
84 #endif