14 Replies Latest reply on Mar 18, 2009 4:33 PM by mazz

    Installing JOPR agent as service on windows

    ICT KG Newbie

      We are using Jopr 2.1on MS Windows

      Having setup the Jopr agent manually it connects to the Jopr server and works fine. When we try to start te JOPR agent as a SYSTEM service however this fails. Starting it as a user account (with password) works but is not favourable as the user may disappear in future and subsequently will stop all agents from working.

      The JOPR server however starts as a SYSTEM service without problems.

      Are there some parameters missing for the agent to start as a SYSTEM service that we should set particularly? Or are there particular registry settings that need changing?

      Regards,
      ictkg

        • 1. Re: Installing JOPR agent as service on windows
          Heiko Rupp Master

          Hello,

          this is sort of a "feature" :-)

          Have a look at http://www.redhat.com/docs/en-US/JBoss_ON/html/FAQs/sect-FAQs-Agent-Agent_Fail.html and tell us if it helped you.

          Heiko

          • 2. Re: Installing JOPR agent as service on windows
            ICT KG Newbie

            Thanks for your quick reply/suggestion.

            We followed the documentation and put the following at the end of the rhq-agent-env.bat :
            set RHQ_AGENT_CMDLINE_OPTS=--input D:\jopr-agent-2.1.0.GA\bin\agents-settings.txt --nonative
            THat did not work.

            We removed the line and put following lines in rhq-agent-wrapper.conf:
            wrapper.app.parameter.3=--input
            wrapper.app.parameter.4=D:\jopr-agent-2.1.0.GA\bin\agents-settings.txt
            That also did not work.

            According to the documentation we do not need to provide following environment variables to start as a SYSTEM service :
            RHQ_AGENT_RUN_AS_ME
            RHQ_AGENT_RUN_AS

            output in the rhq-agent-wrapper.log file shows:
            STATUS | wrapper | 2009/02/27 11:35:25 | RHQ Agent [rhqagent-WXP5203] installed.
            STATUS | wrapper | 2009/02/27 11:35:53 | Starting the RHQ Agent [rhqagent-WXP5203] service...
            STATUS | wrapper | 2009/02/27 11:35:53 | --> Wrapper Started as Service
            STATUS | wrapper | 2009/02/27 11:35:54 | Launching a JVM...
            INFO | jvm 1 | 2009/02/27 11:35:54 | Wrapper (Version 3.2.0) http://wrapper.tanukisoftware.org
            INFO | jvm 1 | 2009/02/27 11:35:54 |
            INFO | jvm 1 | 2009/02/27 11:35:54 | RHQ 1.1.0.GA (null)
            INFO | jvm 1 | 2009/02/27 11:35:54 | Failed to start the agent
            INFO | jvm 1 | 2009/02/27 11:35:54 | java.net.BindException: Cannot assign requested address: JVM_Bind
            INFO | jvm 1 | 2009/02/27 11:35:54 | at java.net.PlainSocketImpl.socketBind(Native Method)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at java.net.ServerSocket.bind(ServerSocket.java:319)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at java.net.ServerSocket.(ServerSocket.java:185)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:169)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.jboss.remoting.transport.socket.SocketServerInvoker.createServerSocket(SocketServerInvoker.java:264)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.jboss.remoting.transport.socket.SocketServerInvoker.start(SocketServerInvoker.java:193)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.jboss.remoting.transport.Connector.start(Connector.java:322)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.rhq.enterprise.communications.ServiceContainer.setupServerConnector(ServiceContainer.java:1196)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.rhq.enterprise.communications.ServiceContainer.start(ServiceContainer.java:546)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.rhq.enterprise.communications.ServiceContainer.start(ServiceContainer.java:464)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.rhq.enterprise.agent.AgentMain.startCommServices(AgentMain.java:1656)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.rhq.enterprise.agent.AgentMain.start(AgentMain.java:486)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:347)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at java.lang.reflect.Method.invoke(Method.java:585)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:197)
            INFO | jvm 1 | 2009/02/27 11:35:54 | at java.lang.Thread.run(Thread.java:595)
            STATUS | wrapper | 2009/02/27 11:35:56 | RHQ Agent [rhqagent-WXP5203] started.
            STATUS | wrapper | 2009/02/27 11:36:00 | <-- Wrapper Stopped

            Any ideas ?

            Regards,
            ictkgt

            • 3. Re: Installing JOPR agent as service on windows
              Heiko Rupp Master

              This line

              INFO | jvm 1 | 2009/02/27 11:35:54 | java.net.BindException: Cannot assign requested address: JVM_Bind


              suggests, that there is perhaps another agent running which is already using the given port (16163) so that the agent can not bind to it and gives up.

              Heiko

              • 4. Re: Installing JOPR agent as service on windows
                mazz Master

                BTW: using --input to pipe in answers to the settings questions is the incorrect way to preconfigure your agent.

                Read this:

                http://www.redhat.com/docs/en-US/JBoss_ON/html/Installation_Guide/Installation_Guide-JON_Agent_Installation_Guide-Preconfiguring_Agents.html

                I'm reading this thread and will reply once I digest it, but I wanted to get this piece of info out there asap.

                • 5. Re: Installing JOPR agent as service on windows
                  mazz Master

                  I agree with pilhuhn - it looks like something has already bound to the port that you want the agent to start on.

                  You are correct about the SYSTEM user - you do not have to specify any RHQ_AGENT_RUN_AS variables to get it to start as the SYSTEM user, that is the default.

                  All you have to do is make sure the agent is preconfigured properly (that's the link I provided before - it tells you about preconfiguring the agent)

                  Once you preconfigured the agent properly, it should start up fine. In the current release, you must remember to set the rhq.agent.name setting in agent-configuration.xml - in the next release, the agent will use its hostname as the default value for that so you technically don't need to set it yourself. But you will need to provide things like the agent port, bind address and the initial server endpoint/port.

                  BTW: now that you have ran the agent once, you will have preferences stored in your Windows Registry (that's where Java stores Java Preferences on Windows). So changes you now make to agent-configuration.xml will no longer take effect. You need to clean out the configuration via --cleanconfig option (you must run the agent as the SYSTEM user to do this - running the agent from the command line with --cleanconfig will only clean your users preferences, not the SYSTEM user preferrences - you may just want to use "regedit" to purge the registry entries at "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs\rhq-agent" (I think that is where the SYSTEM user puts its Java Preferences, not sure).

                  Read the comments at the very top of agent-configuration.xml - it explains alot about how the configuration file works.

                  • 6. Re: Installing JOPR agent as service on windows
                    ICT KG Newbie

                    Hello Mazz and pilhuhn

                    Thank you for the suggestions, I modified the agent-configuration.xml and started the the agent with rhq-agent.bat (after uninventory of the platform on the jopr-server). That worked ok and registered the agent without any prompt.

                    Then I exit from agent dosprompt and started rhq-agent-wrapper.bat to start as a service (install , start ). It created the service , started it and then crashed:
                    D:\jopr-agent-2.1.0.GA\bin>rhq-agent-wrapper.bat status
                    Loading script environment from rhq-agent-env.bat...
                    The RHQ Agent [rhqagent-WXP5203] Service is installed.
                    Start Type: Automatic
                    Interactive: No
                    Running: No

                    The service is started as Local System

                    The logfile rhq-agent-wrapper.log shows:
                    STATUS | wrapper | 2009/02/27 15:02:46 | RHQ Agent [rhqagent-WXP5203] installed.
                    STATUS | wrapper | 2009/02/27 15:02:51 | Starting the RHQ Agent [rhqagent-WXP5203] service...
                    STATUS | wrapper | 2009/02/27 15:02:51 | --> Wrapper Started as Service
                    STATUS | wrapper | 2009/02/27 15:02:52 | Launching a JVM...
                    INFO | jvm 1 | 2009/02/27 15:02:52 | Wrapper (Version 3.2.0) http://wrapper.tanukisoftware.org
                    INFO | jvm 1 | 2009/02/27 15:02:52 |
                    INFO | jvm 1 | 2009/02/27 15:02:52 | RHQ 1.1.0.GA (null)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | Failed to start the agent
                    INFO | jvm 1 | 2009/02/27 15:02:53 | java.net.BindException: Cannot assign requested address: JVM_Bind
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at java.net.PlainSocketImpl.socketBind(Native Method)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at java.net.ServerSocket.bind(ServerSocket.java:319)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at java.net.ServerSocket.(ServerSocket.java:185)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:169)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.jboss.remoting.transport.socket.SocketServerInvoker.createServerSocket(SocketServerInvoker.java:264)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.jboss.remoting.transport.socket.SocketServerInvoker.start(SocketServerInvoker.java:193)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.jboss.remoting.transport.Connector.start(Connector.java:322)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.rhq.enterprise.communications.ServiceContainer.setupServerConnector(ServiceContainer.java:1196)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.rhq.enterprise.communications.ServiceContainer.start(ServiceContainer.java:546)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.rhq.enterprise.communications.ServiceContainer.start(ServiceContainer.java:464)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.rhq.enterprise.agent.AgentMain.startCommServices(AgentMain.java:1656)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.rhq.enterprise.agent.AgentMain.start(AgentMain.java:486)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:347)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at java.lang.reflect.Method.invoke(Method.java:585)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:197)
                    INFO | jvm 1 | 2009/02/27 15:02:53 | at java.lang.Thread.run(Thread.java:595)
                    STATUS | wrapper | 2009/02/27 15:02:54 | RHQ Agent [rhqagent-WXP5203] started.
                    STATUS | wrapper | 2009/02/27 15:02:58 | <-- Wrapper Stopped
                    STATUS | wrapper | 2009/02/27 15:03:01 | The RHQ Agent [rhqagent-WXP5203] Service is installed.
                    STATUS | wrapper | 2009/02/27 15:03:01 | Start Type: Automatic
                    STATUS | wrapper | 2009/02/27 15:03:01 | Interactive: No
                    STATUS | wrapper | 2009/02/27 15:03:01 | Running: No

                    I start to think it may have something to do with the JVM (JAVA_HOME=C:\jdk1.5.0_09 ), could that be?

                    Regards,
                    ictkg

                    • 7. Re: Installing JOPR agent as service on windows
                      ICT KG Newbie

                      Hi Mazz And Pilhuhn,

                      I forgot to mention that I cleared out the registry first for the agent and also started with a fresh dir setup, modified the xml file and then started as in my previous message,

                      regards,
                      ictkg

                      • 8. Re: Installing JOPR agent as service on windows
                        Heiko Rupp Master

                        Hi,

                        I still see

                        INFO | jvm 1 | 2009/02/27 15:02:53 | java.net.BindException: Cannot assign requested address: JVM_Bind

                        Can you make absolutely sure no agent is running or anything else on port 16163 ?

                        Also did you specify the correct IP to bind to?

                        Heiko

                        • 9. Re: Installing JOPR agent as service on windows
                          mazz Master

                           

                          INFO | jvm 1 | 2009/02/27 15:02:53 | java.net.BindException: Cannot assign requested address: JVM_Bind


                          Its still not able to bind to the socket properly. This probably has nothing to do with your version of Java.

                          Just to be clear, I want to make sure you understand that the agent's configuration is stored in different places if you run it as your own user account vs. the SYSTEM account.

                          The agent persists its configuration using the Java Preferences API - and on Windows, the Java Preferences API stores the data in the Windows Registry (at least that is how SUN's implementation of the VM works). The agent stores the preferences in the user preferences root - which means it is in a different place in the Registry for different users.

                          So if you run the agent from the command line, that will get its configuration preferences from a different place than if you run the agent as a service as the SYSTEM user. Therefore, if you ran it from the command line and it works, but it doesn't work as a service, that tells me the configuration in the registry for those two users are different. If you ran the agent from the command line with --cleanconfig, that only cleared the config from that users preferences, it does NOT clean the preferences for the SYSTEM user.

                          What I suggest you do is edit your rhq_agent_env.bat file, set RHQ_AGENT_DEBUG to "true" and re-run it. Then go to your agent's log/agent.log file and see if you have any other error messages that might help.

                          What I suspect is happening is you already have configuration persisted by the agent in Java Preferences (in the Registry) and that configuration is bad (e.g. has the wrong port number in it) - and if you already have config, your current agent-configuration.xml is being ignored (so changing it will have no effect until you clear out that persisted config). The log file should be able to tell you if the configuration is already present in preferences (and thus skipping agent configuration.xml). The log will also tell you the full set of configuration settings that are in effect, so you can look there to see if they are all what you expect.

                          • 10. Re: Installing JOPR agent as service on windows
                            ICT KG Newbie

                            Hi,

                            NETSTAT -O shows that port 16163 is not in use, nor does netstat -an

                            still something odd.

                            thanks,
                            ictkg

                            • 11. Re: Installing JOPR agent as service on windows
                              ICT KG Newbie

                              Thanks Mazz,

                              I will turn on DEBUG

                              It will probably after this weekend I will be able to reply again, I'll try to find it this weekend

                              regards,
                              ictkg

                              • 12. Re: Installing JOPR agent as service on windows
                                ICT KG Newbie

                                Hi,

                                thank you for the info and suggestion that the settings in the registry for starting the agent as a system service could be wrong. That seemed to be the case.

                                Before starting I removed the key rhq-agent from HKEY_USERS / S-1-5-18 / Software / JavaSoft / Prefs (S-1-5-18 is the entry for local system in our registry)

                                Before starting the agent as a service, the agent-configuration.xml file needed to be updated. After updating/inserting the following in this agent-configuration.xml file, the agent kept running as a service:

                                <entry key="rhq.agent.configuration-setup-flag" value="true" />
                                
                                <entry key="rhq.agent.name" value="name of agent at JOPR server"/>
                                
                                <entry key="rhq.agent.server.bind-address" value="IP or name of JOPR server " />
                                
                                <entry key="rhq.communications.connector.bind-address" value="IP or name of agent server" />


                                Using then on DOS-cmmand prompt:
                                D:\jopr-agent-2.1.0.GA\bin>rhq-agent-wrapper.bat install
                                D:\jopr-agent-2.1.0.GA\bin>rhq-agent-wrapper.bat start

                                started the agent properly as a server (and kept running).

                                The Jopr server showed the agent up even when the user session logged off.

                                Thank you for your input, suggestions and help.

                                Regards,
                                ictkg


                                • 13. Re: Installing JOPR agent as service on windows
                                  Ramesh Mourthy Newbie

                                  This happens even if i do not register the agent as windows service. Though the service is not running, i still get the same error java.net.BindException: Cannot assign requested address: JVM_Bind. But as suggested i went and deleted the IMQ Agent registration in the windows registry and then i was able to start the agent successfully.

                                  • 14. Re: Installing JOPR agent as service on windows
                                    mazz Master

                                    FYI: the agent will purge its existing preferences (e.g. on Windows, will purge that registry data) if you pass --cleanconfig on the command line. You have to run the agent as the user whose preferences you want to purge (which is a problem if you are trying to purge the preferences of the windows SYSTEM user - that is why, if you are using the agent as a windows service, its easiest just to use regedit to purge the registry entries.