dump_systemstate: Move most of the runnable programs to configuration files 76/226276/11
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 28 Feb 2020 13:50:25 +0000 (14:50 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 9 Mar 2020 15:56:49 +0000 (16:56 +0100)
Change-Id: I2b68d40de0f4309cc3a25dd6b2786bf5e0ff0902

packaging/crash-worker.spec
src/dump_systemstate/CMakeLists.txt
src/dump_systemstate/dump_systemstate.c
src/dump_systemstate/files.conf.example [deleted file]
src/dump_systemstate/files/crash-worker-files.conf [moved from src/dump_systemstate/files/10-crash-worker.conf with 84% similarity]
src/dump_systemstate/files/files.conf.example [new file with mode: 0644]
src/dump_systemstate/programs/10-crash-worker.conf [deleted file]
src/dump_systemstate/programs/crash-worker-programs.conf [new file with mode: 0644]
src/dump_systemstate/programs/programs.conf.example [moved from src/dump_systemstate/programs.conf.example with 79% similarity]
tests/system/log_file/log_file.sh.template

index 9aaf71a..a58bc51 100644 (file)
@@ -181,10 +181,8 @@ mkdir -p %{buildroot}%{crash_temp}
 %attr(-,root,root) %{_prefix}/lib/sysctl.d/70-crash-manager.conf
 %attr(0750,crash_worker,crash_worker) %{_bindir}/crash-manager
 %attr(0750,crash_worker,crash_worker) %{_bindir}/dump_systemstate
-%{_sysconfdir}/dump_systemstate.conf.d/files/files.conf.example
-%{_sysconfdir}/dump_systemstate.conf.d/files/10-crash-worker.conf
-%{_sysconfdir}/dump_systemstate.conf.d/programs/programs.conf.example
-%{_sysconfdir}/dump_systemstate.conf.d/programs/10-crash-worker.conf
+%{_sysconfdir}/dump_systemstate.conf.d/files/*.conf*
+%{_sysconfdir}/dump_systemstate.conf.d/programs/*.conf*
 %{_libexecdir}/crash-stack
 %{_libexecdir}/crash-popup-launch
 %{_libexecdir}/crash-notify-send
index d659aa4..aadbe1f 100644 (file)
@@ -31,15 +31,10 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${dump_systemstate_pkgs_LDFLAGS} -pie)
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin
                PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
                GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}/files.conf.example
-                          DESTINATION ${DUMP_SYSTEMSTATE_CONFIG_DIR_PATH}/files
-                          PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}/files/10-crash-worker.conf
-                          DESTINATION ${DUMP_SYSTEMSTATE_CONFIG_DIR_PATH}/files
-                          PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}/programs.conf.example
-                          DESTINATION ${DUMP_SYSTEMSTATE_CONFIG_DIR_PATH}/programs
-                          PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/${PROJECT_NAME}/programs/10-crash-worker.conf
-                          DESTINATION ${DUMP_SYSTEMSTATE_CONFIG_DIR_PATH}/programs
-                          PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(DIRECTORY files DESTINATION ${DUMP_SYSTEMSTATE_CONFIG_DIR_PATH}
+        PATTERN "files/*.conf*"
+        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(DIRECTORY programs DESTINATION ${DUMP_SYSTEMSTATE_CONFIG_DIR_PATH}
+        PATTERN "programs/*.conf*"
+        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
index e3824d5..9688bd9 100644 (file)
@@ -94,12 +94,7 @@ int main(int argc, char *argv[])
        int c, ret, i, dpercent, exit_code = 0;
        const char *arg_file = NULL;
        int out_fd = -1;
-       bool arg_buxton = false;
-       bool arg_dlog = false;
-       bool arg_dmesg = false;
        bool arg_extras = true;
-       bool arg_journal = false;
-       bool arg_pkgs = false;
        char timestr[80];
        time_t cur_time;
        struct tm gm_tm;
@@ -111,14 +106,12 @@ int main(int argc, char *argv[])
 
        while ((c = getopt_long(argc, argv, "hf:kdbjeEp", long_options, NULL)) != -1) {
                switch (c) {
-               case 'b':
-                       arg_buxton = true;
-                       break;
-               case 'd':
-                       arg_dlog = true;
-                       break;
-               case 'k':
-                       arg_dmesg = true;
+               case 'b': /* buxton */
+               case 'd': /* dlog */
+               case 'k': /* dmesg */
+               case 'j': /* journal */
+               case 'p': /* pkgs */
+                         // Above flags are handled through extra config files
                        break;
                case 'e': // This flag is here for backward compatibility
                        arg_extras = true;
@@ -126,12 +119,6 @@ int main(int argc, char *argv[])
                case 'E':
                        arg_extras = false;
                        break;
-               case 'j':
-                       arg_journal = true;
-                       break;
-               case 'p':
-                       arg_pkgs = true;
-                       break;
                case 'f':
                        arg_file = optarg;
                        break;
@@ -207,57 +194,6 @@ int main(int argc, char *argv[])
                spawn_wait_checked(du_args, NULL);
        }
 
