简体   繁体   English

编写一个Java程序来远程监视Linux中运行的应用程序

[英]Write a java program to monitor an application running in linux remotely

Dear all, I want a java program which can connect to a remote host that runs on linux os and able to start and stop any application from that remote host. 亲爱的所有人,我想要一个Java程序,该程序可以连接到在linux os上运行的远程主机,并能够从该远程主机启动和停止任何应用程序。 Is it possible to do this task with a java program, with or without any service wrapper! 是否可以使用Java程序(带有或不带有任何服务包装器)来执行此任务!

Check Ant SSHEXEC task. 检查Ant SSHEXEC任务。

link... 链接...

Looks like there's no AntBuilder implementation in Java. 看起来Java中没有AntBuilder实现。 Groovy is the ideal tool for these kind of tasks. Groovy是执行此类任务的理想工具。 You can write a Groovy and access it just like any other class in Java. 您可以编写Groovy并像访问Java中的其他任何类一样对其进行访问。 If you are using NetBeans, then Groovy and Java can co-exist in the same package. 如果您使用的是NetBeans,则Groovy和Java可以共存于同一程序包中。

 def String execute(def cmd, def host, def uname, def pwd)throws Exception {
        def ant = new AntBuilder()
        ant.sshexec(host : host,
            username : uname,
            password : pwd,
            command : "ls -l,
            trust : "true",
            outputproperty : "result")

        return ant.project.properties."result"
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM