Monitoring application/daemon in a remote linux machine
-
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 machinefor example if i want to restart snmpd daemon then i must to execute
"/etc/init.d/snmpd start" in the remote machineWhat could be the ways to achieve this?
Ciao to everyone!
-
Have you considered Munin?
-
No, I don't know Munin
but it is impossible with mango?? :( -
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.
-
How Mango should get commands to linux box?
-
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.
-
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
-
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.
-
This is a great feature to send alerts to external systems.
Hope the next release will be soon? -
Will the alert details be available as a variables to commands to send alerts to external systems? Hope the next release will be soon?
-
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