As part of changing the load averages APIs, this patch changes just that one piece of functionality. All other new APIs will be provided in followup patches.
Signed-off-by: Darryl L. Pierce dpierce@redhat.com --- src/Makefile.am | 16 ++++++------ src/host.cpp | 11 ++------ src/host.h | 2 +- src/main.cpp | 4 +- src/qmf/hostagent.cpp | 11 ++++++-- src/qmf/hostagent.h | 4 +- src/schema.xml | 65 +++++++++++++++++++++++++++---------------------- 7 files changed, 60 insertions(+), 53 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am index 6182fb1..daddf9d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,12 +10,12 @@ AM_CXXFLAGS = $(INCLUDES) sbin_PROGRAMS = matahari
generated_file_list = \ - qmf/com/redhat/matahari/EventHeartbeat.cpp \ - qmf/com/redhat/matahari/EventHeartbeat.h \ - qmf/com/redhat/matahari/Host.cpp \ - qmf/com/redhat/matahari/Host.h \ - qmf/com/redhat/matahari/Package.cpp \ - qmf/com/redhat/matahari/Package.h + qmf/com/redhat/matahari/host/EventHeartbeat.cpp \ + qmf/com/redhat/matahari/host/EventHeartbeat.h \ + qmf/com/redhat/matahari/host/Host.cpp \ + qmf/com/redhat/matahari/host/Host.h \ + qmf/com/redhat/matahari/host/Package.cpp \ + qmf/com/redhat/matahari/host/Package.h
nodist_matahari_SOURCES = $(generated_file_list) config.h
@@ -30,8 +30,8 @@ matahari_SOURCES = \ $(generated_file_list): schema.xml qmf-gen -o ./qmf ./schema.xml
-BUILT_SOURCES = $(generated_file_list) $(first) -CLEANFILES = $(generated_file_list) $(first) +BUILT_SOURCES = $(generated_file_list) +CLEANFILES = $(generated_file_list)
matahari_CPPFLAGS = -fno-strict-aliasing matahari_LDADD = -lpcre -lqmf -lqpidclient -lqpidcommon -ludev -lvirt diff --git a/src/host.cpp b/src/host.cpp index 0b991fc..8b6cd6f 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -287,21 +287,16 @@ host_get_number_of_cpu_cores() return cores; }
-double -host_get_load_average() +void +host_get_load_averages(double& one, double& five, double& fifteen) { - double result = 0.0; - #ifdef __linux__ - double load_average; ifstream input;
input.open("/proc/loadavg", ios::in); - input >> result; + input >> one >> five >> fifteen; input.close(); #endif - - return result; }
void diff --git a/src/host.h b/src/host.h index dab88ad..c9e97b2 100644 --- a/src/host.h +++ b/src/host.h @@ -47,7 +47,7 @@ string host_get_cpu_model();
unsigned int host_get_number_of_cpu_cores();
-double host_get_load_average(); +void host_get_load_averages(double& one, double& five, double& fifteen);
void host_identify(const unsigned int iterations);
diff --git a/src/main.cpp b/src/main.cpp index 27b2434..f7d6329 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,12 +36,12 @@
#include "qmf/hostagent.h"
-#include "qmf/com/redhat/matahari/Package.h" +#include "qmf/com/redhat/matahari/host/Package.h"
using namespace qpid::management; using namespace qpid::client; using namespace std; -namespace _qmf = qmf::com::redhat::matahari; +namespace _qmf = qmf::com::redhat::matahari::host;
// Global Variables ManagementAgent::Singleton* singleton; diff --git a/src/qmf/hostagent.cpp b/src/qmf/hostagent.cpp index 94004d5..cd6d0e6 100644 --- a/src/qmf/hostagent.cpp +++ b/src/qmf/hostagent.cpp @@ -21,7 +21,7 @@ #include "hostagent.h" #include <qpid/agent/ManagementAgent.h>
-#include "qmf/com/redhat/matahari/EventHeartbeat.h" +#include "qmf/com/redhat/matahari/host/EventHeartbeat.h"
HostAgent::HostAgent() { @@ -45,7 +45,6 @@ HostAgent::setup(ManagementAgent* agent) _management_object->set_hypervisor(host_get_hypervisor()); _management_object->set_arch(host_get_architecture()); _management_object->set_memory(host_get_memory()); - _management_object->set_beeping(false);
_management_object->set_cpu_model(host_get_cpu_model()); _management_object->set_cpu_cores(host_get_number_of_cpu_cores()); @@ -76,5 +75,11 @@ HostAgent::heartbeat(unsigned long timestamp, unsigned int sequence) void HostAgent::updated() { - _management_object->set_load_average(host_get_load_average()); + // update the load averages + double one, five, fifteen; + + host_get_load_averages(one, five, fifteen); + _management_object->set_load_average_1(one); + _management_object->set_load_average_5(five); + _management_object->set_load_average_15(fifteen); } diff --git a/src/qmf/hostagent.h b/src/qmf/hostagent.h index 7f7bbaa..d1f3bc1 100644 --- a/src/qmf/hostagent.h +++ b/src/qmf/hostagent.h @@ -26,12 +26,12 @@ #include "host.h" #include "hostlistener.h"
-#include "qmf/com/redhat/matahari/Host.h" +#include "qmf/com/redhat/matahari/host/Host.h"
using namespace qpid::management; using namespace std;
-namespace _qmf = qmf::com::redhat::matahari; +namespace _qmf = qmf::com::redhat::matahari::host;
class HostAgent : public Manageable, public HostListener { diff --git a/src/schema.xml b/src/schema.xml index 20fd9bc..7a223f9 100644 --- a/src/schema.xml +++ b/src/schema.xml @@ -1,31 +1,38 @@ -<schema package="com.redhat.matahari"> - - <class name="Host"> - - <!-- general properties --> - <property name="uuid" type="sstr" access="RO" desc="Host UUID" index="y"/> - <property name="hostname" type="sstr" access="RO" desc="Hostname"/> - <property name="memory" type="int64" access="RO" desc="Amount of primary memory for host (kb)" unit="kb"/> - <property name="hypervisor" type="sstr" access="RO" desc="Hypervisor used by host"/> - <property name="arch" type="sstr" access="RO" desc="Architecture of host"/> - <property name="beeping" type="bool" access="RW" desc="speaker beep loop active? (used to identify host)"/> - - <!-- CPU properties --> - <property name="cpu_model" type="lstr" access="RO" desc="The process model description." /> - <property name="cpu_cores" type="uint8" access="RO" desc="The number of processor cores." /> - <statistic name="load_average" type="double" desc="The current processing load average." /> - - <!-- APIs --> - <method name="shutdown" desc="Shutdown node" /> - <method name="reboot" desc="Reboot node" /> - - </class> - - <eventArguments> - <arg name="timestamp" type="absTime" /> - <arg name="sequence" type="uint32" /> - </eventArguments> - - <event name="heartbeat" args="timestamp,sequence" /> +<schema package="com.redhat.matahari.host"> + + <class name="Host"> + <!-- properties --> + <property name="uuid" type="sstr" access="RO" desc="Host UUID" index="y" /> + <property name="hostname" type="sstr" access="RO" desc="Hostname" /> + <property name="is_virtual" type="bool" access="RO" desc="Is this machine virtual?" /> + <property name="operating_system" type="sstr" access="RO" desc="The installed operating system." /> + <property name="memory" type="int64" access="RO" desc="Amount of primary memory for host (kb)" unit="kb" /> + <property name="arch" type="sstr" access="RO" desc="Architecture of host" /> + <property name="hypervisor" type="sstr" access="RO" desc="Hypervisor used by host" /> + <property name="platform" type="sstr" access="RO" desc="The wordsize for the host." /> + <property name="cpu_model" type="lstr" access="RO" desc="The process model description." /> + <property name="cpu_count" type="uint8" access="RO" desc="The number of physical CPUs." /> + <property name="cpu_cores" type="uint8" access="RO" desc="The total number of processor cores." /> + + <!-- statistics --> + <statistic name="last_updated" type="absTime" desc="The last time a heartbeat occurred." /> + <statistic name="load_average_1" type="double" desc="The one minute load average." /> + <statistic name="load_average_5" type="double" desc="The five minute load average." /> + <statistic name="load_average_15" type="double" desc="The fiften minute load average" /> + + <!-- APIs --> + <method name="list_network_interfaces" desc="Returns the list of all network interfaces." /> + <method name="identify" desc="Tells the host to beep its pc speaker." /> + <method name="shutdown" desc="Shutdown node" /> + <method name="reboot" desc="Reboot node" /> + + </class> + + <eventArguments> + <arg name="timestamp" type="absTime" /> + <arg name="sequence" type="uint32" /> + </eventArguments> + + <event name="heartbeat" args="timestamp,sequence" />
</schema>