Skip to content

Commit

Permalink
Make the agent configurable via configuration file
Browse files Browse the repository at this point in the history
Related to #34

Signed-off-by: Jakub Filak <jfilak@redhat.com>
  • Loading branch information
Jakub Filak committed Mar 13, 2014
1 parent 74291f7 commit 8a28fc6
Show file tree
Hide file tree
Showing 12 changed files with 762 additions and 227 deletions.
34 changes: 32 additions & 2 deletions README
Expand Up @@ -16,10 +16,20 @@ It needs to be compiled as a shared native library (.so) and then loaded into
JVM using -agentlib command line parameter.


Configuration
-------------

The agent can be configured either via configuration file or via command line
arguments. The command line arguments have higher priority and overwrites
values loaded from the configuration file.

The default path to the configuration file is '/etc/abrt/plugins/java.conf'.


Examples
--------

Before you can run the example, you need to make sure that
Before you can run the examples, you need to make sure that
libabrt-java-connector.so is placed somewhere in the ld searched directories
or configure LD_LIBRARY_PATH environment variable to point to a directory
containing the library.
Expand Down Expand Up @@ -76,7 +86,7 @@ $ java -agentlib:abrt-java-connector=journald=off $MyClass -platform.jvmtiSuppo
$ java -agentlib:abrt-java-connector=syslog=on $MyClass -platform.jvmtiSupported true

Example5:
- this example shows how configure abrt-java-connector to fill 'executable'
- this example shows how to configure abrt-java-connector to fill 'executable'
ABRT file with a path to a class on the bottom of the stack trace (the first
method of thread)
- this feature can be enabled via 'executable' option which can contain either
Expand All @@ -86,3 +96,23 @@ $ java -agentlib:abrt-java-connector=executable=threadclass $MyClass -platform.

- 'mainclass' is used when 'executable' option is not passed and 'executable'
file is filled with full path $MyClass


Example6:
- this example shows how to enrich the exception report with extra debug information
- abrt-java-connector is capable to call a static method returning String at
time of processing exception
- while creating the exception report methods from the list stored in
'debugmethod' option are called, not all of them, but only those whose defining
class was already loaded by 'System Class Loader'

$ java -agentlib:abrt-java-connector=debugmethod=com.example.$MyClass.getMethod $MyClass


Example7:
- this example shows how to change the path to configuration file
- the default configuration file path is '/etc/abrt/plugins/java.conf'
- empty 'conffile' option means do not read any configuration file


$ java -agentlib:abrt-java-connector=conffile=/etc/foo/example.conf $MyClass
6 changes: 6 additions & 0 deletions etc/CMakeLists.txt
Expand Up @@ -6,3 +6,9 @@ install(FILES java_event.conf.5 bugzilla_format_java.conf.5 bugzilla_formatdup_j

install(FILES bugzilla_format_java.conf bugzilla_formatdup_java.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/libreport/plugins)

install(FILES java.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/abrt/plugins)

install(FILES java.conf
DESTINATION ${SHARE_INSTALL_PREFIX}/abrt/conf.d/plugins)
36 changes: 36 additions & 0 deletions etc/java.conf
@@ -0,0 +1,36 @@
# Which frame of a stack trace to use for 'executable'
# Allowed options are 'mainclass' or 'threadclass' where
# 'mainclass' is used when this option is not configured.
# executable = threadclass

# Enables reporting of exceptions to ABRT
# Default value: off
abrt = on

# If enabled, exception reports are written to syslog
# Default value: off
# syslog = on

# If enabled, exception reports are written to systemd-journald
# Default value: on
# journald = off

# Path to directory or file for writing exception reports.
# Default value: <empty string = means no log file>
# output = /tmp/

# Comma separated list of exception types that are reported even
# if they are caught.
# Default value: <empty>
# caught = java.lang.UnsatisfiedLinkError, java.lang.ClassCastException

# Comma separated list of methods whose return values are
# included in exception report.
# Methods in the list must be static, without arguments and return
# java.lang.String
# Default value: empty
#
# http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2014-March/026533.html
# http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2014-March/026551.html
#
debugmethod = net.sourceforge.jnlp.runtime.JNLPRuntime.getHistory
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -3,13 +3,15 @@ include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})

pkg_check_modules(PC_JOURNALD REQUIRED libsystemd-journal)
include_directories(${PC_LIBREPORT_INCLUDE_DIRS})
include_directories(${PC_ABRT_INCLUDE_DIRS})
include_directories(${PC_JOURNALD_INCLUDE_DIRS})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -DVERBOSE")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSILENT")

set(AbrtChecker_SRCS abrt-checker.c jthrowable_circular_buf.c jthread_map.c)
set(AbrtChecker_SRCS configuration.c abrt-checker.c
jthrowable_circular_buf.c jthread_map.c)

add_library(AbrtChecker SHARED ${AbrtChecker_SRCS})
set_target_properties(
Expand All @@ -18,6 +20,7 @@ set_target_properties(
OUTPUT_NAME abrt-java-connector)

target_link_libraries(AbrtChecker ${PC_LIBREPORT_LIBRARIES})
target_link_libraries(AbrtChecker ${PC_ABRT_LIBRARIES})
target_link_libraries(AbrtChecker ${PC_JOURNALD_LIBRARIES})

install(TARGETS AbrtChecker DESTINATION ${LIB_INSTALL_DIR})

0 comments on commit 8a28fc6

Please sign in to comment.