-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstats.h
93 lines (79 loc) · 2.5 KB
/
stats.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
+----------------------------------------------------------------------+
| Zan-Stats |
+----------------------------------------------------------------------+
| Copyright (c) 2017-2017 maben<https://github.com/imaben> |
+----------------------------------------------------------------------+
| This source file is subject to version 2.0 of the Apache license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.apache.org/licenses/LICENSE-2.0.html |
| If you did not receive a copy of the Apache2.0 license and are unable|
| to obtain it through the world-wide-web, please send a note to |
| www.maben@foxmail.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: maben <www.maben@foxmail.com> |
+----------------------------------------------------------------------+
*/
#pragma once
#include <curses.h>
#include <panel.h>
#define ZS_VERSION "0.0.1"
typedef unsigned int uint;
#define WORKER_DETAIL_TH { \
"WorkerID", \
"StartTime", \
"TotalRequest", \
"Request", \
"Status"\
}
#define WORKER_DETAIL_TH_NUM 5
#define BASE_INFO_WIDTH 60
#define LEFT_ALIGN 3
enum zs_colors {
ZS_COLOR_WHITE,
ZS_COLOR_RED,
ZS_COLOR_GREEN,
ZS_COLOR_CYAN,
ZS_COLOR_BLACK_GREEN,
ZS_COLOR_BLACK_CYAN
};
typedef struct {
uint x;
uint y;
} zs_point;
struct worker_detail_item {
int worker_id;
char start_time[32];
int total_request;
int request;
char status[8];
};
typedef struct {
WINDOW *win;
PANEL *panel;
int width;
int height;
int x;
int y;
int total_worker;
struct worker_detail_item *item;
int th_width[WORKER_DETAIL_TH_NUM];
int offset;
int cursor;
} zs_worker_detail;
typedef struct {
char start_time[32];
char last_reload[32];
uint32_t connection_num;
uint64_t accept_count;
uint64_t close_count;
uint32_t tasking_num;
uint32_t worker_normal_exit;
uint32_t worker_abnormal_exit;
uint32_t task_worker_normal_exit;
uint32_t task_worker_abnormal_exit;
} zs_base_info;
#define zs_select_color(color) attrset(COLOR_PAIR(color))
#define zs_bold_on() attron(A_BOLD)
#define zs_bold_off() attroff(A_BOLD)