Skip to content

Commit 85cab6a

Browse files
abmussesjanuary
authored andcommitted
Added support for PASE installs (#69)
1 parent 3401231 commit 85cab6a

File tree

9 files changed

+86
-16
lines changed

9 files changed

+86
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/
22
libagentcore.so
33
plugins/
4+
libagentcore.a

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Authors ordered by first contribution:
1010
- Julie Stalley (https://github.com/stalleyj)
1111
- Richard Lau (https://github.com/richardlau)
1212
- Gibson Fahnestock (https://github.com/gibfahn)
13+
- Abdirahim Musse (https://github.com/ab-m)
1314

binding.gyp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,20 @@
4343
],
4444
"conditions": [
4545
['OS=="aix"', {
46-
"defines": [ "_AIX", "AIX" ],
47-
"libraries": [ "-Wl,-bexpall,-brtllib,-G,-bernotok,-brtl,-L.,-bnoipath" ],
46+
'variables': {
47+
'os_name': '<!(uname -s)',
48+
},
49+
'conditions': [
50+
[ '"<(os_name)"=="AIX"', {
51+
"defines": [ "_AIX", "AIX" ],
52+
"libraries": [ "-Wl,-bexpall,-brtllib,-G,-bernotok,-brtl,-L.,-bnoipath" ]
53+
}],
54+
[ '"<(os_name)"=="OS400"', {
55+
'ldflags': [
56+
'-Wl,-brtl,-bnoquiet,-bnoipath,-blibpath:/QOpenSys/pkgs/lib:/QOpenSys/usr/lib'
57+
]
58+
}]
59+
]
4860
}],
4961
['OS=="mac"', {
5062
"defines": [ "__MACH__", "__APPLE__", ],
@@ -164,8 +176,15 @@
164176
"libraries": [ "Pdh" ],
165177
}],
166178
['OS=="aix"', {
167-
"libraries": [ "-lperfstat" ],
168-
}],
179+
'variables': {
180+
'os_name': '<!(uname -s)',
181+
},
182+
'conditions': [
183+
[ '"<(os_name)"=="AIX"', {
184+
"libraries": [ "-lperfstat" ]
185+
}]
186+
]
187+
}]
169188
],
170189
},
171190
{

org.eclipse.paho.mqtt.c/src/MQTTAsync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ START_TIME_TYPE MQTTAsync_start_clock(void)
162162
{
163163
return GetTickCount();
164164
}
165-
#elif defined(AIX)
165+
#elif defined(_AIX)
166166
#define START_TIME_TYPE struct timespec
167167
START_TIME_TYPE MQTTAsync_start_clock(void)
168168
{
@@ -186,7 +186,7 @@ long MQTTAsync_elapsed(DWORD milliseconds)
186186
{
187187
return GetTickCount() - milliseconds;
188188
}
189-
#elif defined(AIX)
189+
#elif defined(_AIX)
190190
#define assert(a)
191191
long MQTTAsync_elapsed(struct timespec start)
192192
{

src/ibmras/common/util/LibraryUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ std::string LibraryUtils::getLibraryLocation(const void* func) {
8383
std::string path;
8484

8585
#if defined (WINDOWS)
86-
#elif defined(AIX)
86+
#elif defined(_AIX)
8787
#elif defined(_ZOS)
8888
#else
8989
Dl_info dlInfo;

src/ibmras/common/util/sysUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <Psapi.h>
2727
#elif defined(LINUX) || defined(__MACH__) || defined(__APPLE__)
2828
#include <sys/time.h>
29-
#elif defined(AIX)
29+
#elif defined(_AIX)
3030
#include <sys/time.h>
3131
#elif defined(_ZOS)
3232
#include <sys/time.h>

src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
2424
#include <sstream>
2525
#include <fstream>
2626
#include <cstring>
27-
#if defined(_AIX)
27+
#if defined(_AIX) && !defined(__PASE__)
2828
#include <unistd.h>
2929
#include <libperfstat.h>
3030
#endif
31+
#if defined(__PASE__)
32+
#include <unistd.h>
33+
#include <sys/time.h>
34+
#include <sys/resource.h>
35+
#endif
3136
#if defined(__MACH__) || defined(__APPLE__)
3237
#include <sys/time.h>
3338
#include <stdio.h>
@@ -306,7 +311,7 @@ struct CPUTime* CpuPlugin::getCPUTime() {
306311

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

309-
#if defined(_AIX)
314+
#if defined(_AIX) && !defined(__PASE__)
310315
static const uint32 NS_PER_CPU_TICK = 10000000;
311316
static const uint32 NS_PER_MS = 1000000;
312317
struct CPUTime* cputime = new CPUTime;
@@ -426,6 +431,34 @@ struct CPUTime* CpuPlugin::getCPUTime() {
426431
}
427432

428433
return cputime;
434+
#elif defined(__PASE__)
435+
struct CPUTime* cputime = new CPUTime;
436+
struct rusage usage;
437+
//microseconds->nanoseconds
438+
uint64 nsStart = time_microseconds() *1000;
439+
if (getrusage(RUSAGE_SELF, &usage) < 0){
440+
std::stringstream errorss;
441+
errorss << "[env_os] Could not get process cpu time, error: ";
442+
errorss << strerror(errno);
443+
aCF.logMessage(warning, errorss.str().c_str());
444+
}
445+
//microseconds->nanoseconds
446+
uint64 nsEnd = time_microseconds() *1000;
447+
448+
//seconds->microsecond
449+
uint64 userTimeSec = static_cast<uint64>(usage.ru_utime.tv_sec * 1000000);
450+
uint64 userTimeMs = static_cast<uint64>(usage.ru_utime.tv_usec);
451+
452+
//seconds->microsecond
453+
uint64 sysTimeSec = static_cast<uint64>(usage.ru_stime.tv_sec * 1000000);
454+
uint64 sysTimeMs = static_cast<uint64>(usage.ru_stime.tv_usec);
455+
456+
//microseconds->nanoseconds
457+
cputime->process = ((userTimeSec + userTimeMs + sysTimeSec + sysTimeMs) *1000);
458+
cputime->time = nsStart + ((nsEnd - nsStart) /2);
459+
//TODO: figure out how to get global cpu time, For now place hold with 1.
460+
cputime->total = uint64(1);
461+
return cputime;
429462
#else
430463
return NULL;
431464
#endif

src/ibmras/monitoring/plugins/common/environment/envplugin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
#include <sys/sysinfo.h> // get_nprocs()
6060
#include <unistd.h> // gethostname()
6161
#include <procinfo.h>
62+
#if defined(__PASE__)
63+
//on PASE procinfo.h does not declare getargs()
64+
extern "C"{
65+
extern int getargs(void *, int, char *, int);
66+
}
67+
#endif
6268
#include <sys/types.h>
6369
#endif
6470

src/ibmras/monitoring/plugins/common/memory/MemoryPlugin.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#pragma comment(lib, "psapi.lib")
6060
#endif
6161

62-
#if defined(AIXPPC)
62+
#if defined(_AIX)
6363
#include <unistd.h>
6464
#include <alloca.h>
6565
#include <procinfo.h>
@@ -315,7 +315,7 @@ int64 MemoryPlugin::getProcessPhysicalMemorySize() {
315315
size_t size = t_info.resident_size;
316316
return size;
317317

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

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

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

@@ -496,13 +496,18 @@ int64 MemoryPlugin::getFreePhysicalMemorySize() {
496496
return statex.ullAvailPhys;
497497
}
498498
return -1;
499+
#elif defined (__PASE__)
500+
//TODO: Working on PASE Implementation
501+
//AIXPPC implementation fails on PASE ...
502+
// ...@ line 482 size never gets changed therefore -1 is returned
503+
return -1;
499504
#else
500505
return -1;
501506
#endif
502507
}
503508

504509
int64 MemoryPlugin::getTotalPhysicalMemorySize() {
505-
#if defined (_AIX)
510+
#if defined (_AIX) && !defined(__PASE__)
506511
return (int64)(sysconf(_SC_AIX_REALMEM) * 1024);
507512

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

0 commit comments

Comments
 (0)