I am currently trying to learn how to generate Java code with the AgenPro application on MacOS Ventura 13.5. I am trying it with the IF-MIB without success. I keep getting the attached 5 errors:
I assume that you have a AgenPro configuration file still in your home directory that contains an old project generation configuration, because in your steps, the “Project/Open” step seems to be missing.
In the project file, the correct template paths should be configured.
To fix your setup, you can choose “Project/Edit” and replace the string “snmp4j-agent_3_1” by “snmp4j-agent-v3” in all paths. That will remove the errors from the code generation.
However, the never project file might contain additional code generations or formatting information, that had not been yet included in the “old” project configuration present on your system.
Do you see anything in the log panel?
The code generation is very quick, so it will never take more than a couple of seconds.
It is unusual that the progress dialog does not disappear. That’s why I assume a rather fatal error in the log. The job name is a bit unusual - I would have expected an MIB module name here instead of “MimeMhs”. Maybe that points in the right direction?
For SNMP4J agent code generation the first job generates the MIB module names for the second job phase.
There is nothing in the log panel. I even tried saving the logging output to a log file and the generated file is empty. I get the same dialog hang with the INET-ADDRESS-MIB. I am not sure why it shows MimeMhs as the MIB module–not sure what that is.
I am currently evaluating AgenPro for a big project that is about to start. Do you know if there is someone from the AgenPro development team that can help? (Not sure if you are part of the AgenPro development team).
Hi Bill,
I am the developer of AgenPro. Maybe you can send screenshots with the content of all the project wizard pages and the log panel (with DEBUG level enabled) to support@agentpp.com
I guess there is some fundamental misunderstanding or misconfiguration.
You can send me as alternative to the screenshots the AgenPro4.cf file to the above email address. That file contains the complete configuration.
BTW, are you able to load MIB files from your repository into the AgenPro UI using File>Open/Close MIB? Then you MIB repository works.
To generate code for a specific selected MIB like shown in the below screenshot (e.g., IF-MIB) the checkbox to create code for all MIB modules should be unchecked in the project editor:
The main issue is that the Java Google [built-in] formatter throws an exception with the latest JDKs (those shipped with DMG and MSI packages) because of:
java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x5cc73178) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module @0x5cc73178
As a workaround you can remove the Google formatter from the configuration as follows:
Another issue with the job template configuration (it is not the best possible): To update it to the latest predefined one, you can use the “predefined job template” named snmp4j-agent-v3.jobs as shown by the following screenshot:
I am now able to generate Java code from the IF-MIB module after applying your suggested workarounds. Thanks!
I could not run your suggested start scripts because I do not have the agenpro4.jar file. I am using the DMG version of AgenPro 5.1.0 on the Mac.
Anyway, next I would like to try out the SNMP agent to see if I am able to make SNMP calls against the code that was generated for the IF-MIB module. Is there a quick tutorial on that? (I’ll also take a look at the manual).
Yes, I was able to upgrade to AgentPro 5.1.1 but it prompted me to install it again & again even though it was already installed. I finally just cancelled the prompt to get me out of the infinite loop.
I am not able to successfully compile the agent. I am getting the following error:
╭─bdurant@Macbook2 /var/tmp/agenpro5/generated/snmp4j
╰─$ mvn --version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T00:58:13-07:00)
Maven home: /Applications/apache-maven-3.5.2
Java version: 11.0.16.1, vendor: Amazon.com Inc.
Java home: /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "13.5", arch: "x86_64", family: "mac"
╭─bdurant@Macbook2 /var/tmp/agenpro5/generated/snmp4j
╰─$ mvn clean install
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /private/var/tmp/agenpro5/generated/snmp4j/pom.xml: Unrecognised tag: 'exclusions' (position: START_TAG seen ...</exclusion>\n\t\t\t\t<exclusions>... @55:17) @ /private/var/tmp/agenpro5/generated/snmp4j/pom.xml, line 55, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.snmp4j.agent:snmp4j-agent-gen:1.0.0-SNAPSHOT (/private/var/tmp/agenpro5/generated/snmp4j/pom.xml) has 1 error
[ERROR] Malformed POM /private/var/tmp/agenpro5/generated/snmp4j/pom.xml: Unrecognised tag: 'exclusions' (position: START_TAG seen ...</exclusion>\n\t\t\t\t<exclusions>... @55:17) @ /private/var/tmp/agenpro5/generated/snmp4j/pom.xml, line 55, column 17 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
Here are the contents of the generated pom.xml file:
The simulation agent is working for me. It takes a few seconds to finish the starting, because the port needs to be bound, but hen it is running. You can check the progress in the Log panel if you have activated at least the INFO level.
Note: Please disable “code generation preview” if you are using maven while AgenPro is open. Maven triggers a lot of operating system file update events that “overload” the diff view of AgenPro with update events. Although I tried to mitigate this issue by some queuing techniques, it does not seem to finally help a lot. I am still working on it.
I was able to compile the agent after removing the exclusions from the generated POM file manually–not sure how about the process for modifying the templates to do the same.
So I started the agent and while it throws a java exception at the end, it appears to be running:
─bdurant@Macbook2 /var/tmp/agenpro5/generated/snmp4j/target
╰─$ java -jar snmp4j-agent-gen-1.0.0-SNAPSHOT-jar-with-dependencies.jar udp:0.0.0.0/4700
Jul 27, 2023 5:56:22 PM org.snmp4j.log.JavaLogAdapter log
INFO: Engine boots is: 1 for engine ID: null
Jul 27, 2023 5:56:22 PM org.snmp4j.log.JavaLogAdapter log
...
...
INFO: Registered MO [DefaultMOTable] in default context with scope DefaultMOTable[id=1.3.6.1.2.1.31.1.4.1,index=MOTableIndex{subindexes=[MOTableSubIndex{smiSyntax=2, minLength=1, maxLength=1, oid=1.3.6.1.2.1.2.2.1.1}, MOTableSubIndex{smiSyntax=4, minLength=0, maxLength=128, oid=1.3.6.1.2.1.31.1.4.1.1}], impliedLength=false, validator=org.snmp4j.agent.tutorial.IfMib$5@306e95ec},columns=[org.snmp4j.agent.mo.snmp.RowStatus[columnID=2,syntax=2,default=null,mutableInService=true,mandatory=true], org.snmp4j.agent.mo.snmp.Enumerated[columnID=3,syntax=2,default=2,mutableInService=true,mandatory=true]]]
Exception in thread "main" java.lang.NumberFormatException: For input string: "1#--|AgenPro:|--#"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at org.snmp4j.agent.io.prop.PropertyMOInput.createVariableFromString(PropertyMOInput.java:506)
at org.snmp4j.agent.io.prop.PropertyMOInput.scanDataIndexVariables(PropertyMOInput.java:326)
at org.snmp4j.agent.io.prop.PropertyMOInput.readSequence(PropertyMOInput.java:423)
at org.snmp4j.agent.mo.DefaultMOTable.load(DefaultMOTable.java:1600)
at org.snmp4j.agent.io.MOServerPersistence.readData(MOServerPersistence.java:162)
at org.snmp4j.agent.io.MOServerPersistence.loadData(MOServerPersistence.java:104)
at org.snmp4j.agent.AgentConfigManager.configure(AgentConfigManager.java:787)
at org.snmp4j.agent.AgentConfigManager.run(AgentConfigManager.java:322)
at org.snmp4j.agent.tutorial.Agent.run(Agent.java:131)
at org.snmp4j.agent.tutorial.Agent.defaultMain(Agent.java:309)
at org.snmp4j.agent.tutorial.Agent.main(Agent.java:334)
However, I not able to access it even though the Firewall is disabled:
╰─$ snmpget -v2c -c public 127.0.0.1:4700 IF-MIB::ifDescr.1 1 ↵
Timeout: No Response from 127.0.0.1:4700.
╭─bdurant@Macbook2 ~/scripts
╰─$ snmpwalk -v 2c -c public 127.0.0.1:4700 1 ↵
Timeout: No Response from 127.0.0.1:4700
╭─bdurant@Macbook2 ~/scripts
╰─$ sudo lsof -i :4700 1 ↵
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 37244 bdurant 5u IPv6 0x8cde41d1b00b35f5 0t0 UDP *:netxms-agent
As for the simulation agent issue, I am still getting the hang. I looked into the UI and did not find any way to activate INFO log level. Nothing is showing up in the log panel.
Regarding the templates, there will be a fix available soon (with 5.1.2).
The exception comes from a template issue too, in the agent properties file where its initial configuration is stored, some data has not been generated appropriately. I will check that too.
For the simulation agent log: Please got the the log panel and click on the small + or arrow sign on the categories:
Here the line break is correct. That does not seem to be the case on your system. Either the corresponding template was edited, or there is an issue with the newline and carriage return interpretation on your system (can be caused by moving a Windows file to Unix or vice versa)
I was able to configure DEBUG for the Agent category via the Logging Properties but I am still not seeing any logs while the Simulation Agent is running. The Simulation Agent still hangs for me. I am on MacOS Ventura 13.5. I am not using any other operating system. I am not seeing a way to set the log level to DEBUG at the root level.