Author: tedross
Date: 2009-10-30 13:59:46 -0400 (Fri, 30 Oct 2009)
New Revision: 3686
Modified:
mgmt/trunk/sesame/cpp/src/SysAgent.cpp
Log:
Periodically refresh the system-id information. This handles the case where
the hostname is changed while sesame is running.
Modified: mgmt/trunk/sesame/cpp/src/SysAgent.cpp
===================================================================
--- mgmt/trunk/sesame/cpp/src/SysAgent.cpp 2009-10-26 13:39:17 UTC (rev 3685)
+++ mgmt/trunk/sesame/cpp/src/SysAgent.cpp 2009-10-30 17:59:46 UTC (rev 3686)
@@ -57,14 +57,13 @@
uint32_t swapFree;
};
+ void setSystemId();
void getLoadAverage(LoadAverage& la);
void getMem(Mem& mem);
};
SysAgent::SysAgent(ManagementAgent* _agent, const string& uuidFile) : agent(_agent)
{
- std::string sysname, nodename, release, version, machine;
-
// obtain or establish the system-id
ifstream input(uuidFile.c_str());
if (input.good()) {
@@ -82,17 +81,7 @@
}
mgmtObject = new _qmf::Sysimage(agent, this, uuid);
- qpid::sys::SystemInfo::getSystemId (sysname,
- nodename,
- release,
- version,
- machine);
- mgmtObject->set_osName (sysname);
- mgmtObject->set_nodeName (nodename);
- mgmtObject->set_release (release);
- mgmtObject->set_version (version);
- mgmtObject->set_machine (machine);
-
+ setSystemId();
ifstream distro("/etc/redhat-release");
if (distro.good()) {
char text[256];
@@ -104,6 +93,18 @@
agent->addObject(mgmtObject, 1);
}
+void SysAgent::setSystemId()
+{
+ std::string sysname, nodename, release, version, machine;
+
+ qpid::sys::SystemInfo::getSystemId(sysname, nodename, release, version, machine);
+ mgmtObject->set_osName(sysname);
+ mgmtObject->set_nodeName(nodename);
+ mgmtObject->set_release(release);
+ mgmtObject->set_version(version);
+ mgmtObject->set_machine(machine);
+}
+
void SysAgent::getLoadAverage(LoadAverage& la)
{
ifstream input("/proc/loadavg");
@@ -160,6 +161,7 @@
mgmtObject->set_swapTotal(mem.swapTotal);
for (;;) {
+ setSystemId();
getLoadAverage(la);
getMem(mem);
mgmtObject->set_loadAverage1Min(la.load1Min);
@@ -170,6 +172,8 @@
mgmtObject->set_memFree(mem.memFree);
mgmtObject->set_swapFree(mem.swapFree);
+ mgmtObject->set_memTotal(mem.memTotal);
+ mgmtObject->set_swapTotal(mem.swapTotal);
::sleep(5);
}
}
Show replies by date