{"id":26659873,"url":"https://github.com/ashutoshiwnl/monarchjavaagent","last_synced_at":"2025-03-25T11:15:52.963Z","repository":{"id":282572037,"uuid":"949017530","full_name":"AshutoshIWNL/MonarchJavaAgent","owner":"AshutoshIWNL","description":"Monarch-Java-Agent is a powerful Java agent for method monitoring and analysis. It offers various features to track method execution time, print stack traces, log method arguments and return values, capture heap dumps, and gather JVM-related information.","archived":false,"fork":false,"pushed_at":"2025-03-15T14:20:53.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T14:33:40.623Z","etag":null,"topics":["application-monitoring","bytecode-manipulation","instrumentation-agent","java-agent"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AshutoshIWNL.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-15T13:44:34.000Z","updated_at":"2025-03-15T14:20:56.000Z","dependencies_parsed_at":"2025-03-15T19:15:11.781Z","dependency_job_id":null,"html_url":"https://github.com/AshutoshIWNL/MonarchJavaAgent","commit_stats":null,"previous_names":["ashutoshiwnl/monarchjavaagent"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AshutoshIWNL%2FMonarchJavaAgent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AshutoshIWNL%2FMonarchJavaAgent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AshutoshIWNL%2FMonarchJavaAgent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AshutoshIWNL%2FMonarchJavaAgent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AshutoshIWNL","download_url":"https://codeload.github.com/AshutoshIWNL/MonarchJavaAgent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245449674,"owners_count":20617190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-monitoring","bytecode-manipulation","instrumentation-agent","java-agent"],"created_at":"2025-03-25T11:15:51.621Z","updated_at":"2025-03-25T11:15:52.933Z","avatar_url":"https://github.com/AshutoshIWNL.png","language":"Java","readme":"# MonarchJavaAgent\n\nMonarchJavaAgent is a powerful Java agent for method monitoring and analysis. It offers various features to track method execution time, print stack traces, log method arguments and return values, capture heap dumps, and gather JVM-related information.\n\n## Features\n\n- **Method Execution Time**: Print the time taken for a method's execution.\n- **Stack Trace Printing**: Print the stack trace when a certain method is invoked.\n- **Argument Logging**: Log the arguments provided to a method.\n- **Return Value Logging**: Log the return value of a method.\n- **Custom code addition**: Add custom code to a method.\n- **Heap Dump Capture**: Take a heap dump when a method is invoked or exits.\n- **System Flags Printing**: Print system flags of the target application.\n- **JVM Options Printing**: Print JVM options of the target application.\n- **JVM Heap Usage Details**: Print JVM heap usage details of the target application.\n- **JVM CPU Usage Details**: Print JVM CPU usage details of the target application.\n- **Alert Emails**: Sends alert emails for high heap/ high CPU usage in the target application. \n\n## Agent Arguments\n\n| Argument        | Description |\n|----------------|-------------|\n| `configFile`   | Path to the configuration file specifying agent behavior. |\n| `agentLogFileDir` | Directory where initialization logs will be written. |\n| `agentLogLevel` | Log verbosity level (`DEBUG`, `INFO`, `WARN`, `ERROR`). |\n| `smtpProperties` | Path to SMTP configuration for sending alert emails. |\n\n\n## Usage\n\nYou can attach Monarch-Java-Agent either during startup or during runtime.\n\n**For startup:**\n\n1. Download the latest agent JAR file from releases page.\n2. Start your Java application using the `-javaagent` option.\n3. Specify the configuration file and other options as needed.\n\nExample command to attach the agent:\n\n```bash \njava -Xbootclasspath/a:/path/to/monarch-java-agent.jar -javaagent:/path/to/monarch-java-agent.jar=configFile=/path/to/config.yaml,agentLogFileDir=/path/to/log/dir,agentLogLevel=DEBUG,smtpProperties=/path/to/smtpProperties.props YourMainClass\n```\n\n**For Runtime:**\n\n1. Download the latest agent JAR file from releases page.\n2. Start your application.\n3. Run \"monarchAgentStart.bat\"/\"monarchAgentStart.sh\" and provide the requested details.\n\nExample command run:\n```bash \nC:\\Users\\ashut\\monarch-java-agent\\attachScript\u003e .\\monarchAgentStart.bat\nEnter path to the agent JAR file: C:\\Users\\ashut\\monarch-java-agent\\target\\monarch-java-agent-1.0-SNAPSHOT.jar\nEnter path to the agent config file: C:\\Users\\ashut\\monarch-java-agent\\sampleConfig\\mConfig.yaml\nEnter arguments to pass to the agent: agentLogFileDir=C:\\Users\\ashut\\manualTesting,agentLogLevel=DEBUG,smtpProperties=/path/to/smtpProperties.props\nEnter PID of the target JVM (press Enter to use current JVM): 24300\nAgent attached successfully to PID 24300\n```\n\n## Configuration\n\nBelow is a sample configuration YAML that you can use with Monarch-Java-Agent:\n\n```yaml\nshouldInstrument: true\nconfigRefreshInterval: 15\ntraceFileLocation: C:\\\\TraceFileDumps\nagentRules:\n  - ClassA::methodA@INGRESS::STACK\n  - ClassA::methodA@INGRESS::ARGS\n  - ClassA::methodA@EGRESS::RET\n  - ClassA::methodB@INGRESS::ARGS\n  - ClassA::methodB@INGRESS::STACK\n  - ClassA::methodB@EGRESS::STACK\n  - ClassA::methodB@EGRESS::RET\n  - ClassB::methodC@PROFILE\n  - ClassB::methodC@INGRESS::HEAP\n  - ClassB::methodC@INGRESS::ADD::[System.out.println(20);]\n  - ClassA::methodA@INGRESS::ADD::[System.out.println(this.getClass().getName());]\n  - ClassA::methodA@CODEPOINT(11)::ADD::[System.out.println(499);]\n  - ClassA::methodA@CODEPOINT(11)::ADD::[System.out.println(499 + \",\" + \"Ashutosh Mishra\");]\nprintClassLoaderTrace: true\nprintJVMSystemProperties: true\nprintEnvironmentVariables: true\nprintJVMHeapUsage: true\nprintJVMCpuUsage: true\nmaxHeapDumps: 3\nsendAlertEmails: true\nemailRecipientList:\n  - abc@example.com\n  - ashutosh@asm.com\n```\n\n## Rule Syntax\n\nThe rule syntax for Monarch-Java-Agent follows the format:\n\n```plaintext\n\u003cFQCN\u003e::\u003cMethodName\u003e@\u003cEVENT\u003e::\u003cACTION\u003e\n```\n\nWhere:\n\n- `\u003cFQCN\u003e`: Fully Qualified Class Name.\n- `\u003cMethodName\u003e`: Name of the method.\n- `\u003cEVENT\u003e`: Event at which the action should be performed. Possible values are:\n    - INGRESS\n    - EGRESS\n    - CODEPOINT\n    - PROFILE (Note: PROFILE is a special case and no ACTION is required along with it.)\n- `\u003cACTION\u003e`: Action to be performed. Possible values are:\n    - STACK: Print stack trace.\n    - HEAP: Capture heap dump.\n    - ARGS: Log method arguments.\n    - RET: Log method return value.\n    - ADD: Add custom code.\n\n\n## Building from Source\n\n```bash\ngit https://github.com/AshutoshIWNL/MonarchJavaAgent.git\ncd MonarchJavaAgent\nmvn clean package\n```\n\n## Author\n\n- **Ashutosh Mishra** (https://github.com/AshutoshIWNL)\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashutoshiwnl%2Fmonarchjavaagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashutoshiwnl%2Fmonarchjavaagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashutoshiwnl%2Fmonarchjavaagent/lists"}