Skip to content

Commit

Permalink
flora-monitor can specify flora uri by command line
Browse files Browse the repository at this point in the history
  • Loading branch information
张晨 authored and 张晨 committed Apr 28, 2019
1 parent 7342eb7 commit af02804
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions monitor/main.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "flora-agent.h"
#include <curses.h>
#include <list>
#include <stdio.h>
#include <string.h>
#include "xmopt.h"
#include "flora-agent.h"

using namespace std;
using namespace flora;
Expand All @@ -13,9 +14,19 @@ static char textBuffer[64];
static const char *COLUMN_HEADER_TEXT[] = {"PID", "NAME"};

typedef struct {
string floraUri{"unix:/var/run/flora.sock"};
} CmdlineArgs;

static bool parseCmdline(int argc, char **argv, CmdlineArgs &res) {
XMOptions options;
if (!options.parse(argc, argv)) {
return false;
}
auto it = options.find(nullptr);
it.next();
auto opt = it.next();
if (opt != nullptr)
res.floraUri = opt->value();
return true;
}

Expand Down Expand Up @@ -117,8 +128,8 @@ static void doMonitor(CmdlineArgs &args) {

Agent agent;
MonitorView monitorView;
agent.config(FLORA_AGENT_CONFIG_URI,
"unix:/var/run/flora.sock#flora-monitor");
string uri = args.floraUri + "#flora-monitor";
agent.config(FLORA_AGENT_CONFIG_URI, uri.c_str());
agent.config(FLORA_AGENT_CONFIG_MONITOR, FLORA_CLI_FLAG_MONITOR,
&monitorView);
agent.start();
Expand Down

0 comments on commit af02804

Please sign in to comment.