• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

    Monitoring application/daemon in a remote linux machine

    User help
    3
    12
    3732
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      peppemath last edited by

      Ciao,
      my problem is this:
      I would monitor an application/daemon in a remote linux machine: i would launch the commands start, stop, eccc. in the remote machine

      for example if i want to restart snmpd daemon then i must to execute
      "/etc/init.d/snmpd start" in the remote machine

      What could be the ways to achieve this?

      Ciao to everyone!

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler last edited by

        Have you considered Munin?

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • P
          peppemath last edited by

          No, I don't know Munin
          but it is impossible with mango?? :(

          1 Reply Last reply Reply Quote 0
          • M
            mlohbihler last edited by

            It sounds like you're trying to do Linux administration, for which Munin is specifically suited. Mango is more generic. Mango may be able to get commands to the linux box, but you'll need an agent there to receive the command and execute it.

            Best regards,
            Matthew

            1 Reply Last reply Reply Quote 0
            • P
              peppemath last edited by

              How Mango should get commands to linux box?

              1 Reply Last reply Reply Quote 0
              • M
                mlohbihler last edited by

                Use one of the data sources. Something suitable to the agent that will execute the commands on the remote host. The details are up to you.

                Best regards,
                Matthew

                1 Reply Last reply Reply Quote 0
                • P
                  peppemath last edited by

                  Ciao
                  I have created a php script called "processSNMPD"; launching the url http://localhost/processSNMPD.php?oper=xxxx (with xxx=start/stop) with a webbroser, i can start or stop the service.
                  Now, How can i send a HTTP request to server? In the context help (of Http receiver) i found "HTTP sender publisher" but, where is it? how it work? There isn't in the list of data sources types
                  Can you help me?

                  Ciao

                  1 Reply Last reply Reply Quote 0
                  • M
                    mlohbihler last edited by

                    Um, i was kind of expecting that you would review the available data sources to know the possibilities before implementing anything. As it is, you cannot have Mango fire off an arbitrary web request in the manner you are expecting.

                    But this did give me an idea. It's not as straightforward for your needs as you might like, but i believe it will offer a lot of general power. I've added a new "process" event handler, which provides active and inactive "process command" values. "Commands" are basically shell commands. When the event is raised the active command will be executed, and vice versa.

                    A command could be "java -X" (although this wouldn't really be very useful for much), or "wget ...", which would be good for your situation, as long as you're using *nix. This will be available in the next release.

                    Best regards,
                    Matthew

                    1 Reply Last reply Reply Quote 0
                    • N
                      narenblr last edited by

                      This is a great feature to send alerts to external systems.
                      Hope the next release will be soon?

                      1 Reply Last reply Reply Quote 0
                      • N
                        narenblr last edited by

                        Will the alert details be available as a variables to commands to send alerts to external systems? Hope the next release will be soon?

                        1 Reply Last reply Reply Quote 0
                        • P
                          peppemath last edited by

                          Hello everyone,
                          after some testing and considering that I'm new with java
                          to solve my problem I have proceeded as follows:

                          MANGO->proxy->agent

                          a) I created a html control with a button that makes a local call to a proxy java (proxyProcess) by ajax

                          
                          <script language="javascript">
                          <!--
                             var myRequest = null;
                             
                             function CreateXmlHttpReq( handler)
                                          {
                                                    alert("create XmllHttpReq");
                                                    var xmlhttp = null;
                                                    xmlhttp = new XMLHttpRequest();
                                                    xmlhttp.onreadystatechange = handler;
                                                    return xmlhttp;
                                          }
                             function myHandler()
                                          {
                                                  
                                                  if (myRequest.readyState == 4 && myRequest.status == 200)
                                                  {
                                                          alert(myRequest.responseText);
                                                  }
                                          }
                          
                             function sendRequest( operation)
                                          {
                                                  var path = '?process=snmpd&command=' + operation;
                                                  var urlProxy  = 'http://xxx.xxx.xxx.xxx:8080/proxyPROCESS' + path;
                          
                                                  alert("sendRequest to proxy \n" + urlProxy);
                          
                                      try
                                      {
                                              myRequest = CreateXmlHttpReq(myHandler);
                          
                                                  myRequest.open( 'GET', urlProxy, true);
                                                  myRequest.send( null);
                                      }
                                      catch(e)
                                      {
                                            alert(e.message);
                                      }
                          
                                          }
                          -->
                          </script>
                          <input type="button" value="start " onclick="sendRequest('start')" />
                          
                          

                          b) I created a servlet (positioned between the servlet Mango) proxyProcess.class that received the request makes a remote call (http://yyy.yyy.yyy.yyy/provaXMango/PROCESSI/processCommands.php?process = "+ param1 + "& command =" + param2) to the server where I want to execute the command

                          
                          public class proxyPROCESS extends HttpServlet 
                          {
                          	private static final long serialVersionUID = 1L;
                          
                          	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
                          	{
                          		try
                          		{
                          			
                          			String param1 = request.getParameter("process");
                          			String param2 = request.getParameter("command");
                          			URL url = new URL("http://yyy.yyy.yyy.yyy/provaXMango/PROCESSI/processCommands.php?process=" + param1 + "&command=" + param2);
                          			HttpURLConnection conn = (HttpURLConnection)url.openConnection();
                          			
                          			int code = conn.getResponseCode();
                          			
                          			//conn.disconnect();
                          		} 
                          		catch(MalformedURLException ex) 
                          		{
                          			ex.printStackTrace();
                          		} 
                          		catch(IOException ioex) 
                          		{
                          			ioex.printStackTrace();
                          		}
                          
                          		
                          	}
                          
                          }
                          
                          

                          c) I created an php agent on the remote server to run command

                          
                          <?php
                          	 
                          	$availableProcess = array();
                          	getProcess( $availableProcess);
                          	
                          	$qs = $_SERVER['QUERY_STRING'];
                          	$process = $_GET['process'];
                          	$command = $_GET['command'];
                          	
                          	
                          	//comando to execute
                          	$completeCommand = "sudo /etc/init.d/" . $process . " " . $command;
                          	$tmp = exec( $completeCommand, $outputs, $ret_var);	
                          ?>
                          
                          

                          To execute commands with www user with sudo, you need to enable the www user to run the desired command in sudoers, for example

                          
                          apache  yyy.yyy.yyy.yyy=NOPASSWD: /etc/init.d/snmpd
                          
                          

                          Everything works correctly!

                          Probably this is not the optimal solution, but it works!

                          Ciao

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post