/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "utilpvt.h" #include "evhelper.h" using namespace pvxs; namespace { void usage(const char* argv0) { std::cerr<< "Usage:\n" " Discover Servers:\n" " "<\n" "\n" " Server Info:\n" " "<\n" "\n" "Examples:\n" " Monitor server beacons to detect servers coming online, and going offline.\n" " "< Operation timeout in seconds. Default 5 sec. '0' disables timeout,\n" " useful in combination with '-v'.\n" ; } } // namespace int main(int argc, char *argv[]) { try { logger_config_env(); // from $PVXS_LOG double timeout = 5.0; bool verbose = false; bool info = false; bool active = true; { int opt; while ((opt = getopt(argc, argv, "hVApivdw:")) != -1) { switch(opt) { case 'h': usage(argv[0]); return 0; case 'V': std::cout<(optarg); break; default: usage(argv[0]); std::cerr<<"\nUnknown argument: "<> ops; ops.reserve(argc-optind); if(optind==argc) { // discover mode, search of all servers std::set> servprotos; ops.push_back(ctxt.discover([servprotos, verbose](const client::Discovered& serv) mutable { if(verbose) { // print all events and info std::cout< remaining{argc-optind}; for(auto n : range(optind, argc)) { ops.push_back(ctxt.rpc("server") .server(argv[n]) .arg("op", info ? "info" : "channels") .result([argv, n, info, verbose, &remaining, &done](client::Result&& r) { try { auto top(r()); if(info) { std::cout<>()); for(auto& name : channels) { std::cout<0.0) done.wait(timeout); else done.wait(); return 0; }catch(std::exception& e){ std::cerr<