29 #include <boost/format.hpp> 31 #include <boost/date_time/posix_time/posix_time.hpp> 33 #include <rsc/logging/Logger.h> 37 rsc::logging::LoggerPtr logger
38 = rsc::logging::Logger::getLogger(
"rsb.introspection");
43 namespace introspection {
47 ParticipantInfo::ParticipantInfo(
const std::string& kind,
48 const rsc::misc::UUID&
id,
49 const rsc::misc::UUID& parentId,
51 const std::string& type,
52 const std::set<std::string>& transportURLs)
53 : kind(kind), id(id), parentId(parentId), scope(scope), type(type),
54 transportURLs(transportURLs) {
89 return rsc::os::currentProgramName();
90 }
catch (
const std::exception& e) {
91 RSCERROR(logger, boost::str(boost::format(
"tryCurrentProgramName failed: %1%")
93 return "<unknown program>";
99 return rsc::os::currentCommandlineArguments();
100 }
catch (
const std::exception& e) {
101 RSCERROR(logger, boost::str(boost::format(
"tryCurrentCommandlineArguments failed: %1%")
103 return std::vector<std::string>();
109 return rsc::os::currentProcessStartTime();
110 }
catch (
const std::exception& e) {
111 RSCERROR(logger, boost::str(boost::format(
"tryCurrentProcessStartTime failed: %1%")
113 static boost::posix_time::ptime firstCall
114 = boost::posix_time::microsec_clock::universal_time();
121 return rsc::os::currentExecutingUser();
122 }
catch (
const std::exception& e) {
123 RSCERROR(logger, boost::str(boost::format(
"tryCurrentExecutingUser failed: %1%")
130 const std::string& programName,
131 const std::vector<std::string>& arguments,
132 const boost::posix_time::ptime& startTime,
133 const std::string& rsbVersion,
134 const std::string& executingUser)
135 : pid(pid), programName(programName), arguments(arguments),
136 startTime(startTime), rsbVersion(rsbVersion),
137 executingUser(executingUser) {
171 return rsc::os::currentHostId();
172 }
catch (
const std::exception& e) {
173 RSCERROR(logger, boost::str(boost::format(
"tryCurrentHostId failed: %1%")
184 if (softwareType ==
"win32" || softwareType ==
"darwin") {
193 return rsc::os::currentHostname();
194 }
catch (
const std::exception& e) {
195 RSCERROR(logger, boost::str(boost::format(
"tryCurrentHostname failed: %1%")
197 return "<unknown host>";
203 return rsc::os::currentMachineType();
204 }
catch (
const std::exception& e) {
205 RSCERROR(logger, boost::str(boost::format(
"tryCurrentMachineType failed: %1%")
213 return rsc::os::currentMachineVersion();
214 }
catch (
const std::exception& e) {
215 RSCERROR(logger, boost::str(boost::format(
"tryCurrentMachineVersion failed: %1%")
223 return rsc::os::currentSoftwareType();
224 }
catch (
const std::exception& e) {
225 RSCERROR(logger, boost::str(boost::format(
"tryCurrentSoftwareType failed: %1%")
233 return rsc::os::currentSoftwareVersion();
234 }
catch (
const std::exception& e) {
235 RSCERROR(logger, boost::str(boost::format(
"tryCurrentSoftwareVersion failed: %1%")
242 const std::string& hostname,
243 const std::string& machineType,
244 const std::string& machineVersion,
245 const std::string& softwareType,
246 const std::string& softwareVersion)
247 : id(id), hostname(hostname),
248 machineType(machineType), machineVersion(machineVersion),
249 softwareType(softwareType), softwareVersion(softwareVersion) {
unsigned int getPid() const
boost::posix_time::ptime tryCurrentProcessStartTime()
const std::string & getMachineType() const
HostInfo(const std::string &id=currentCompatibleHostId(), const std::string &hostname=tryCurrentHostname(), const std::string &machineType=tryCurrentMachineType(), const std::string &machineVersion=tryCurrentMachineVersion(), const std::string &softwareType=tryCurrentSoftwareType(), const std::string &softwareVersion=tryCurrentSoftwareVersion())
std::string softwareVersion
boost::posix_time::ptime startTime
const std::string & getKind() const
std::string tryCurrentMachineType()
std::vector< std::string > arguments
std::string executingUser
std::string tryCurrentExecutingUser()
std::string currentCompatibleHostId()
const std::string & getHostname() const
const std::string & getType() const
std::string tryCurrentSoftwareVersion()
const std::set< std::string > & getTransportURLs() const
const std::string & getProgramName() const
const rsc::misc::UUID & getParentId() const
std::set< std::string > transportURLs
const std::string & getSoftwareType() const
std::vector< std::string > tryCurrentCommandlineArguments()
const std::vector< std::string > & getArguments() const
const std::string & getRSBVersion() const
const std::string & getExecutingUser() const
const std::string & getMachineVersion() const
const Scope & getScope() const
std::string tryCurrentMachineVersion()
std::string tryCurrentHostId()
const std::string & getSoftwareVersion() const
virtual ~ParticipantInfo()
const std::string & getId() const
std::string machineVersion
std::string tryCurrentSoftwareType()
std::string tryCurrentProgramName()
Scope is a descriptor for a hierarchical channel of the unified bus.
const boost::posix_time::ptime & getStartTime() const
ProcessInfo(unsigned int pid=rsc::os::currentProcessId(), const std::string &programName=tryCurrentProgramName(), const std::vector< std::string > &arguments=tryCurrentCommandlineArguments(), const boost::posix_time::ptime &startTime=tryCurrentProcessStartTime(), const std::string &rsbVersion=rsb::Version::string()+"-"+rsb::Version::buildId(), const std::string &executingUser=tryCurrentExecutingUser())
std::string tryCurrentHostname()
const rsc::misc::UUID & getId() const