Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
libagentcore.so
plugins/
libagentcore.a
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Authors ordered by first contribution:
- Julie Stalley (https://github.com/stalleyj)
- Richard Lau (https://github.com/richardlau)
- Gibson Fahnestock (https://github.com/gibfahn)
- Abdirahim Musse (https://github.com/ab-m)

27 changes: 23 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@
],
"conditions": [
['OS=="aix"', {
"defines": [ "_AIX", "AIX" ],
"libraries": [ "-Wl,-bexpall,-brtllib,-G,-bernotok,-brtl,-L.,-bnoipath" ],
'variables': {
'os_name': '<!(uname -s)',
},
'conditions': [
[ '"<(os_name)"=="AIX"', {
"defines": [ "_AIX", "AIX" ],
"libraries": [ "-Wl,-bexpall,-brtllib,-G,-bernotok,-brtl,-L.,-bnoipath" ]
}],
[ '"<(os_name)"=="OS400"', {
'ldflags': [
'-Wl,-brtl,-bnoquiet,-bnoipath,-blibpath:/QOpenSys/pkgs/lib:/QOpenSys/usr/lib'
]
}]
]
}],
['OS=="mac"', {
"defines": [ "__MACH__", "__APPLE__", ],
Expand Down Expand Up @@ -164,8 +176,15 @@
"libraries": [ "Pdh" ],
}],
['OS=="aix"', {
"libraries": [ "-lperfstat" ],
}],
'variables': {
'os_name': '<!(uname -s)',
},
'conditions': [
[ '"<(os_name)"=="AIX"', {
"libraries": [ "-lperfstat" ]
}]
]
}]
],
},
{
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.paho.mqtt.c/src/MQTTAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ START_TIME_TYPE MQTTAsync_start_clock(void)
{
return GetTickCount();
}
#elif defined(AIX)
#elif defined(_AIX)
#define START_TIME_TYPE struct timespec
START_TIME_TYPE MQTTAsync_start_clock(void)
{
Expand All @@ -186,7 +186,7 @@ long MQTTAsync_elapsed(DWORD milliseconds)
{
return GetTickCount() - milliseconds;
}
#elif defined(AIX)
#elif defined(_AIX)
#define assert(a)
long MQTTAsync_elapsed(struct timespec start)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ibmras/common/util/LibraryUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::string LibraryUtils::getLibraryLocation(const void* func) {
std::string path;

#if defined (WINDOWS)
#elif defined(AIX)
#elif defined(_AIX)
#elif defined(_ZOS)
#else
Dl_info dlInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/ibmras/common/util/sysUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <Psapi.h>
#elif defined(LINUX) || defined(__MACH__) || defined(__APPLE__)
#include <sys/time.h>
#elif defined(AIX)
#elif defined(_AIX)
#include <sys/time.h>
#elif defined(_ZOS)
#include <sys/time.h>
Expand Down
37 changes: 35 additions & 2 deletions src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
#include <sstream>
#include <fstream>
#include <cstring>
#if defined(_AIX)
#if defined(_AIX) && !defined(__PASE__)
#include <unistd.h>
#include <libperfstat.h>
#endif
#if defined(__PASE__)
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif
#if defined(__MACH__) || defined(__APPLE__)
#include <sys/time.h>
#include <stdio.h>
Expand Down Expand Up @@ -306,7 +311,7 @@ struct CPUTime* CpuPlugin::getCPUTime() {

aCF.logMessage(debug, ">>>CpuPlugin::getCPUTime");

#if defined(_AIX)
#if defined(_AIX) && !defined(__PASE__)
static const uint32 NS_PER_CPU_TICK = 10000000;
static const uint32 NS_PER_MS = 1000000;
struct CPUTime* cputime = new CPUTime;
Expand Down Expand Up @@ -426,6 +431,34 @@ struct CPUTime* CpuPlugin::getCPUTime() {
}

return cputime;
#elif defined(__PASE__)
struct CPUTime* cputime = new CPUTime;
struct rusage usage;
//microseconds->nanoseconds
uint64 nsStart = time_microseconds() *1000;
if (getrusage(RUSAGE_SELF, &usage) < 0){
std::stringstream errorss;
errorss << "[env_os] Could not get process cpu time, error: ";
errorss << strerror(errno);
aCF.logMessage(warning, errorss.str().c_str());
}
//microseconds->nanoseconds
uint64 nsEnd = time_microseconds() *1000;

//seconds->microsecond
uint64 userTimeSec = static_cast<uint64>(usage.ru_utime.tv_sec * 1000000);
uint64 userTimeMs = static_cast<uint64>(usage.ru_utime.tv_usec);

//seconds->microsecond
uint64 sysTimeSec = static_cast<uint64>(usage.ru_stime.tv_sec * 1000000);
uint64 sysTimeMs = static_cast<uint64>(usage.ru_stime.tv_usec);

//microseconds->nanoseconds
cputime->process = ((userTimeSec + userTimeMs + sysTimeSec + sysTimeMs) *1000);
cputime->time = nsStart + ((nsEnd - nsStart) /2);
//TODO: figure out how to get global cpu time, For now place hold with 1.
cputime->total = uint64(1);
return cputime;
#else
return NULL;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
#include <sys/sysinfo.h> // get_nprocs()
#include <unistd.h> // gethostname()
#include <procinfo.h>
#if defined(__PASE__)
//on PASE procinfo.h does not declare getargs()
extern "C"{
extern int getargs(void *, int, char *, int);
}
#endif
#include <sys/types.h>
#endif

Expand Down
22 changes: 16 additions & 6 deletions src/ibmras/monitoring/plugins/common/memory/MemoryPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#pragma comment(lib, "psapi.lib")
#endif

#if defined(AIXPPC)
#if defined(_AIX)
#include <unistd.h>
#include <alloca.h>
#include <procinfo.h>
Expand Down Expand Up @@ -315,7 +315,7 @@ int64 MemoryPlugin::getProcessPhysicalMemorySize() {
size_t size = t_info.resident_size;
return size;

#elif defined(AIXPPC)
#elif defined(_AIX)
/*
* There is no API on AIX to get the rss of the shared memory used by this process.
* If such an API was available, this function should return the following:
Expand Down Expand Up @@ -367,7 +367,7 @@ int64 MemoryPlugin::getProcessPrivateMemorySize() {
}
}
#undef SHARED_FIELD_INDEX
#elif defined(AIXPPC)
#elif defined(_AIX)
struct procentry64 pe;
pid_t pid = getpid();

Expand Down Expand Up @@ -416,7 +416,7 @@ int64 MemoryPlugin::getProcessVirtualMemorySize() {
task_info(current_task(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
size_t size = t_info.virtual_size;
return size;
#elif defined(AIXPPC)
#elif defined(_AIX)
/* There is no API on AIX to get shared memory usage for the process. If such an
* API existed, we could return getProcessPrivateMemorySize() + sharedSize here.
*
Expand Down Expand Up @@ -459,7 +459,7 @@ int64 MemoryPlugin::getFreePhysicalMemorySize() {
}
return vm_stat.free_count*pageSize;

#elif defined(AIXPPC)
#elif defined(_AIX) && !defined(__PASE__)
/* NOTE: This works on AIX 5.3 and later. */
IDATA numPageSizes = vmgetinfo(NULL, VMINFO_GETPSIZES, 0);

Expand Down Expand Up @@ -496,13 +496,18 @@ int64 MemoryPlugin::getFreePhysicalMemorySize() {
return statex.ullAvailPhys;
}
return -1;
#elif defined (__PASE__)
//TODO: Working on PASE Implementation
//AIXPPC implementation fails on PASE ...
// ...@ line 482 size never gets changed therefore -1 is returned
return -1;
#else
return -1;
#endif
}

int64 MemoryPlugin::getTotalPhysicalMemorySize() {
#if defined (_AIX)
#if defined (_AIX) && !defined(__PASE__)
return (int64)(sysconf(_SC_AIX_REALMEM) * 1024);

#elif defined(_LINUX) ||defined(__MACH__)&&defined(_SC_PAGESIZE)&&defined(_SC_PHYS_PAGES) ||defined(__APPLE__)&&defined(_SC_PAGESIZE)&&defined(_SC_PHYS_PAGES)
Expand Down Expand Up @@ -558,6 +563,11 @@ int64 MemoryPlugin::getTotalPhysicalMemorySize() {
#elif defined(_S390)
/* Get_Physical_Memory returns "SIZE OF ACTUAL REAL STORAGE ONLINE IN 'K'" */
return Get_Physical_Memory() * 1024;
#elif defined (__PASE__)
//TODO: Working on PASE implementation.
//AIX implementation: sysconf(_SC_AIX_REALMEM) returns -1
//errno is set to 109 Function not implemented POSIX
return -1;
#else
return -1;
#endif
Expand Down