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 {
48 const rsc::misc::UUID&
id,
49 const rsc::misc::UUID& parentId,
51 const std::string& type)
52 : kind(kind), id(id), parentId(parentId), scope(scope), type(type) {
82 return rsc::os::currentProgramName();
83 }
catch (
const std::exception& e) {
84 RSCERROR(logger, boost::str(boost::format(
"tryCurrentProgramName failed: %1%")
86 return "<unknown program>";
92 return rsc::os::currentCommandlineArguments();
93 }
catch (
const std::exception& e) {
94 RSCERROR(logger, boost::str(boost::format(
"tryCurrentCommandlineArguments failed: %1%")
96 return std::vector<std::string>();
102 return rsc::os::currentProcessStartTime();
103 }
catch (
const std::exception& e) {
104 RSCERROR(logger, boost::str(boost::format(
"tryCurrentProcessStartTime failed: %1%")
106 static boost::posix_time::ptime firstCall
107 = boost::posix_time::microsec_clock::universal_time();
114 return rsc::os::currentExecutingUser();
115 }
catch (
const std::exception& e) {
116 RSCERROR(logger, boost::str(boost::format(
"tryCurrentExecutingUser failed: %1%")
123 const std::string& programName,
124 const std::vector<std::string>& arguments,
125 const boost::posix_time::ptime& startTime,
126 const std::string& rsbVersion,
127 const std::string& executingUser)
128 : pid(pid), programName(programName), arguments(arguments),
129 startTime(startTime), rsbVersion(rsbVersion),
130 executingUser(executingUser) {
164 return rsc::os::currentHostId();
165 }
catch (
const std::exception& e) {
166 RSCERROR(logger, boost::str(boost::format(
"tryCurrentHostId failed: %1%")
177 if (softwareType ==
"win32" || softwareType ==
"darwin") {
186 return rsc::os::currentHostname();
187 }
catch (
const std::exception& e) {
188 RSCERROR(logger, boost::str(boost::format(
"tryCurrentHostname failed: %1%")
190 return "<unknown host>";
196 return rsc::os::currentMachineType();
197 }
catch (
const std::exception& e) {
198 RSCERROR(logger, boost::str(boost::format(
"tryCurrentMachineType failed: %1%")
206 return rsc::os::currentMachineVersion();
207 }
catch (
const std::exception& e) {
208 RSCERROR(logger, boost::str(boost::format(
"tryCurrentMachineVersion failed: %1%")
216 return rsc::os::currentSoftwareType();
217 }
catch (
const std::exception& e) {
218 RSCERROR(logger, boost::str(boost::format(
"tryCurrentSoftwareType failed: %1%")
226 return rsc::os::currentSoftwareVersion();
227 }
catch (
const std::exception& e) {
228 RSCERROR(logger, boost::str(boost::format(
"tryCurrentSoftwareVersion failed: %1%")
235 const std::string& hostname,
236 const std::string& machineType,
237 const std::string& machineVersion,
238 const std::string& softwareType,
239 const std::string& softwareVersion)
240 : id(id), hostname(hostname),
241 machineType(machineType), machineVersion(machineVersion),
242 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::string & getProgramName() const
const rsc::misc::UUID & getParentId() const
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.
ParticipantInfo(const std::string &kind, const rsc::misc::UUID &id, const rsc::misc::UUID &parentId, const Scope &scope, const std::string &type)
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