-       fprintf_fd(out_fd, "\n==== System timezone (ls -al /opt/etc/localtime)\n");
-       char *ls_args[] = {"/bin/ls", "-al", "/opt/etc/localtime", NULL};
-       spawn_wait_checked(ls_args, NULL);
-
-       fprintf_fd(out_fd, "\n==== System summary (/usr/bin/top -bcH -n 1)\n");
-       char *top_args[] = {"/bin/top", "-bcH", "-n", "1", NULL};
-       char *top_env[] = {"COLUMNS=200", NULL};
-       spawn_wait_checked(top_args, top_env);
-
-       fprintf_fd(out_fd, "\n==== Current processes (/bin/ps auxfw)\n");
-       char *ps_args[] = {"/bin/ps", "auxfw", NULL};
-       spawn_wait_checked(ps_args, NULL);
-
-       fprintf_fd(out_fd, "\n==== System memory statistics (/usr/bin/memps -v)\n");
-       char *memps_args[] = {"/bin/memps", "-v", NULL};
-       spawn_wait_checked(memps_args, NULL);
-
-       if (arg_buxton) {
-               fprintf_fd(out_fd, "\n==== System configuration (/usr/bin/buxton2ctl dump memory, system)\n");
-               char *get_mem_args[] = {"/bin/buxton2ctl", "dump", "memory",  NULL};
-               spawn_wait_checked(get_mem_args, NULL);
-
-               char *get_sys_args[] = {"/bin/buxton2ctl", "dump", "system",  NULL};
-               spawn_wait_checked(get_sys_args, NULL);
-       }
-
-       if (arg_pkgs) {
-               fprintf_fd(out_fd, "\n==== Installed packages (/usr/bin/pkgcmd -l)\n");
-               char *pkgcmd_args[] = {"/usr/bin/pkgcmd", "-l", "--global", NULL};  // see TODO file
-               spawn_wait_checked(pkgcmd_args, NULL);
-       }
-
-       if (arg_dmesg) {
-               fprintf_fd(out_fd, "\n==== Kernel messages (TZ=UTC /bin/dmesg -T)\n");
-               char *dmesg_args[] = {"/bin/dmesg", "-T", NULL};
-               char *dmesg_env[] = {"TZ=UTC", NULL};
-               spawn_wait_checked(dmesg_args, dmesg_env);
-       }
-
-       if (arg_dlog) {
-               fprintf_fd(out_fd, "\n==== Log messages\n");
-               char *dlogutil_args[] = {"/bin/dlogutil", "-d", "-v", "threadtime", "-u", "16384", NULL};
-               spawn_wait_checked(dlogutil_args, NULL);
-       }
-
-       if (arg_journal) {
-               fprintf_fd(out_fd, "\n==== Journal messages\n");
-               char *journalctl_args[] = {"/bin/journalctl", "-b", "-n", "1024", NULL};
-               spawn_wait_checked(journalctl_args, NULL);
-       }
-
        if (arg_extras)
                exit_code |= handle_extra_dir(out_fd, DUMP_SYSTEMSTATE_CONFIG_DIR_PROGRAMS_PATH, handle_extra_program, argc, argv);
 
