-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathngx_http_monitor_message.h
61 lines (43 loc) · 1.37 KB
/
ngx_http_monitor_message.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _NGX_HTTP_MONITOR_MESSAGE_H_INCLUDE_
#define _NGX_HTTP_MONITOR_MESSAGE_H_INCLUDE_
#include <stdint.h>
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
// A simple queue to buffer Message
typedef struct ngx_http_monitor_str{
ngx_int_t buflen;
u_char* buf;
} ngx_http_monitor_str_t;
typedef struct ngx_http_monitor_str_list ngx_http_monitor_str_list_t;
struct ngx_http_monitor_str_list{
ngx_http_monitor_str_t* str;
ngx_http_monitor_str_list_t* next;
};
// Protocol definition of Message send to monitor server
struct Message
{
const int32_t HEADER_LENGTH;//= 24;
int32_t totalLen;
const int8_t version; // = 0x01;
// Top level No: 4(Nginx)
const int8_t collectcode; // = 4;
// Second level No
int8_t businesscode; // = 1;
// 1 High, 4 Middle, 8 Low
int8_t warnlevel;
// Length of b_name, not used
const int32_t b_name_s; // = 0;
uint32_t ip; // not used, should ignore it's value
int64_t timestamp;
char b_name[0]; // not used
char body[0];
};
#define MESSAGE_INTIALIZER {24, 0, 1, 4, 1, 1, 0, 0, 0}
void toByteWithoutCopyBody(struct Message* msg, ngx_http_monitor_str_t* strbuf);
// Byte utils
uint64_t htonll(uint64_t n);
uint32_t revertByteL(uint32_t val);
//long getCurrentEpoch();
//long getLocalIp();
#endif