如何检查rpc应用程序是否在linux系统中运行 [英] How to check if a rpc application is running in linux system
问题描述
亲爱的专家,
我在Linux上运行了一个wpf应用程序和一个RPC应用程序(应用程序名称MyRemoteApp,它是用C#开发的,使用mod mono)系统。
我想检查我的wpf应用程序是否正在运行远程过程调用应用程序。
以下是我的代码。
Dear Experts,
I''ve a wpf application and a RPC appliation (Application Name MyRemoteApp and it is developed in C# using mod mono) running in Linux system.
I want to check in my wpf application if thre Remote Procedure call application is running or not.
Below is my code.
public static bool CheckIfRemoteAppIsRunning()
{
bool bRetVal = false;
string remoteSystem = "10.221.55.127";
string procSearch = "MyRemoteApp";
Process[] proc = System.Diagnostics.Process.GetProcessesByName(procSearch, remoteSystem);
if (proc.Length > 0)
{
bRetVal = true;
Console.WriteLine("Able to find: " + proc[0]);
}
else
{
Console.WriteLine("Unable to find: " + procSearch);
}
return bRetVal;
}
但它的抛出异常无法连接到远程机器。。
请告诉我代码中的错误。
问候,
Vidi
But its throwing exception "Couldn''t connect to remote machine.".
Please let me know whats the wrong in the code.
Regards,
Vidi
推荐答案
你好,
如果查看Process类的MSDN文档,你会发现支持GetProcessByName仅适用于以下平台。
Hello,
If you look at MSDN documentation for Process class you will realize that the GetProcessByName is supported for following platforms only.
Windows 8,Windows Server 2012,Windows 7,Windows Vista SP2,Windows Server 2008(不支持服务器核心角色),Windows Server 2008 R2(支持服务器核心角色) SP1或更高版本;不支持Itanium)
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
对于Unix / Linux,您可以使用SSH然后使用
For Unix/Linux you can use SSH and then use
ps -Af | grep "YOUR PROCESS NAME"
此命令返回的输出很容易。典型输出如下所示。
The output returned by this command is easily. The typical output is shown below.
UID PID PPID C STIME TTY TIME CMD
hope 29197 18961 0 Sep27 ? 00:00:06 sshd: hope@pts/87
hope 32097 29197 0 Sep27 pts/87 00:00:00 -csh
hope 7209 32097 0 12:17 pts/87 00:00:00 ps -Af
mysql 18617 18581 0 Jan10 ? 05:36:19 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=my
您可以使用SharpSSH [为此目的^ ]库。
问候,
You can use SharpSSH[^] library for this purpose.
Regards,
这篇关于如何检查rpc应用程序是否在linux系统中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!