C#:查询 FlexLM 许可证管理器

发布于 2024-07-26 12:11:05 字数 103 浏览 2 评论 0原文

有人有查询 FlexLM 的经验吗? (至少)我需要能够判断许可证是否可用于特定应用程序。 以前这是通过检查正在运行的进程来完成的,但如果我可以以某种方式查询 FlexLM,那就更优雅了!

Does anyone have any experience querying FlexLM? (At a minimum) I need to be able to tell if a license is available for a particular application. Previously this was done by checking what processes were running, but if I can somehow query FlexLM, that would be more elegant!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞄了个咪的 2024-08-02 12:11:05

我最近做过这个。 我需要查询 FlexLM 许可证服务器,并发现哪些许可证未完成/可用。 我没有为此找到合理的 API,所以我只是启动 lmutil,要求它查询服务器,并费力地解析文本结果。 虽然很痛苦,但确实有效,而且组装起来确实没花那么长时间。

找到 lmutil.exe 的副本,然后使用 -a 或 -i 开关运行它,具体取决于您要收集的数据。 使用 -c 开关将您希望查询的服务器和端口传递给它。 是的,您需要知道 FlexLM 守护程序运行的端口。 有一个标准端口,但没有什么强制它仅在该端口上运行。

由于我需要定期运行它,并且需要查询数千个守护进程,因此我从应用程序驱动 lmutil - 类似于:

string portAtHost = "[email protected]";
string args = String.Format("lmstat -c {0} -a -i", portAtHost);
ProcessStartInfo info = new ProcessStartInfo(@"lmutil.exe", args);
info.WindowStyle = ProcessWindowStyle.Hidden;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;

using (Process p = Process.Start(info))
{
    string output = p.StandardOutput.ReadToEnd();

    // standard output must be read first; wait max 5 minutes
    if (p.WaitForExit(300000))
    {
        p.WaitForExit(); // per MSDN guidance: Process.WaitForExit Method 
    }
    else
    {
        // kill the lmstat instance and move on
        log.Warn("lmstat did not exit within timeout period; killing");
        p.Kill();
        p.WaitForExit(); // Process.Kill() is asynchronous; wait for forced quit
    }   
    File.WriteAllText("c:\file.lmout", output);
}

...然后您需要解析结果。 根据您要查找的内容,这可能就像通过空格字符分割结果行一样简单。

I've done this recently. I needed to query FlexLM license servers, and discover what licenses were outstanding/available. I didn't find a reasonable API for this, so I instead just launched lmutil, asked it to query the server, and parsed laboriously through the textual results. A pain, but it worked, and really didn't take that long to put together.

Find your copy of lmutil.exe, and run it with either the -a or -i switch, depending on the data you want to gather. Pass it the server and port you wish you query, with the -c switch. Yes, you will need to know the port the FlexLM daemon's running on. There's a standard port, but there's nothing forcing it to run on that port only.

Since I needed to run this regularly, and I needed to query thousands of daemons, I drove lmutil from an application - something like:

string portAtHost = "[email protected]";
string args = String.Format("lmstat -c {0} -a -i", portAtHost);
ProcessStartInfo info = new ProcessStartInfo(@"lmutil.exe", args);
info.WindowStyle = ProcessWindowStyle.Hidden;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;

using (Process p = Process.Start(info))
{
    string output = p.StandardOutput.ReadToEnd();

    // standard output must be read first; wait max 5 minutes
    if (p.WaitForExit(300000))
    {
        p.WaitForExit(); // per MSDN guidance: Process.WaitForExit Method 
    }
    else
    {
        // kill the lmstat instance and move on
        log.Warn("lmstat did not exit within timeout period; killing");
        p.Kill();
        p.WaitForExit(); // Process.Kill() is asynchronous; wait for forced quit
    }   
    File.WriteAllText("c:\file.lmout", output);
}

...then you need to parse through the results. Depending what you're looking for, this could be as simple as splitting the result lines over space characters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文