41 if (config.
check(
"cmd") && config.
check(
"stdio"))
47 Help(
"SYNTAX ERROR: missing remote stdio server\n");
52 Help(
"SYNTAX ERROR: missing command\n");
57 Help(
"SYNTAX ERROR: missing tag\n");
62 Help(
"SYNTAX ERROR: missing remote server\n");
68 printf(
"*********** %s ************\n", config.
toString().c_str());
76 if (config.
check(
"workdir")) {
79 if (config.
check(
"geometry")) {
82 if (config.
check(
"hold")) {
85 if (config.
check(
"env")) {
88 if (config.
check(
"log")) {
104 if (!response.
size()) {
117 if (config.
check(
"cmd"))
123 Help(
"SYNTAX ERROR: missing command\n");
128 Help(
"SYNTAX ERROR: missing tag\n");
133 Help(
"SYNTAX ERROR: missing remote server\n");
143 if (config.
check(
"workdir")) {
146 if (config.
check(
"log")) {
157 if (config.
check(
"env")) {
163 if (!response.
size()) {
179 if (config.
check(
"kill"))
183 Help(
"SYNTAX ERROR: missing remote server\n");
188 Help(
"SYNTAX ERROR: missing tag\n");
193 Help(
"SYNTAX ERROR: missing signum\n");
205 if (config.
check(
"sigterm"))
209 Help(
"SYNTAX ERROR: missing tag");
214 Help(
"SYNTAX ERROR: missing remote server\n");
225 if (config.
check(
"sigtermall"))
229 Help(
"SYNTAX ERROR: missing remote server\n");
239 if (config.
check(
"ps"))
243 Help(
"SYNTAX ERROR: missing remote server\n");
247 std::vector<processInfo> processes;
254 if (config.
check(
"isrunning"))
258 Help(
"SYNTAX ERROR: missing remote server\n");
264 Help(
"SYNTAX ERROR: missing tag\n");
275 if (config.
check(
"sysinfo"))
279 Help(
"SYNTAX ERROR: missing remote server\n");
287 fprintf(stdout,
"No response. (timeout)\n");
291 fprintf(stdout,
"Platform name : %s\n",
info.platform.name.c_str());
292 fprintf(stdout,
"Platform dist : %s\n",
info.platform.distribution.c_str());
293 fprintf(stdout,
"Platform release : %s\n",
info.platform.release.c_str());
294 fprintf(stdout,
"Platform code : %s\n",
info.platform.codename.c_str());
295 fprintf(stdout,
"Platform kernel : %s\n\n",
info.platform.kernel.c_str());
297 fprintf(stdout,
"User Id : %d\n",
info.user.userID);
298 fprintf(stdout,
"User name : %s\n",
info.user.userName.c_str());
299 fprintf(stdout,
"User real name : %s\n",
info.user.realName.c_str());
300 fprintf(stdout,
"User home dir : %s\n\n",
info.user.homeDir.c_str());
302 fprintf(stdout,
"Cpu load Ins.: %d\n",
info.load.cpuLoadInstant);
303 fprintf(stdout,
"Cpu load 1 : %.2lf\n",
info.load.cpuLoad1);
304 fprintf(stdout,
"Cpu load 5 : %.2lf\n",
info.load.cpuLoad5);
305 fprintf(stdout,
"Cpu load 15 : %.2lf\n\n",
info.load.cpuLoad15);
307 fprintf(stdout,
"Memory total : %dM\n",
info.memory.totalSpace);
308 fprintf(stdout,
"Memory free : %dM\n\n",
info.memory.freeSpace);
310 fprintf(stdout,
"Storage total : %dM\n",
info.storage.totalSpace);
311 fprintf(stdout,
"Storage free : %dM\n\n",
info.storage.freeSpace);
313 fprintf(stdout,
"Processor model : %s\n",
info.processor.model.c_str());
314 fprintf(stdout,
"Processor model num : %d\n",
info.processor.modelNumber);
315 fprintf(stdout,
"Processor family : %d\n",
info.processor.family);
316 fprintf(stdout,
"Processor vendor : %s\n",
info.processor.vendor.c_str());
317 fprintf(stdout,
"Processor arch : %s\n",
info.processor.architecture.c_str());
318 fprintf(stdout,
"Processor cores : %d\n",
info.processor.cores);
319 fprintf(stdout,
"Processor siblings : %d\n",
info.processor.siblings);
320 fprintf(stdout,
"Processor Mhz : %.2lf\n\n",
info.processor.frequency);
322 fprintf(stdout,
"Environment variables :\n%s\n",
info.platform.environmentVars.c_str());
331 if (config.
check(
"which"))
335 Help(
"SYNTAX ERROR: missing remote server\n");
346 if (config.
check(
"exit"))
350 Help(
"SYNTAX ERROR: missing remote server\n");
363void yarp::run::Run::Help(
const char *msg)
365 fprintf(stderr,
"%s", msg);
366 fprintf(stderr,
"\nUSAGE:\n\n");
367 fprintf(stderr,
"yarp run --server SERVERPORT\nrun a server on the local machine\n\n");
368 fprintf(stderr,
"yarp run --on SERVERPORT --as TAG --cmd COMMAND [ARGLIST] [--workdir WORKDIR] [--env ENVIRONMENT]\nrun a command on SERVERPORT server\n\n");
369 fprintf(stderr,
"yarp run --on SERVERPORT --as TAG --stdio STDIOSERVERPORT [--hold] [--geometry WxH+X+Y] --cmd COMMAND [ARGLIST] [--workdir WORKDIR] [--env ENVIRONMENT]\n");
370 fprintf(stderr,
"run a command on SERVERPORT server sending I/O to STDIOSERVERPORT server\n\n");
371 fprintf(stderr,
"yarp run --on SERVERPORT --kill TAG SIGNUM\nsend SIGNUM signal to TAG command\n\n");
372 fprintf(stderr,
"yarp run --on SERVERPORT --sigterm TAG\nterminate TAG command\n\n");
373 fprintf(stderr,
"yarp run --on SERVERPORT --sigtermall\nterminate all commands\n\n");
374 fprintf(stderr,
"yarp run --on SERVERPORT --ps\nreport commands running on SERVERPORT\n\n");
375 fprintf(stderr,
"yarp run --on SERVERPORT --isrunning TAG\nTAG command is running?\n\n");
376 fprintf(stderr,
"yarp run --on SERVERPORT --sysinfo\nreport system information of SERVERPORT\n\n");
377 fprintf(stderr,
"yarp run --on SERVERPORT --exit\nstop SERVERPORT server\n\n");
378 fprintf(stderr,
"yarp run --on SERVERPORT --which\nsearch for path of provided filename\n\n");
399 printf(
":: %s\n", msg.
toString().c_str());
401 response=sendMsg(msg, node);
403 if (!response.
size()) {
424 printf(
":: %s\n", msg.
toString().c_str());
427 if (!port.
open(
"..."))
429 fprintf(stderr,
"RESPONSE:\n=========\n");
430 fprintf(stderr,
"Cannot open port, aborting...\n");
436 fprintf(stderr,
"RESPONSE:\n=========\n");
437 fprintf(stderr,
"Cannot connect to remote server, aborting...\n");
442 RUNLOG(
"<<<port.write(msg, info)")
444 RUNLOG(
">>>port.write(msg, info)")
448 fprintf(stdout,
"RESPONSE:\n=========\n\n");
451 fprintf(stdout,
"No response. (timeout)\n");
467 std::string dest_srv=node;
469 if (command.
check(
"stdio"))
478 if (command.
check(
"geometry"))
486 if (command.
check(
"hold"))
505 printf(
":: %s\n", msg.
toString().c_str());
507 response=sendMsg(msg, dest_srv);
510 snprintf(buff,
sizeof(buff),
"%d", response.
get(0).
asInt32());
511 keyv=std::string(buff);
513 return response.
get(0).
asInt32()>0?
true:
false;
530 printf(
":: %s\n", msg.
toString().c_str());
532 response=sendMsg(msg, node);
534 return response.
get(0).
asString()==
"sigterm OK"?
true:
false;
550 printf(
":: %s\n", msg.
toString().c_str());
552 response=sendMsg(msg, node);
554 return response.
get(0).
asString()==
"sigtermall OK"?
true:
false;
572 printf(
":: %s\n", msg.
toString().c_str());
574 response=sendMsg(msg, node);
576 return response.
get(0).
asString()==
"kill OK"?
true:
false;
591 printf(
":: %s\n", msg.
toString().c_str());
593 response=sendMsg(msg, node);
594 for (
size_t i=0; i<response.
size(); i++)
605 processes.push_back(temp);
624 printf(
":: %s\n", msg.
toString().c_str());
626 response=sendMsg(msg, node);
628 if (!response.
size()) {
648 printf(
":: %s\n", msg.
toString().c_str());
650 response=sendMsg(msg, node);
652 if (!response.
size()) {
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string toString() const override
Return a standard text representation of the content of the object.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
A port that is specialized as an RPC client.
A class to get the system (platform) status such as available memory, storage, CPU load and etc.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::string asString() const
Get string value.
static bool ps(const std::string &node, std::vector< processInfo > &processes)
Get a report of all applications running on a yarprun server.
static bool start(const std::string &node, yarp::os::Property &command, std::string &keyv)
Launch a yarprun server.
static bool sigtermall(const std::string &node)
Terminate all applications running on a yarprun server.
static bool which(const std::string &node, const std::string &keyv)
Display the path of a file on a yarprun server.
static int client(yarp::os::Property &config)
Send a property object to a run server, bundling up all the settings usually specified on the command...
static bool kill(const std::string &node, const std::string &keyv, int s)
Send a SIGNAL to an application running on a yarprun server (Linux only).
static bool isRunning(const std::string &node, const std::string &keyv)
Report if an application is still running on a yarprun server.
static bool sysinfo(const std::string &node, yarp::os::SystemInfo &info)
Get a report of system information of a yarprun server.
static bool sigterm(const std::string &node, const std::string &keyv)
Terminate an application running on a yarprun server.
static bool exit(const std::string &node)
Exit a yarprun server.