00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __ResourceMonitorTypes_h__
00034 #define __ResourceMonitorTypes_h__
00035
00036 #include <sys/types.h>
00037 #include <unistd.h>
00038 #include <time.h>
00039 #include "ResourceMonitorErrno.h"
00040
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 #include <uuid/uuid.h>
00045 #define MAX_GUID_STRLEN (sizeof(uuid_t)*2+6)
00046 #ifdef __cplusplus
00047 #include <iostream>
00048
00055 class RMuid
00056 {
00057 public:
00058 uuid_t id;
00059 public:
00060 RMuid() { uuid_clear(id); }
00061 RMuid( const char * idstr ) { uuid_parse((char *)idstr, id); }
00062 RMuid( const uuid_t uu ) { uuid_copy(id, (unsigned char *)uu); }
00063 RMuid( const RMuid &uu ) { uuid_copy(id, (unsigned char *)uu.id); }
00064 void clear() { uuid_clear(id); }
00065 void generate() { uuid_generate(id); }
00066 void generate_random() { uuid_generate_random(id); }
00067 void generate_time() { uuid_generate_time(id); }
00069 int parse( const char * idstr ) { return uuid_parse((char *)idstr, id); }
00070 void unparse( char *out ) { uuid_unparse(id, out); }
00071 bool compare( const uuid_t &uu ) { if(uuid_compare((unsigned char *)uu, id)==0) return true; else return false;}
00072 bool is_null() { if(uuid_is_null(id)) return true; else return false; }
00073 void print(ostream &out) { char buffer[MAX_GUID_STRLEN]; unparse(buffer); out << buffer; }
00074
00075 RMuid & operator=(const RMuid &b)
00076 {
00077 uuid_copy(id, (unsigned char *)b.id);
00078 return *this;
00079 }
00080 bool operator==(const RMuid &b)
00081 {
00082 return compare(b.id);
00083 }
00084 bool operator<(const RMuid &b)
00085 {
00086 return uuid_compare(id, (unsigned char *)b.id);
00087 }
00088 };
00089
00090 }
00091 #endif
00092
00093 #ifdef NO_EVENTLOG
00094 typedef int posix_log_severity_t;
00095 typedef int posix_log_notify_t;
00096 typedef int posix_log_query_t;
00097 #include <syslog.h>
00098 #include <signal.h>
00099 #else
00100 #include <posix_evlog.h>
00101 #endif
00102
00103 #define RESOURCE_MONITOR_VERSION_1 1
00104 #define RESOURCE_MONITOR_VERSION_15 105
00105 #define RESOURCE_MONITOR_VERSION RESOURCE_MONITOR_VERSION_15
00106
00108
00109 #include <wchar.h>
00110 typedef wchar_t rmChar;
00111 #else
00112 typedef char rmChar;
00113 #endif
00114
00115 typedef uuid_t rmUID;
00117 typedef u_int32_t rmID;
00119 typedef rmChar * rmString;
00121 typedef void * rmHandle;
00123 typedef time_t rmTimeStamp;
00125 typedef time_t rmTimeInterval;
00127 typedef long rmMicroTimeInterval;
00134 enum rmDescriptions
00135 {
00136 rmShortDescription = 1,
00137 rmLongDescription,
00138 rmUnitsDescription,
00139 rmDescriptionsEnd
00140 };
00141
00150 typedef struct
00151 {
00152 #ifdef InSubsystemMonitor
00153
00154 rmString name;
00156 rmString description;
00157 #endif // InSubsystemMonitor
00158
00159 rmUID id;
00161 size_t noResources;
00163 size_t noStatistics;
00164 } rmSubsystemInfo;
00165
00166
00175 typedef struct
00176 {
00177 #ifdef InSubsystemMonitor
00178
00179 rmString name;
00181 rmString description;
00182 #endif // InSubsystemMonitor
00183
00184 rmUID SubsystemId;
00186 rmID id;
00187 } rmResourceInfo;
00188
00197 #define rmPsuedoResourceID 0xffffffff
00198
00202 enum rmStatisticType
00203 {
00204 rmCounter = 1,
00205 rmGauge,
00206 rmStatisticTypeEnd
00207 };
00208
00212 enum rmStatisticSize
00213 {
00214 rmSizeU32 = 1,
00215 rmSizeS32,
00216 rmSizeU64,
00217 rmSizeS64,
00218 rmStatisticSizeEnd
00219 };
00220
00224 enum rmStatisticScale
00225 {
00226 rmScaleNone = 1,
00227 rmScaleByte,
00228 rmScaleKilobyte,
00229 rmScaleMegabyte,
00230 rmScaleGigabyte,
00231 rmScaleTerabyte,
00232 rmScalePages,
00233 rmScaleJiffies,
00234 rmScaleNanosec,
00235 rmScaleMicrosec,
00236 rmScaleMillisec,
00237 rmScaleSec,
00238 rmScaleMin,
00239 rmScaleHour,
00240 rmScaleDay,
00241 rmScaleWeek,
00242 rmScaleMonth,
00243 rmScaleYear,
00244 rmStatisticScaleEnd
00245 };
00246
00250 typedef union
00251 {
00253 int32_t rmValueS32;
00255 u_int32_t rmValueU32;
00257 int64_t rmValueS64;
00259 u_int64_t rmValueU64;
00260 } rmValue;
00261
00262
00266 typedef struct
00267 {
00268 #ifdef InSubsystemMonitor
00269
00270 rmString name;
00272 rmString description;
00274 rmString units;
00275 #endif // InSubsystemMonitor
00276
00277 rmUID SubsystemId;
00279 rmID id;
00281 enum rmStatisticType type;
00283 enum rmStatisticSize size;
00285 enum rmStatisticScale scale;
00286 } rmStatisticInfo;
00287
00296 typedef struct
00297 {
00299 rmUID SubsystemId;
00303 rmID ResourceId;
00305 rmID StatisticId;
00306 } rmStatisticKey;
00307 typedef rmStatisticKey rmStatisticId;
00308
00312 typedef struct
00313 {
00315 rmStatisticKey Stat;
00317 rmValue Value;
00318 } rmStatisticValue;
00319
00323 enum rmMonitorType
00324 {
00325 rmThresholding = 1,
00326 rmWatermarking,
00327 rmLeakyBucket,
00328 rmMonitorTypeEnd
00329 };
00330
00331
00332
00333
00334
00339 enum rmMonitorLocation
00340 {
00341 rmInLine = 1,
00342 rmDaemon,
00343 rmInLineDaemon,
00344 rmMonitorLocationEnd
00345 };
00346
00352 typedef struct
00353 {
00356 rmValue tolerance;
00358 u_int32_t samples;
00363 rmTimeInterval loggingRate;
00364 } rmThresholdControl;
00365 #define RMThresholdTolerance typeControl.threshold.tolerance
00366 #define RMThresholdSamples typeControl.threshold.samples
00367 #define RMThresholdLoggingRate typeControl.threshold.loggingRate
00368
00374 typedef struct
00375 {
00379 rmTimeInterval loggingRate;
00380 } rmLeakyBucketControl;
00381 #define RMLeakyBucketLoggingRate typeControl.leakyBucket.loggingRate
00382
00392 typedef struct
00393 {
00395 enum rmMonitorType monitorType;
00399 enum rmMonitorLocation location;
00406 rmUID uid;
00409 #define clearMonitorUID(c) (uuid_clear((c).uid))
00412 #define setMonitorUID(c,str) (uuid_parse((char *)(str), (c).uid);
00418 rmUID dataCapture;
00421 #define clearDataCapture(c) (uuid_clear((c).dataCapture))
00424 #define setDataCapture(c,str) (uuid_parse((char *)(str), (c).dataCapture))
00425
00426 rmTimeInterval monitoringInterval;
00429 rmTimeInterval monitoringRate;
00432 rmMicroTimeInterval microMonitoringRate;
00434 union {
00435 rmThresholdControl threshold;
00436 rmLeakyBucketControl leakyBucket;
00437
00438 } typeControl;
00439 } rmMonitorControl;
00440
00441
00442
00443
00444
00457 enum rmStatisticTransform
00458 {
00459 rmNone = 1,
00460 rmChange,
00461 rmPercent,
00462 rmPercentChange,
00463 rmStatisticTransformEnd
00464 };
00465
00472 enum rmThresholdType
00473 {
00474 rmThreshold = 1,
00475 rmBiDirectionalThreshold,
00476 rmThresholdTypeEnd
00477 };
00478
00483 enum rmThresholdTestCondition
00484 {
00485 rmValueIsAbove = 1,
00486 rmValueIsAtOrAbove,
00487 rmValueIsAt,
00488 rmValueIsAtOrBelow,
00489 rmValueIsBelow,
00490 rmValueIsNotAt,
00491 rmThresholdTestConditionEnd
00492 };
00493
00494 enum rmThresholdPrecondition
00495 {
00496 rmNoPrecondition = 1,
00497 rmObserveGoodValue,
00498 rmThresholdPreconditionEnd
00499 };
00500
00514 typedef struct
00515 {
00517 enum rmThresholdType type;
00521 rmValue thresholdValue;
00523 enum rmThresholdTestCondition condition;
00525 enum rmThresholdPrecondition precondition;
00528 posix_log_severity_t eventSeverity;
00531 posix_log_severity_t cancelEventSeverity;
00532 } rmThresholdConfiguration;
00533 #define RMThresholdType typeConfiguration.threshold.type
00534 #define RMThresholdValue typeConfiguration.threshold.thresholdValue
00535 #define RMThresholdCondition typeConfiguration.threshold.condition
00536 #define RMThresholdPrecondition typeConfiguration.threshold.precondition
00537 #define RMThresholdEventSeverity typeConfiguration.threshold.eventSeverity
00538 #define RMThresholdCancelEventSeverity typeConfiguration.threshold.cancelEventSeverity
00539
00573 typedef struct
00574 {
00576 rmValue bucketSize;
00578 rmValue fillValue;
00581 posix_log_severity_t eventSeverity;
00582 } rmLeakyBucketConfiguration;
00583 #define RMbucketSize typeConfiguration.leakyBucket.bucketSize
00584 #define RMfillValue typeConfiguration.leakyBucket.fillValue
00585 #define RMleakyBucketEventSeverity typeConfiguration.leakyBucket.eventSeverity
00586
00587 enum rmWatermarkType
00588 {
00589 rmHighWatermark = 1,
00590 rmLowWatermark,
00591 rmDualWatermark,
00592 rmWatermarkTypeEnd
00593 };
00594
00600 typedef struct
00601 {
00602 enum rmWatermarkType type;
00603 } rmWatermarkConfiguration;
00604 #define RMWatermarkType typeConfiguration.watermark.type
00605
00611 typedef struct
00612 {
00614 enum rmMonitorType monitorType;
00616 rmStatisticKey statisticKey;
00629 enum rmStatisticTransform statisticTransform;
00631 union {
00632 rmThresholdConfiguration threshold;
00633 rmWatermarkConfiguration watermark;
00634 rmLeakyBucketConfiguration leakyBucket;
00635
00636 } typeConfiguration;
00637 } rmMonitorConfiguration;
00638
00662 enum rmMonitorStatus
00663 {
00664 rmAvailable = 1,
00665 rmConfigured,
00666 rmActive,
00667 rmStopped,
00668 rmInactive,
00669 rmUnavailableResource,
00670 rmMonitorStatusEnd
00671 };
00672
00677 typedef struct
00678 {
00680 rmTimeStamp LastEventTime;
00681 } rmThresholdState;
00682 #define RMThresholdLastEventTime typeState.threshold.LastEventTime
00683
00689 typedef struct
00690 {
00692 rmValue highWatermark;
00694 rmValue lowWatermark;
00696 rmTimeStamp highTime;
00698 rmTimeStamp lowTime;
00699 } rmWatermarkState;
00700 #define RMWatermarkHigh typeState.watermark.highWatermark
00701 #define RMWatermarkLow typeState.watermark.lowWatermark
00702 #define RMWatermarkHighTime typeState.watermark.highTime
00703 #define RMWatermarkLowTime typeState.watermark.lowTime
00704
00710 typedef struct
00711 {
00713 rmValue bucketLevel;
00715 rmTimeStamp LastEventTime;
00716 } rmLeakyBucketState;
00717 #define RMLeakyBucketLevel typeState.leakyBucket.bucketLevel
00718 #define RMLeakyBucketLastEventTime typeState.leakyBucket.LastEventTime
00719
00725 typedef struct
00726 {
00728 enum rmMonitorType monitorType;
00730 enum rmMonitorStatus currentStatus;
00733 int notificationPaused;
00734 rmStatisticValue lastMonitoredValue;
00736 rmTimeStamp startTime;
00738 rmTimeStamp stopTime;
00740 union {
00741 rmThresholdState threshold;
00742 rmWatermarkState watermark;
00743 rmLeakyBucketState leakyBucket;
00744
00745 } typeState;
00746 } rmMonitorState;
00747
00751 typedef struct
00752 {
00753
00754 rmUID uid;
00756 uid_t creator;
00758 rmHandle handle;
00759 } rmMonitorInfo;
00760
00761 #endif // __ResourceMonitorTypes_h__
00762