From 09b5c4b42e9c75c523f4dc3a2036c33dfb5f234b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 10 May 2011 17:36:08 +0200 Subject: Add analyzer which collects /var/log/messages. Closes bz#565725 Signed-off-by: Denys Vlasenko --- abrt.spec.in | 1 + src/gui-wizard-gtk/wizard.c | 72 ++++++++++++++++------------- src/lib/event_xml_parser.c | 8 ++-- src/plugins/Makefile.am | 6 ++- src/plugins/analyze_var_log_messages.xml.in | 10 ++++ src/plugins/ccpp_events.conf | 26 +++++++---- 6 files changed, 76 insertions(+), 47 deletions(-) create mode 100644 src/plugins/analyze_var_log_messages.xml.in diff --git a/abrt.spec.in b/abrt.spec.in index 6c7f2900..af8be2c9 100644 --- a/abrt.spec.in +++ b/abrt.spec.in @@ -540,6 +540,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_sysconfdir}/%{name}/events.d/ccpp_events.conf %{_sysconfdir}/%{name}/events/analyze_LocalGDB.xml %{_sysconfdir}/%{name}/events/analyze_RetraceServer.xml +%{_sysconfdir}/%{name}/events/analyze_var_log_messages.xml %{_mandir}/man*/abrt-action-trim-files.* %{_mandir}/man*/abrt-action-generate-backtrace.* %{_mandir}/man*/abrt-action-analyze-backtrace.* diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 39f90e37..ba0d9b90 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -447,7 +447,7 @@ static void report_tb_was_toggled(GtkButton *button_unused, gpointer user_data_u * Add new {radio/check}buttons to GtkBox for each EVENTn (type depends on bool radio). * Remember them in GList **p_event_list (list of event_gui_data_t's). * Set "toggled" callback on each button to given GCallback if it's not NULL. - * If prev_selected == EVENTn, set this button as active. In this case return NULL. + * If prev_selected_event_name == EVENTn, set this button as active. In this case return NULL. * Else return 1st button created (or NULL if none created). */ static event_gui_data_t *add_event_buttons(GtkBox *box, @@ -455,7 +455,7 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, char *event_name, GCallback func, bool radio, - const char *prev_selected) + const char *prev_selected_event_name) { //VERB2 log("removing all buttons from box %p", box); gtk_container_foreach(GTK_CONTAINER(box), &remove_child_widget, NULL); @@ -466,13 +466,15 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, if (radio) g_black_event_count = 0; - bool have_activated_btn = false; event_gui_data_t *first_button = NULL; + event_gui_data_t *active_button = NULL; while (event_name[0]) { char *event_name_end = strchr(event_name, '\n'); *event_name_end = '\0'; + event_config_t *cfg = get_event_config(event_name); + /* Form a pretty text representation of event */ /* By default, use event name, just strip "foo_" prefix if it exists: */ const char *event_screen_name = strchr(event_name, '_'); @@ -480,11 +482,10 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, event_screen_name++; else event_screen_name = event_name; -///vda + const char *event_description = NULL; char *tmp_description = NULL; bool green_choice = false; - event_config_t *cfg = get_event_config(event_name); if (cfg) { /* .xml has (presumably) prettier description, use it: */ @@ -532,9 +533,10 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, gtk_widget_modify_fg(child, GTK_STATE_PRELIGHT, &green); } } + if (func) g_signal_connect(G_OBJECT(button), "toggled", func, NULL); - if (cfg->long_descr) + if (cfg && cfg->long_descr) gtk_widget_set_tooltip_text(button, cfg->long_descr); event_gui_data_t *event_gui_data = new_event_gui_data_t(); @@ -545,12 +547,12 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, if (!first_button) first_button = event_gui_data; - if ((radio && !prev_selected && !have_activated_btn && !green_choice) - || (prev_selected && strcmp(prev_selected, event_name) == 0) + if ((radio && !prev_selected_event_name && !active_button && !green_choice) + || (prev_selected_event_name && strcmp(prev_selected_event_name, event_name) == 0) ) { - prev_selected = NULL; + prev_selected_event_name = NULL; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true); - have_activated_btn = true; + active_button = event_gui_data; } *event_name_end = '\n'; @@ -561,12 +563,13 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, if (radio) { + const char *msg_proceed_to_reporting = _("Go to reporting step"); GtkWidget *button = radio ? gtk_radio_button_new_with_label_from_widget( (first_button ? GTK_RADIO_BUTTON(first_button->toggle_button) : NULL), - "Don't do anything" + msg_proceed_to_reporting ) - : gtk_check_button_new_with_label("Don't do anything"); + : gtk_check_button_new_with_label(msg_proceed_to_reporting); if (func) g_signal_connect(G_OBJECT(button), "toggled", func, NULL); @@ -575,19 +578,19 @@ static event_gui_data_t *add_event_buttons(GtkBox *box, event_gui_data->toggle_button = GTK_TOGGLE_BUTTON(button); *p_event_list = g_list_append(*p_event_list, event_gui_data); - if (!first_button) - first_button = event_gui_data; + //if (!first_button) + // first_button = event_gui_data; - if (g_black_event_count == 0 && !have_activated_btn) + if (!active_button) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), true); - have_activated_btn = true; + active_button = event_gui_data; } gtk_box_pack_start(box, button, /*expand*/ false, /*fill*/ false, /*padding*/ 0); } - return (have_activated_btn ? NULL : first_button); + return active_button; } struct cd_stats { @@ -661,15 +664,16 @@ void update_gui_state_from_problem_data(void) load_text_to_text_view(g_tv_comment, FILENAME_COMMENT); /* Update analyze radio buttons */ - event_gui_data_t *first_rb = add_event_buttons(g_box_analyzers, &g_list_analyzers, + event_gui_data_t *active_button = add_event_buttons(g_box_analyzers, &g_list_analyzers, g_analyze_events, G_CALLBACK(analyze_rb_was_toggled), /*radio:*/ true, /*prev:*/ g_analyze_event_selected ); /* Update the value of currently selected analyzer */ - if (first_rb) + if (active_button) { free(g_analyze_event_selected); - g_analyze_event_selected = xstrdup(first_rb->event_name); + g_analyze_event_selected = xstrdup(active_button->event_name); + VERB2 log("g_analyze_event_selected='%s'", g_analyze_event_selected); } /* Update reporter checkboxes */ @@ -1131,18 +1135,21 @@ static void next_page(GtkAssistant *assistant, gpointer user_data) int page_no = gtk_assistant_get_current_page(assistant); VERB2 log("page_no:%d", page_no); - if (added_pages[page_no]->name == PAGE_ANALYZE_SELECTOR - && g_analyze_event_selected != NULL - && g_analyze_event_selected[0] - ) { - start_event_run(g_analyze_event_selected, - NULL, - pages[PAGENO_ANALYZE_PROGRESS].page_widget, - g_tv_analyze_log, - g_lbl_analyze_log, - _("Analyzing..."), - _("Analyzing finished with exit code %d") - ); + if (added_pages[page_no]->name == PAGE_ANALYZE_SELECTOR) + { + VERB2 log("g_analyze_event_selected:'%s'", g_analyze_event_selected); + if (g_analyze_event_selected + && g_analyze_event_selected[0] + ) { + start_event_run(g_analyze_event_selected, + NULL, + pages[PAGENO_ANALYZE_PROGRESS].page_widget, + g_tv_analyze_log, + g_lbl_analyze_log, + _("Analyzing..."), + _("Analyzing finished with exit code %d") + ); + } } if (added_pages[page_no]->name == PAGE_REPORT) @@ -1236,6 +1243,7 @@ static gint next_page_no(gint current_page_no, gpointer data) break; case PAGENO_ANALYZE_PROGRESS: + VERB2 log("g_analyze_event_selected:'%s'", g_analyze_event_selected); if (!g_analyze_event_selected || !g_analyze_event_selected[0]) goto again; } diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c index 30c0ee31..9dc8eee1 100644 --- a/src/lib/event_xml_parser.c +++ b/src/lib/event_xml_parser.c @@ -56,16 +56,16 @@ static const char *const option_types[] = static char *get_element_lang(struct my_parse_data *parse_data, const gchar **att_names, const gchar **att_values) { char *short_locale_end = strchr(parse_data->cur_locale, '_'); - VERB2 log("locale: %s", parse_data->cur_locale); + VERB3 log("locale: %s", parse_data->cur_locale); int i; for (i = 0; att_names[i] != NULL; ++i) { - VERB2 log("attr: %s:%s", att_names[i], att_values[i]); + VERB3 log("attr: %s:%s", att_names[i], att_values[i]); if (strcmp(att_names[i], "xml:lang") == 0) { if (strcmp(att_values[i], parse_data->cur_locale) == 0) { - VERB2 log("found translation for: %s", parse_data->cur_locale); + VERB3 log("found translation for: %s", parse_data->cur_locale); return xstrdup(att_values[i]); } @@ -75,7 +75,7 @@ static char *get_element_lang(struct my_parse_data *parse_data, const gchar **at if (short_locale_end && strncmp(att_values[i], parse_data->cur_locale, short_locale_end - parse_data->cur_locale) == 0 ) { - VERB2 log("found translation for shortlocale: %s", parse_data->cur_locale); + VERB3 log("found translation for shortlocale: %s", parse_data->cur_locale); return xstrndup(att_values[i], short_locale_end - parse_data->cur_locale); } } diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 699f13bd..7221079a 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -40,6 +40,7 @@ dist_events_DATA = \ report_Logger.conf \ analyze_LocalGDB.xml \ analyze_RetraceServer.xml \ + analyze_var_log_messages.xml \ report_Mailx.xml \ report_RHTSupport.xml \ report_Kerneloops.xml @@ -90,11 +91,12 @@ EXTRA_DIST = \ $(MAN_TXT) \ $(PYTHON_FILES) \ $(man1_MANS) \ + analyze_var_log_messages.xml.in \ + analyze_LocalGDB.xml.in \ + analyze_RetraceServer.xml.in \ report_Bugzilla.xml.in \ report_Bugzilla.conf \ report_Logger.conf \ - analyze_LocalGDB.xml.in \ - analyze_RetraceServer.xml.in \ report_Mailx.xml.in \ report_RHTSupport.xml.in \ report_Kerneloops.xml.in diff --git a/src/plugins/analyze_var_log_messages.xml.in b/src/plugins/analyze_var_log_messages.xml.in new file mode 100644 index 00000000..fa5edbff --- /dev/null +++ b/src/plugins/analyze_var_log_messages.xml.in @@ -0,0 +1,10 @@ + + + Collect /var/log/messages + <_description>Save relevant lines in /var/log/messages + <_long-description> + Scans through /var/log/messages file and saves those lines which contain executable's name. + The result is saved as 'var_log_messages' element. + + var_log_messages + diff --git a/src/plugins/ccpp_events.conf b/src/plugins/ccpp_events.conf index dc582486..ca9ac558 100644 --- a/src/plugins/ccpp_events.conf +++ b/src/plugins/ccpp_events.conf @@ -1,18 +1,26 @@ EVENT=post-create analyzer=CCpp - abrt-action-analyze-c && - abrt-action-list-dsos.py -m maps -o dsos + abrt-action-analyze-c && + abrt-action-list-dsos.py -m maps -o dsos + +EVENT=analyze_var_log_messages analyzer=CCpp + test -f /var/log/messages || { echo "No /var/log/messages"; exit 1; } + test -r /var/log/messages || { echo "Can't read /var/log/messages"; exit 1; } + executable=`cat executable` && + base_executable=${executable##*/} && + grep -e "$base_executable" /var/log/messages | tail -999 >var_log_messages && + echo "var_log_messages element saved" # TODO: can we still specify additional directories to search for debuginfos, # or was this ability lost with move to python installer? EVENT=analyze_LocalGDB analyzer=CCpp - abrt-action-analyze-core.py --core=coredump -o build_ids && - abrt-action-install-debuginfo --size_mb=4096 && - abrt-action-generate-backtrace && - abrt-action-analyze-backtrace + abrt-action-analyze-core.py --core=coredump -o build_ids && + abrt-action-install-debuginfo --size_mb=4096 && + abrt-action-generate-backtrace && + abrt-action-analyze-backtrace EVENT=analyze_RetraceServer analyzer=CCpp - abrt-retrace-client batch --dir "$DUMP_DIR" && - abrt-action-analyze-backtrace + abrt-retrace-client batch --dir "$DUMP_DIR" && + abrt-action-analyze-backtrace EVENT=report_Bugzilla analyzer=CCpp - abrt-action-bugzilla -c /etc/abrt/plugins/Bugzilla.conf + abrt-action-bugzilla -c /etc/abrt/plugins/Bugzilla.conf -- cgit