Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi, Update inline comment. Best Regards, ThuanTr -Original Message- From: Tran Thuan Sent: Tuesday, January 7, 2020 4:22 PM To: 'phuc.h.chau' ; 'thang.d.ngu...@dektech.com.au' ; 'minh.c...@dektech.com.au' ; 'vu.m.ngu...@dektech.com.au' ; 'gary@dektech.com.au' Cc: 'opensaf-devel@lists.sourceforge.net' Subject: RE: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Hi Phuc, I have minor comments with [Thuan]. Best Regards, ThuanTr -Original Message- From: phuc.h.chau Sent: Tuesday, January 7, 2020 3:11 PM To: thang.d.ngu...@dektech.com.au; minh.c...@dektech.com.au; vu.m.ngu...@dektech.com.au; gary@dektech.com.au Cc: opensaf-devel@lists.sourceforge.net Subject: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. This patch also corrects wrong indentation in osaflog.cc file. --- src/base/log_writer.h | 1 + src/dtm/README | 15 +- src/dtm/tools/osaflog.cc| 44 +++-- src/dtm/transport/log_server.cc | 12 ++- src/dtm/transport/log_server.h | 8 ++-- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/base/log_writer.h b/src/base/log_writer.h index ab2bf32..abd6d47 100644 --- a/src/base/log_writer.h +++ b/src/base/log_writer.h @@ -47,6 +47,7 @@ class LogWriter { void Flush(); void RotateLog(); void SetLogFile(const std::string& log_file) { log_file_ = log_file; } + size_t file_size() const { return current_file_size_; } [Thuan]: should name function as other functions? e.g: GetFileSize() private: constexpr static const size_t kBufferSize = 128 * size_t{1024}; diff --git a/src/dtm/README b/src/dtm/README index 430ff19..ff73af7 100644 --- a/src/dtm/README +++ b/src/dtm/README @@ -190,6 +190,9 @@ Options: --delete Delete the specified LOGSTREAM(s) by removing allocated resources in the log server. Does not delete log files from disk. +--rotate Rotate the specified LOGSTREAM(s). +--all Rotate all LOGSTREAM(s). + This option only works with '--rotate'. --max-file-size=SIZE Set the maximum size of the log file to SIZE bytes. The log file will be rotated when it exceeds this size. Suffixes k, M and @@ -197,4 +200,14 @@ Options: gigabytes. --max-backups=NUM Set the maximum number of backup files to retain during log rotation to NUM. - +--extract-trace + If a process produces a core dump file has + THREAD_TRACE_BUFFER enabled, this option + reads the to extract the trace + strings in all threads and writes them to + the file. +--max-idle=NUMSet the maximum number of idle time to NUM" + minutes. If a stream has not been used for + the given time, the stream will be closed. + Given zero (default) to max-idle to disable + this functionality. diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc index f6fa168..b1fb461 100644 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -93,6 +95,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +108,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:ra", long_options,
Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi Phuc, I have minor comments with [Thuan]. Best Regards, ThuanTr -Original Message- From: phuc.h.chau Sent: Tuesday, January 7, 2020 3:11 PM To: thang.d.ngu...@dektech.com.au; minh.c...@dektech.com.au; vu.m.ngu...@dektech.com.au; gary@dektech.com.au Cc: opensaf-devel@lists.sourceforge.net Subject: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. This patch also corrects wrong indentation in osaflog.cc file. --- src/base/log_writer.h | 1 + src/dtm/README | 15 +- src/dtm/tools/osaflog.cc| 44 +++-- src/dtm/transport/log_server.cc | 12 ++- src/dtm/transport/log_server.h | 8 ++-- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/base/log_writer.h b/src/base/log_writer.h index ab2bf32..abd6d47 100644 --- a/src/base/log_writer.h +++ b/src/base/log_writer.h @@ -47,6 +47,7 @@ class LogWriter { void Flush(); void RotateLog(); void SetLogFile(const std::string& log_file) { log_file_ = log_file; } + size_t file_size() const { return current_file_size_; } [Thuan]: should name function as other functions? e.g: GetFileSize() private: constexpr static const size_t kBufferSize = 128 * size_t{1024}; diff --git a/src/dtm/README b/src/dtm/README index 430ff19..ff73af7 100644 --- a/src/dtm/README +++ b/src/dtm/README @@ -190,6 +190,9 @@ Options: --delete Delete the specified LOGSTREAM(s) by removing allocated resources in the log server. Does not delete log files from disk. +--rotate Rotate the specified LOGSTREAM(s). +--all Rotate all LOGSTREAM(s). + This option only works with '--rotate'. --max-file-size=SIZE Set the maximum size of the log file to SIZE bytes. The log file will be rotated when it exceeds this size. Suffixes k, M and @@ -197,4 +200,14 @@ Options: gigabytes. --max-backups=NUM Set the maximum number of backup files to retain during log rotation to NUM. - +--extract-trace + If a process produces a core dump file has + THREAD_TRACE_BUFFER enabled, this option + reads the to extract the trace + strings in all threads and writes them to + the file. +--max-idle=NUMSet the maximum number of idle time to NUM" + minutes. If a stream has not been used for + the given time, the stream will be closed. + Given zero (default) to max-idle to disable + this functionality. diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc index f6fa168..b1fb461 100644 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -93,6 +95,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +108,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:ra", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +124,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; [Thuan] Can we add check here? rotate_set = false; If (!rotate_set || optind < argc) { PrintUsage(argv[0]);
Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi Phuc, Ack. Thanks, Vu On 1/7/20 3:11 PM, phuc.h.chau wrote: Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. This patch also corrects wrong indentation in osaflog.cc file. --- src/base/log_writer.h | 1 + src/dtm/README | 15 +- src/dtm/tools/osaflog.cc| 44 +++-- src/dtm/transport/log_server.cc | 12 ++- src/dtm/transport/log_server.h | 8 ++-- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/base/log_writer.h b/src/base/log_writer.h index ab2bf32..abd6d47 100644 --- a/src/base/log_writer.h +++ b/src/base/log_writer.h @@ -47,6 +47,7 @@ class LogWriter { void Flush(); void RotateLog(); void SetLogFile(const std::string& log_file) { log_file_ = log_file; } + size_t file_size() const { return current_file_size_; } private: constexpr static const size_t kBufferSize = 128 * size_t{1024}; diff --git a/src/dtm/README b/src/dtm/README index 430ff19..ff73af7 100644 --- a/src/dtm/README +++ b/src/dtm/README @@ -190,6 +190,9 @@ Options: --delete Delete the specified LOGSTREAM(s) by removing allocated resources in the log server. Does not delete log files from disk. +--rotate Rotate the specified LOGSTREAM(s). +--all Rotate all LOGSTREAM(s). + This option only works with '--rotate'. --max-file-size=SIZE Set the maximum size of the log file to SIZE bytes. The log file will be rotated when it exceeds this size. Suffixes k, M and @@ -197,4 +200,14 @@ Options: gigabytes. --max-backups=NUM Set the maximum number of backup files to retain during log rotation to NUM. - +--extract-trace + If a process produces a core dump file has + THREAD_TRACE_BUFFER enabled, this option + reads the to extract the trace + strings in all threads and writes them to + the file. +--max-idle=NUMSet the maximum number of idle time to NUM" + minutes. If a stream has not been used for + the given time, the stream will be closed. + Given zero (default) to max-idle to disable + this functionality. diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc index f6fa168..b1fb461 100644 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -93,6 +95,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +108,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:ra", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +124,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -175,15 +181,15 @@ int main(int argc, char** argv) { pretty_print_set = true; flush_set = true; } - - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { - PrintUsage(argv[0]); - exit(EXIT_FAILURE); - } - + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set
[devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. This patch also corrects wrong indentation in osaflog.cc file. --- src/base/log_writer.h | 1 + src/dtm/README | 15 +- src/dtm/tools/osaflog.cc| 44 +++-- src/dtm/transport/log_server.cc | 12 ++- src/dtm/transport/log_server.h | 8 ++-- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/base/log_writer.h b/src/base/log_writer.h index ab2bf32..abd6d47 100644 --- a/src/base/log_writer.h +++ b/src/base/log_writer.h @@ -47,6 +47,7 @@ class LogWriter { void Flush(); void RotateLog(); void SetLogFile(const std::string& log_file) { log_file_ = log_file; } + size_t file_size() const { return current_file_size_; } private: constexpr static const size_t kBufferSize = 128 * size_t{1024}; diff --git a/src/dtm/README b/src/dtm/README index 430ff19..ff73af7 100644 --- a/src/dtm/README +++ b/src/dtm/README @@ -190,6 +190,9 @@ Options: --delete Delete the specified LOGSTREAM(s) by removing allocated resources in the log server. Does not delete log files from disk. +--rotate Rotate the specified LOGSTREAM(s). +--all Rotate all LOGSTREAM(s). + This option only works with '--rotate'. --max-file-size=SIZE Set the maximum size of the log file to SIZE bytes. The log file will be rotated when it exceeds this size. Suffixes k, M and @@ -197,4 +200,14 @@ Options: gigabytes. --max-backups=NUM Set the maximum number of backup files to retain during log rotation to NUM. - +--extract-trace + If a process produces a core dump file has + THREAD_TRACE_BUFFER enabled, this option + reads the to extract the trace + strings in all threads and writes them to + the file. +--max-idle=NUMSet the maximum number of idle time to NUM" + minutes. If a stream has not been used for + the given time, the stream will be closed. + Given zero (default) to max-idle to disable + this functionality. diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc index f6fa168..b1fb461 100644 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -93,6 +95,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +108,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:ra", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +124,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -175,15 +181,15 @@ int main(int argc, char** argv) { pretty_print_set = true; flush_set = true; } - - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { - PrintUsage(argv[0]); - exit(EXIT_FAILURE); - } - + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { +PrintUsage(argv[0]); +exit(EXIT_FAILURE); + } if (flush_set == true) { - flush_result =
Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi Phuc, Maybe you need updating the Readme file to align with this change too src/dtm/README -Original Message- From: phuc.h.chau Sent: Tuesday, January 7, 2020 11:11 AM To: thang.d.ngu...@dektech.com.au; minh.c...@dektech.com.au; gary@dektech.com.au; vu.m.ngu...@dektech.com.au Cc: opensaf-devel@lists.sourceforge.net; phuc.h.chau Subject: [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. This patch also corrects wrong indentation in osaflog.cc file. --- src/base/log_writer.h | 1 + src/dtm/tools/osaflog.cc| 41 + src/dtm/transport/log_server.cc | 10 ++ src/dtm/transport/log_server.h | 7 ++- 4 files changed, 46 insertions(+), 13 deletions(-) mode change 100644 => 100755 src/base/log_writer.h mode change 100644 => 100755 src/dtm/tools/osaflog.cc mode change 100644 => 100755 src/dtm/transport/log_server.cc mode change 100644 => 100755 src/dtm/transport/log_server.h diff --git a/src/base/log_writer.h b/src/base/log_writer.h old mode 100644 new mode 100755 index ab2bf32..abd6d47 --- a/src/base/log_writer.h +++ b/src/base/log_writer.h @@ -47,6 +47,7 @@ class LogWriter { void Flush(); void RotateLog(); void SetLogFile(const std::string& log_file) { log_file_ = log_file; } + size_t file_size() const { return current_file_size_; } private: constexpr static const size_t kBufferSize = 128 * size_t{1024}; diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc old mode 100644 new mode 100755 index f6fa168..4d00e2b --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -93,6 +95,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +108,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:ra", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +124,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -176,14 +182,16 @@ int main(int argc, char** argv) { flush_set = true; } - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { - PrintUsage(argv[0]); - exit(EXIT_FAILURE); + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { +PrintUsage(argv[0]); +exit(EXIT_FAILURE); } if (flush_set == true) { - flush_result = Flush(); +flush_result = Flush(); } if (pretty_print_set == true) { while (print_result && optind < argc) { @@ -195,20 +203,23 @@ int main(int argc, char** argv) { delete_result = Delete(argv[optind++]); } } - if (rotate_set == true) { -while (rotate_result && optind < argc) { - rotate_result = Rotate(argv[optind++]); -} + if (rotate_all == true) { +rotate_result = RotateAll(); + } else { + while (rotate_result && optind < argc) { +rotate_result = Rotate(argv[optind++]); + } } if (max_backups_set == true) { - number_of_backups_result = NoOfBackupFiles(max_backups); +number_of_backups_result = NoOfBackupFiles(max_backups); } if (max_file_size_set == true) { - max_file_size_result = MaxTraceFileSize(max_file_size); +max_file_size_result = MaxTraceFileSize(max_file_size); } if
[devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. This patch also corrects wrong indentation in osaflog.cc file. --- src/base/log_writer.h | 1 + src/dtm/tools/osaflog.cc| 41 + src/dtm/transport/log_server.cc | 10 ++ src/dtm/transport/log_server.h | 7 ++- 4 files changed, 46 insertions(+), 13 deletions(-) mode change 100644 => 100755 src/base/log_writer.h mode change 100644 => 100755 src/dtm/tools/osaflog.cc mode change 100644 => 100755 src/dtm/transport/log_server.cc mode change 100644 => 100755 src/dtm/transport/log_server.h diff --git a/src/base/log_writer.h b/src/base/log_writer.h old mode 100644 new mode 100755 index ab2bf32..abd6d47 --- a/src/base/log_writer.h +++ b/src/base/log_writer.h @@ -47,6 +47,7 @@ class LogWriter { void Flush(); void RotateLog(); void SetLogFile(const std::string& log_file) { log_file_ = log_file; } + size_t file_size() const { return current_file_size_; } private: constexpr static const size_t kBufferSize = 128 * size_t{1024}; diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc old mode 100644 new mode 100755 index f6fa168..4d00e2b --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -93,6 +95,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +108,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:ra", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +124,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -176,14 +182,16 @@ int main(int argc, char** argv) { flush_set = true; } - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { - PrintUsage(argv[0]); - exit(EXIT_FAILURE); + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { +PrintUsage(argv[0]); +exit(EXIT_FAILURE); } if (flush_set == true) { - flush_result = Flush(); +flush_result = Flush(); } if (pretty_print_set == true) { while (print_result && optind < argc) { @@ -195,20 +203,23 @@ int main(int argc, char** argv) { delete_result = Delete(argv[optind++]); } } - if (rotate_set == true) { -while (rotate_result && optind < argc) { - rotate_result = Rotate(argv[optind++]); -} + if (rotate_all == true) { +rotate_result = RotateAll(); + } else { + while (rotate_result && optind < argc) { +rotate_result = Rotate(argv[optind++]); + } } if (max_backups_set == true) { - number_of_backups_result = NoOfBackupFiles(max_backups); +number_of_backups_result = NoOfBackupFiles(max_backups); } if (max_file_size_set == true) { - max_file_size_result = MaxTraceFileSize(max_file_size); +max_file_size_result = MaxTraceFileSize(max_file_size); } if (max_idle_set == true) { max_idle_result = SetMaxIdleTime(max_idle); } + if (flush_result && print_result && max_file_size_result && rotate_result && delete_result && number_of_backups_result && max_idle_result) exit(EXIT_SUCCESS); @@ -237,6 +248,8 @@ void PrintUsage(const char* program_name) { " removing allocated resources in the log\n" "
Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi Thang & Vu, Thanks for your comments ! I will check and send V2 later. Best Regards, Phuc Chau -Original Message- From: Thang [mailto:thang.d.ngu...@dektech.com.au] Sent: Monday, January 6, 2020 02:46 PM To: 'phuc.h.chau' ; minh.c...@dektech.com.au; gary@dektech.com.au; vu.m.ngu...@dektech.com.au Cc: opensaf-devel@lists.sourceforge.net Subject: RE: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Hi Phuc, See my comment inline. -Original Message- From: phuc.h.chau Sent: Saturday, January 4, 2020 2:53 PM To: minh.c...@dektech.com.au; gary@dektech.com.au; vu.m.ngu...@dektech.com.au Cc: opensaf-devel@lists.sourceforge.net Subject: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. --- src/dtm/tools/osaflog.cc| 37 - src/dtm/transport/log_server.cc | 11 +++ src/dtm/transport/log_server.h | 1 + 3 files changed, 40 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/dtm/tools/osaflog.cc mode change 100644 => 100755 src/dtm/transport/log_server.cc mode change 100644 => 100755 src/dtm/transport/log_server.h diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc old mode 100644 new mode 100755 index f6fa168..0efc989 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -86,6 +88,7 @@ int main(int argc, char** argv) { bool print_result = true; bool delete_result = true; bool rotate_result = true; + bool rotateall_result = true; [Thang]: Maybe no need. Just use existed one, rotate_result bool max_file_size_result = true; bool number_of_backups_result = true; bool max_idle_result = true; @@ -93,6 +96,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +109,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r:a", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +125,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -176,8 +183,10 @@ int main(int argc, char** argv) { flush_set = true; } - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { PrintUsage(argv[0]); exit(EXIT_FAILURE); } @@ -195,10 +204,12 @@ int main(int argc, char** argv) { delete_result = Delete(argv[optind++]); } } - if (rotate_set == true) { -while (rotate_result && optind < argc) { - rotate_result = Rotate(argv[optind++]); -} + if (rotate_all == true && rotate_set == true) { [Thang]: with above check, maybe only need if (rotate_all == true) { + rotateall_result = RotateAll(); + } else { +while (rotate_result && optind < argc) { + rotate_result = Rotate(argv[optind++]); +} } if (max_backups_set == true) { number_of_backups_result = NoOfBackupFiles(max_backups); @@ -209,8 +220,10 @@ int main(int argc, char** argv) { if (max_idle_set == true
Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi Phuc, See my comment inline. -Original Message- From: phuc.h.chau Sent: Saturday, January 4, 2020 2:53 PM To: minh.c...@dektech.com.au; gary@dektech.com.au; vu.m.ngu...@dektech.com.au Cc: opensaf-devel@lists.sourceforge.net Subject: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133] Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. --- src/dtm/tools/osaflog.cc| 37 - src/dtm/transport/log_server.cc | 11 +++ src/dtm/transport/log_server.h | 1 + 3 files changed, 40 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/dtm/tools/osaflog.cc mode change 100644 => 100755 src/dtm/transport/log_server.cc mode change 100644 => 100755 src/dtm/transport/log_server.h diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc old mode 100644 new mode 100755 index f6fa168..0efc989 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -86,6 +88,7 @@ int main(int argc, char** argv) { bool print_result = true; bool delete_result = true; bool rotate_result = true; + bool rotateall_result = true; [Thang]: Maybe no need. Just use existed one, rotate_result bool max_file_size_result = true; bool number_of_backups_result = true; bool max_idle_result = true; @@ -93,6 +96,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +109,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r:a", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +125,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -176,8 +183,10 @@ int main(int argc, char** argv) { flush_set = true; } - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { PrintUsage(argv[0]); exit(EXIT_FAILURE); } @@ -195,10 +204,12 @@ int main(int argc, char** argv) { delete_result = Delete(argv[optind++]); } } - if (rotate_set == true) { -while (rotate_result && optind < argc) { - rotate_result = Rotate(argv[optind++]); -} + if (rotate_all == true && rotate_set == true) { [Thang]: with above check, maybe only need if (rotate_all == true) { + rotateall_result = RotateAll(); + } else { +while (rotate_result && optind < argc) { + rotate_result = Rotate(argv[optind++]); +} } if (max_backups_set == true) { number_of_backups_result = NoOfBackupFiles(max_backups); @@ -209,8 +220,10 @@ int main(int argc, char** argv) { if (max_idle_set == true) { max_idle_result = SetMaxIdleTime(max_idle); } - if (flush_result && print_result && max_file_size_result && rotate_result && - delete_result && number_of_backups_result && max_idle_result) + + if (flush_result && print_result && max_file_size_result && + rotate_result && delete_result && number_of_backups_result && + max_idle_resu
Re: [devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Hi Phuc, See my comments inline. Regards, Vu On 1/4/20 2:53 PM, phuc.h.chau wrote: Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. --- src/dtm/tools/osaflog.cc| 37 - src/dtm/transport/log_server.cc | 11 +++ src/dtm/transport/log_server.h | 1 + 3 files changed, 40 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/dtm/tools/osaflog.cc mode change 100644 => 100755 src/dtm/transport/log_server.cc mode change 100644 => 100755 src/dtm/transport/log_server.h diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc old mode 100644 new mode 100755 index f6fa168..0efc989 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -86,6 +88,7 @@ int main(int argc, char** argv) { bool print_result = true; bool delete_result = true; bool rotate_result = true; + bool rotateall_result = true; bool max_file_size_result = true; bool number_of_backups_result = true; bool max_idle_result = true; @@ -93,6 +96,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +109,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r:a", [Vu] optstring should be 'm:b:p:f:e:i:ra' as 'rotate' option requires no argument. long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +125,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -176,8 +183,10 @@ int main(int argc, char** argv) { flush_set = true; } - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { PrintUsage(argv[0]); exit(EXIT_FAILURE); } @@ -195,10 +204,12 @@ int main(int argc, char** argv) { delete_result = Delete(argv[optind++]); } } - if (rotate_set == true) { -while (rotate_result && optind < argc) { - rotate_result = Rotate(argv[optind++]); -} + if (rotate_all == true && rotate_set == true) { + rotateall_result = RotateAll(); + } else { +while (rotate_result && optind < argc) { + rotate_result = Rotate(argv[optind++]); +} } [Vu] Wrong indentation. Each level should have 02 spaces. if (max_backups_set == true) { number_of_backups_result = NoOfBackupFiles(max_backups); @@ -209,8 +220,10 @@ int main(int argc, char** argv) { if (max_idle_set == true) { max_idle_result = SetMaxIdleTime(max_idle); } - if (flush_result && print_result && max_file_size_result && rotate_result && - delete_result && number_of_backups_result && max_idle_result) + + if (flush_result && print_result && max_file_size_result && + rotate_result && delete_result && number_of_backups_result && + max_idle_result && rotateall_result) exit(EXIT_SUCCESS); exit(EXIT_FAILURE); } @@ -237,6 +250,8 @@ void PrintUsage(const char* program_name) { " removing allocated resources in the log\n" " server. Does not delete log files from disk.\n" "--rotate Rotate the specified LOGSTREAM(s).\n" + "--all Rotate all existing LOGSTREAM(s)\n" +
[devel] [PATCH 1/1] dtm: rotate all logtraces on demand [#3133]
Adding a new option '--all' that means to rotate all existing logtrace if given along with the '--rotate' option. --- src/dtm/tools/osaflog.cc| 37 - src/dtm/transport/log_server.cc | 11 +++ src/dtm/transport/log_server.h | 1 + 3 files changed, 40 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/dtm/tools/osaflog.cc mode change 100644 => 100755 src/dtm/transport/log_server.cc mode change 100644 => 100755 src/dtm/transport/log_server.h diff --git a/src/dtm/tools/osaflog.cc b/src/dtm/tools/osaflog.cc old mode 100644 new mode 100755 index f6fa168..0efc989 --- a/src/dtm/tools/osaflog.cc +++ b/src/dtm/tools/osaflog.cc @@ -55,6 +55,7 @@ uint64_t Random64Bits(uint64_t seed); bool PrettyPrint(const std::string& log_stream); bool Delete(const std::string& log_stream); bool Rotate(const std::string& log_stream); +bool RotateAll(); std::list OpenLogFiles(const std::string& log_stream); std::string PathName(const std::string& log_stream, int suffix); uint64_t GetInode(int fd); @@ -72,6 +73,7 @@ int main(int argc, char** argv) { {"print", no_argument, nullptr, 'p'}, {"delete", no_argument, nullptr, 'd'}, {"rotate", no_argument, nullptr, 'r'}, + {"all", no_argument, nullptr, 'a'}, {"extract-trace", required_argument, 0, 'e'}, {"max-idle", required_argument, 0, 'i'}, {0, 0, 0, 0}}; @@ -86,6 +88,7 @@ int main(int argc, char** argv) { bool print_result = true; bool delete_result = true; bool rotate_result = true; + bool rotateall_result = true; bool max_file_size_result = true; bool number_of_backups_result = true; bool max_idle_result = true; @@ -93,6 +96,7 @@ int main(int argc, char** argv) { bool pretty_print_set = false; bool delete_set = false; bool rotate_set = false; + bool rotate_all = false; bool max_file_size_set = false; bool max_backups_set = false; bool max_idle_set = false; @@ -105,7 +109,7 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } - while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r", + while ((option = getopt_long(argc, argv, "m:b:p:f:e:i:r:a", long_options, _index)) != -1) { switch (option) { case 'p': @@ -121,6 +125,9 @@ int main(int argc, char** argv) { case 'r': rotate_set = true; break; + case 'a': +rotate_all = true; +break; case 'm': max_file_size = base::StrToUint64(optarg, _file_size_set); @@ -176,8 +183,10 @@ int main(int argc, char** argv) { flush_set = true; } - if ((argc <= optind && (pretty_print_set || delete_set || rotate_set)) || - (pretty_print_set && delete_set)) { + if ((argc <= optind && (pretty_print_set || delete_set)) || + (pretty_print_set && delete_set) || + (rotate_all && !rotate_set) || + (argc == optind && rotate_set && !rotate_all)) { PrintUsage(argv[0]); exit(EXIT_FAILURE); } @@ -195,10 +204,12 @@ int main(int argc, char** argv) { delete_result = Delete(argv[optind++]); } } - if (rotate_set == true) { -while (rotate_result && optind < argc) { - rotate_result = Rotate(argv[optind++]); -} + if (rotate_all == true && rotate_set == true) { + rotateall_result = RotateAll(); + } else { +while (rotate_result && optind < argc) { + rotate_result = Rotate(argv[optind++]); +} } if (max_backups_set == true) { number_of_backups_result = NoOfBackupFiles(max_backups); @@ -209,8 +220,10 @@ int main(int argc, char** argv) { if (max_idle_set == true) { max_idle_result = SetMaxIdleTime(max_idle); } - if (flush_result && print_result && max_file_size_result && rotate_result && - delete_result && number_of_backups_result && max_idle_result) + + if (flush_result && print_result && max_file_size_result && + rotate_result && delete_result && number_of_backups_result && + max_idle_result && rotateall_result) exit(EXIT_SUCCESS); exit(EXIT_FAILURE); } @@ -237,6 +250,8 @@ void PrintUsage(const char* program_name) { " removing allocated resources in the log\n" " server. Does not delete log files from disk.\n" "--rotate Rotate the specified LOGSTREAM(s).\n" + "--all Rotate all existing LOGSTREAM(s)\n" + " if given along with the '--rotate' option.\n" "--max-file-size=SIZE Set the maximum size of the log file to\n" " SIZE bytes. The log file will be rotated\n" " when it exceeds this size. Suffixes