diff --git a/src/dump_systemstate/files.conf.example b/src/dump_systemstate/files.conf.example
deleted file mode 100644 (file)
index e8c73c2..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# Please consider prefixing config names with numbers (NN-) if you need order
-# to be preserved.
-#
-# Crash-worker reserves number 00-19 for its purpose. Please add files
-# with number > 20.
-
-[UNIQUE_ID_KEY]
-title=header line that gets printed (path gets appended too)
-path=/path/to/the/file
-
-[DLOG_CONF]
-title=dlog configuration file
-path=/opt/etc/dlog.conf
-
@@ -1,7 +1,9 @@
 [VMSTAT]
+order=100
 title=Virtual Memory statistics
 path=/proc/vmstat
 
 [KERNEL_LOCKS]
+order=110
 title=Kernel lock
 path=/proc/locks
diff --git a/src/dump_systemstate/files/files.conf.example b/src/dump_systemstate/files/files.conf.example
new file mode 100644 (file)
index 0000000..a47de41
--- /dev/null
@@ -0,0 +1,11 @@
+# Please use order=NUMBER directive to have entries printed in (increasing)
+# order.  Entries with the same order value are also printed in random order.
+
+[UNIQUE_ID_KEY]
+title=header line that gets printed (path gets appended too)
+path=/path/to/the/file
+
+[DLOG_CONF]
+title=dlog configuration file
+path=/opt/etc/dlog.conf
+
diff --git a/src/dump_systemstate/programs/10-crash-worker.conf b/src/dump_systemstate/programs/10-crash-worker.conf
deleted file mode 100644 (file)
index 67c5f58..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-[IPC]
-title=System IPC facilities
-path=/usr/bin/ipcs
-args=-a
diff --git a/src/dump_systemstate/programs/crash-worker-programs.conf b/src/dump_systemstate/programs/crash-worker-programs.conf
new file mode 100644 (file)
index 0000000..c8980ac
--- /dev/null
@@ -0,0 +1,73 @@
+[timezone]
+order=100
+title=System timezone
+path=/bin/ls
+args=-l /opt/etc/localtime
+
+[top]
+order=110
+title=System summary
+path=/bin/top
+args=-bcHn1
+env=COLUMNS=200
+
+[ps]
+order=120
+title=Current processes
+path=/bin/ps
+args=auxfw
+
+[memps]
+order=130
+title=System memory statistics
+path=/usr/bin/memps
+args=-v
+
+[buxton memory]
+order=140
+cmdflag=b
+title=System configuration
+path=/usr/bin/buxton2ctl
+args=dump memory
+
+[buxton system]
+order=141
+cmdflag=b
+title=System configuration
+path=/usr/bin/buxton2ctl
+args=dump system
+
+[Tizen packages]
+order=150
+cmdflag=p
+title=Installed packages
+path=/usr/bin/pkgcmd
+args=-l --global
+
+[IPC]
+order=160
+title=System IPC facilities
+path=/usr/bin/ipcs
+args=-a
+
+[dmesg]
+order=200
+cmdflag=k
+title=Kernel messages
+path=/bin/dmesg
+args=-T
+env=TZ=UTC
+
+[dlog]
+order=210
+cmdflag=d
+title=Log messages
+path=/usr/bin/dlogutil
+args=-d -v threadtime -u 16384
+
+[journal]
+order=220
+cmdflag=j
+title=Journal messages
+path=/usr/bin/journalctl
+args=-b -n 1024
@@ -1,4 +1,4 @@
-# See files.conf.example for note about file naming and ordering.
+# See files.conf.example for note about ordering.
 
 [UNIQUE_ID_KEY]
 title=header line describing the program (will be printed alongside env, path and args)
index d684c2d..436fa41 100644 (file)
@@ -65,7 +65,8 @@ check_section "==== System timezone" 2
 check_section "==== System summary" 5
 check_section "==== Current processes" 10
 check_section "==== System memory statistics" 10
-check_section "==== System configuration" 10
+check_section "==== System configuration.*dump memory" 10
+check_section "==== System configuration.*dump system" 10
 check_section "==== Kernel messages" 10
 check_section "==== Log messages" 10
 check_section "==== Journal messages" 10