8 Replies Latest reply on Nov 26, 2008 4:30 PM by mazz

    Agent startup problem

    rafaelcba

      Hi!

      I configure the agents for start automatically when a platform need to be restart (S.O boot). But sometimes my agents don't start automatically by agent-wrapper.sh script on some servers.

      This message's show in agent's log:

      2008-11-18 13:29:34,515 FATAL [main] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.startup-error}The agent encountered an error during startup and must abort
       java.lang.IllegalStateException: The name of this agent is not defined - you cannot start the agent until you give it a valid name
       at org.rhq.enterprise.agent.AgentMain.start(AgentMain.java:480)
       at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:347)
      2008-11-18 13:29:34,539 INFO [main] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.shutting-down}Agent is being shut down...
      2008-11-18 13:29:34,638 WARN [main] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.server-shutdown-notification-failure}Agent failed to notify the server of the pending shutdown. Cause: java.lang.NullPointerException:null
      2008-11-18 13:29:34,638 INFO [main] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.shut-down}Agent has been shut down
      2008-11-18 13:29:34,810 FATAL [main] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.start-failure}Failed to start the agent
      java.lang.IllegalStateException: The name of this agent is not defined - you cannot start the agent until you give it a valid name
       at org.rhq.enterprise.agent.AgentMain.start(AgentMain.java:480)
       at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:347)


      When I try start the agent manually it start normally without change nothing!

      May be agent temporally lost any data or conf?! I don't know.

      Any idea?

      Thanks!


        • 1. Re: Agent startup problem
          pilhuhn

          Is your wrapper script started as the same user as the non-daemon one?
          Stuff is stored in java preferences and they are separate per user.

          • 2. Re: Agent startup problem
            mazz

            You are probably starting it as different users.

            Configuration is stored in Java prefs on a per-user basis (see documentation re: Java Preferences API - on UNIX, it stores them at $HOME/.java.

            Assuming the agent runs as root at boot time, you need to run the agent as root from the command line first to configure it fully. Running it as a different user picks up a different set of configuration.

            There are other ways to preconfigure the agent, but that's the easiest. See the docs for more information on preconfiguring the agent ahead of time if that's what you want.

            BTW: in /trunk, the agent will now autogenerate its agent name if you don't give it one the first time it starts up. That will be in the next release. That's specifically what that error message is telling it - agent name is stored in the user preferences, which is why one user has it set and the other user doesn't.

            • 3. Re: Agent startup problem
              rafaelcba

              Hum!
              It's true!

              I don't pay attention for this...

              Really I use a non root user for start JBoss and Jopr Agent and on OS boot the root user is used.

              I'll change the wrapper script to force the agent start with a specific user like this:

              su - <user_name> -c "java command..."

              Thanks!

              • 4. Re: Agent startup problem
                mazz

                Let us know what exactly you changed and ideas to make this more configurable without having you edit the out-of-box wrapper scripts. This sounds like something alot of people will want to do (i.e. start the agent up as a specific user at boot time) but I don't know a good way to do it. We have this capability on Windows, just not on the UNIX platforms.

                For example, what if you set an environment variable like "RHQ_AGENT_RUN_AS=myusername" and have the wrapper script look for that and sudo to that user if it is set?

                Write a JIRA at http://jira.rhq-project.org if you think this would be a good enhancement to the launcher scripts with your ideas.

                • 5. Re: Agent startup problem
                  mazz

                  In fact, let me write the JIRA now - this is something I want to do in the future:

                  http://jira.rhq-project.org/browse/RHQ-1189

                  I hate having a capability for Windows but not for UNIX :)

                  Feel free to comment in that jira

                  • 6. Re: Agent startup problem
                    jpviragine

                    Another issue when run wrapper as a non root user is that PIDFILEDIR points to /var/run that's usually not writable for non root user.

                    Even so agent starts with message: Failed to start - make sure the RHQ Agent is fully configured properly

                    Should I open a JIRA?

                    • 7. Re: Agent startup problem
                      mazz

                      There is a JIRA on that already and it has been fixed in trunk

                      • 8. Re: Agent startup problem
                        mazz