mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
yum, net graphs
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@28 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
1e5181ce85
commit
68cca1fd8d
@ -1,3 +1,9 @@
|
|||||||
|
2005-07-30
|
||||||
|
* finalized graphing code, see $cpugraph, $memgraph, $execgraph,
|
||||||
|
$downspeedgraph, and $upspeedgraph
|
||||||
|
* added override_utf8_locale option
|
||||||
|
* poop
|
||||||
|
|
||||||
2005-07-28
|
2005-07-28
|
||||||
* Added new graphing code, such as $cpugraph
|
* Added new graphing code, such as $cpugraph
|
||||||
* small fixes all round
|
* small fixes all round
|
||||||
|
7
README
7
README
@ -93,6 +93,7 @@
|
|||||||
mldonkey_login Mldonkey login, default none
|
mldonkey_login Mldonkey login, default none
|
||||||
mldonkey_password Mldonkey password, default none
|
mldonkey_password Mldonkey password, default none
|
||||||
net_avg_samples The number of samples to average for net data
|
net_avg_samples The number of samples to average for net data
|
||||||
|
override_utf8_locale Force UTF8? requires XFT
|
||||||
own_window Boolean, create own window to draw?
|
own_window Boolean, create own window to draw?
|
||||||
pad_percents Pad percentages to this many decimals (0 = no
|
pad_percents Pad percentages to this many decimals (0 = no
|
||||||
padding)
|
padding)
|
||||||
@ -156,10 +157,12 @@
|
|||||||
color (color) Change drawing color to color
|
color (color) Change drawing color to color
|
||||||
cpu CPU usage in percents
|
cpu CPU usage in percents
|
||||||
cpubar (height) Bar that shows CPU usage, height is
|
cpubar (height) Bar that shows CPU usage, height is
|
||||||
bar's height in pixels
|
bar's height in pixels
|
||||||
|
cpugraph (height),(width)CPU usage graph
|
||||||
downspeed net Download speed in kilobytes
|
downspeed net Download speed in kilobytes
|
||||||
downspeedf net Download speed in kilobytes with one
|
downspeedf net Download speed in kilobytes with one
|
||||||
decimal
|
decimal
|
||||||
|
downspeedgraph net (height),(width) Download speed graph
|
||||||
exec shell command Executes a shell command and displays
|
exec shell command Executes a shell command and displays
|
||||||
the output in conky. warning: this
|
the output in conky. warning: this
|
||||||
takes a lot more resources than other
|
takes a lot more resources than other
|
||||||
@ -170,6 +173,7 @@
|
|||||||
will use that number for a bar.
|
will use that number for a bar.
|
||||||
The size for the bar is currently fixed,
|
The size for the bar is currently fixed,
|
||||||
but that may change in the future.
|
but that may change in the future.
|
||||||
|
execgraph shell command Same as execbar, but graphs values
|
||||||
execi interval, shell Same as exec but with specific interval.
|
execi interval, shell Same as exec but with specific interval.
|
||||||
command Interval can't be less than
|
command Interval can't be less than
|
||||||
update_interval in configuration.
|
update_interval in configuration.
|
||||||
@ -295,6 +299,7 @@
|
|||||||
upspeed net Upload speed in kilobytes
|
upspeed net Upload speed in kilobytes
|
||||||
upspeedf net Upload speed in kilobytes with one
|
upspeedf net Upload speed in kilobytes with one
|
||||||
decimal
|
decimal
|
||||||
|
upspeedgraph net (height),(width) Upload speed graph
|
||||||
uptime Uptime
|
uptime Uptime
|
||||||
uptime_short Uptime in a shorter format
|
uptime_short Uptime in a shorter format
|
||||||
|
|
||||||
|
2
common.c
2
common.c
@ -146,7 +146,7 @@ void format_seconds_short(char *buf, unsigned int n, long t)
|
|||||||
static double last_meminfo_update;
|
static double last_meminfo_update;
|
||||||
static double last_fs_update;
|
static double last_fs_update;
|
||||||
|
|
||||||
unsigned int need_mask;
|
unsigned long long need_mask;
|
||||||
|
|
||||||
void update_stuff()
|
void update_stuff()
|
||||||
{
|
{
|
||||||
|
76
conky.c
76
conky.c
@ -242,8 +242,8 @@ static struct special_t *new_special(char *buf, int t)
|
|||||||
buf[0] = SPECIAL_CHAR;
|
buf[0] = SPECIAL_CHAR;
|
||||||
buf[1] = '\0';
|
buf[1] = '\0';
|
||||||
if (t == GRAPH && specials[special_count].graph == NULL) {
|
if (t == GRAPH && specials[special_count].graph == NULL) {
|
||||||
if (specials[special_count].height > 0 && specials[special_count].height < MAX_GRAPH_DEPTH)
|
if (specials[special_count].width > 0 && specials[special_count].width < MAX_GRAPH_DEPTH)
|
||||||
specials[special_count].graph_width = specials[special_count].height;
|
specials[special_count].graph_width = specials[special_count].width - 3; // subtract 3 for the box
|
||||||
else
|
else
|
||||||
specials[special_count].graph_width = MAX_GRAPH_DEPTH;
|
specials[special_count].graph_width = MAX_GRAPH_DEPTH;
|
||||||
specials[special_count].graph = calloc(specials[special_count].graph_width, sizeof(double));
|
specials[special_count].graph = calloc(specials[special_count].graph_width, sizeof(double));
|
||||||
@ -310,13 +310,14 @@ inline void graph_append(struct special_t *graph, double f) {
|
|||||||
if (graph->scaled) {
|
if (graph->scaled) {
|
||||||
graph->graph_scale = 0;
|
graph->graph_scale = 0;
|
||||||
}
|
}
|
||||||
|
graph->graph[graph->graph_width-1] = f;
|
||||||
for (i=0;i<graph->graph_width-1;i++) {
|
for (i=0;i<graph->graph_width-1;i++) {
|
||||||
graph->graph[i] = graph->graph[i+1];
|
graph->graph[i] = graph->graph[i+1];
|
||||||
if (graph->scaled && graph->graph[i] > graph->graph_scale) {
|
if (graph->scaled && graph->graph[i] > graph->graph_scale) {
|
||||||
graph->graph_scale = graph->graph[i];
|
graph->graph_scale = graph->graph[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graph->graph[graph->graph_width-1] = f;
|
// graph->graph[graph->graph_width-1] = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void new_graph(char *buf, int w, int h, double i, int scaled)
|
static void new_graph(char *buf, int w, int h, double i, int scaled)
|
||||||
@ -325,8 +326,11 @@ static void new_graph(char *buf, int w, int h, double i, int scaled)
|
|||||||
s->width = w;
|
s->width = w;
|
||||||
s->height = h;
|
s->height = h;
|
||||||
s->scaled = scaled;
|
s->scaled = scaled;
|
||||||
|
if (s->width) {
|
||||||
|
s->graph_width = s->width - 3; // subtract 3 for rectangle around
|
||||||
|
}
|
||||||
if (scaled) {
|
if (scaled) {
|
||||||
s->graph_scale = 0;
|
s->graph_scale = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s->graph_scale = 100;
|
s->graph_scale = 100;
|
||||||
@ -342,8 +346,8 @@ static const char *scan_graph(const char *args, int *w, int *h)
|
|||||||
if (args) {
|
if (args) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (sscanf(args, "%d,%d %n", h, w, &n) <= 1)
|
if (sscanf(args, "%d,%d %n", h, w, &n) <= 1)
|
||||||
sscanf(args, "%d %n", h, &n);
|
sscanf(args, "%*s %d %n", h, &n);
|
||||||
args += n;
|
//args += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
@ -574,6 +578,7 @@ enum text_object_type {
|
|||||||
|
|
||||||
struct text_object {
|
struct text_object {
|
||||||
int type;
|
int type;
|
||||||
|
int a, b;
|
||||||
union {
|
union {
|
||||||
char *s; /* some string */
|
char *s; /* some string */
|
||||||
int i; /* some integer */
|
int i; /* some integer */
|
||||||
@ -626,7 +631,6 @@ struct text_object {
|
|||||||
struct {
|
struct {
|
||||||
int a, b;
|
int a, b;
|
||||||
} pair; /* 2 */
|
} pair; /* 2 */
|
||||||
|
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -742,8 +746,16 @@ static void construct_text_object(const char *s, const char *arg)
|
|||||||
END OBJ(downspeed, INFO_NET) obj->data.net = get_net_stat(arg);
|
END OBJ(downspeed, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||||
END OBJ(downspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
|
END OBJ(downspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||||
END OBJ(downspeedgraph, INFO_NET)
|
END OBJ(downspeedgraph, INFO_NET)
|
||||||
obj->data.net = get_net_stat(arg);
|
(void) scan_graph(arg, &obj->a, &obj->b);
|
||||||
(void) scan_graph("", &obj->data.pair.a, &obj->data.pair.b);
|
char buf[64];
|
||||||
|
sscanf(arg, "%63s %*i,%*i %*i", buf);
|
||||||
|
obj->data.net = get_net_stat(buf);
|
||||||
|
if (sscanf(arg, "%*s %d,%d %*d", &obj->a, &obj->b) <= 1) {
|
||||||
|
if (sscanf(arg, "%*s %d,%d", &obj->a, &obj->b) <= 1) {
|
||||||
|
obj->a = 0;
|
||||||
|
obj->b = 25;
|
||||||
|
}
|
||||||
|
}
|
||||||
END OBJ(else, 0)
|
END OBJ(else, 0)
|
||||||
if (blockdepth) {
|
if (blockdepth) {
|
||||||
text_objects[blockstart[blockdepth - 1] -
|
text_objects[blockstart[blockdepth - 1] -
|
||||||
@ -1121,7 +1133,16 @@ static void construct_text_object(const char *s, const char *arg)
|
|||||||
END OBJ(upspeed, INFO_NET) obj->data.net = get_net_stat(arg);
|
END OBJ(upspeed, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||||
END OBJ(upspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
|
END OBJ(upspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||||
END OBJ(upspeedgraph, INFO_NET)
|
END OBJ(upspeedgraph, INFO_NET)
|
||||||
(void) scan_graph(arg, &obj->data.pair.a, &obj->data.pair.b);
|
(void) scan_graph(arg, &obj->a, &obj->b);
|
||||||
|
char buf[64];
|
||||||
|
sscanf(arg, "%63s %*i,%*i %*i", buf);
|
||||||
|
obj->data.net = get_net_stat(buf);
|
||||||
|
if (sscanf(arg, "%*s %d,%d %*d", &obj->a, &obj->b) <= 1) {
|
||||||
|
if (sscanf(arg, "%*s %d,%d", &obj->a, &obj->b) <= 1) {
|
||||||
|
obj->a = 0;
|
||||||
|
obj->b = 25;
|
||||||
|
}
|
||||||
|
}
|
||||||
END OBJ(uptime_short, INFO_UPTIME) END OBJ(uptime, INFO_UPTIME) END
|
END OBJ(uptime_short, INFO_UPTIME) END OBJ(uptime, INFO_UPTIME) END
|
||||||
OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
|
OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
|
||||||
#ifdef SETI
|
#ifdef SETI
|
||||||
@ -1402,8 +1423,7 @@ static void generate_text()
|
|||||||
recv_speed / 1024.0);
|
recv_speed / 1024.0);
|
||||||
}
|
}
|
||||||
OBJ(downspeedgraph) {
|
OBJ(downspeedgraph) {
|
||||||
CRIT_ERR("the net graph stuff is broken right now. don't use it.");
|
new_graph(p, obj->a, obj->b, (obj->data.net->recv_speed / 1024.0), 1);
|
||||||
new_graph(p, obj->data.pair.a, obj->data.pair.b, (obj->data.net->recv_speed / 1024.0), 1);
|
|
||||||
}
|
}
|
||||||
OBJ(else) {
|
OBJ(else) {
|
||||||
if (!if_jumped) {
|
if (!if_jumped) {
|
||||||
@ -1934,11 +1954,8 @@ static void generate_text()
|
|||||||
trans_speed / 1024.0);
|
trans_speed / 1024.0);
|
||||||
}
|
}
|
||||||
OBJ(upspeedgraph) {
|
OBJ(upspeedgraph) {
|
||||||
CRIT_ERR("the net graph stuff is broken right now. don't use it.");
|
new_graph(p, obj->a, obj->b, (obj->data.net->trans_speed / 1024.0), 1);
|
||||||
new_graph(p, obj->data.pair.a,
|
}
|
||||||
obj->data.pair.b,
|
|
||||||
(obj->data.net->trans_speed / 1024.0), 1);
|
|
||||||
}
|
|
||||||
OBJ(uptime_short) {
|
OBJ(uptime_short) {
|
||||||
format_seconds_short(p, n,
|
format_seconds_short(p, n,
|
||||||
(int) cur->uptime);
|
(int) cur->uptime);
|
||||||
@ -2692,17 +2709,12 @@ static void draw_line(char *s)
|
|||||||
int by =
|
int by =
|
||||||
cur_y - (font_ascent() +
|
cur_y - (font_ascent() +
|
||||||
h) / 2 - 1;
|
h) / 2 - 1;
|
||||||
int line;
|
|
||||||
w = specials[special_index].width;
|
w = specials[special_index].width;
|
||||||
if (w == 0)
|
if (w == 0)
|
||||||
w = text_start_x +
|
w = text_start_x +
|
||||||
text_width - cur_x - 1;
|
text_width - cur_x - 1;
|
||||||
if (w < 0)
|
if (w < 0)
|
||||||
w = 0;
|
w = 0;
|
||||||
if (w >= specials[special_index].graph_width)
|
|
||||||
line = w/specials[special_index].graph_width+1;
|
|
||||||
else
|
|
||||||
line = 1;
|
|
||||||
XSetLineAttributes(display,
|
XSetLineAttributes(display,
|
||||||
window.gc, 1,
|
window.gc, 1,
|
||||||
LineSolid,
|
LineSolid,
|
||||||
@ -2713,13 +2725,21 @@ static void draw_line(char *s)
|
|||||||
window.gc, cur_x,
|
window.gc, cur_x,
|
||||||
by, w, h);
|
by, w, h);
|
||||||
XSetLineAttributes(display,
|
XSetLineAttributes(display,
|
||||||
window.gc, line,
|
window.gc, 1,
|
||||||
LineSolid,
|
LineSolid,
|
||||||
CapButt,
|
CapButt,
|
||||||
JoinMiter);
|
JoinMiter);
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<specials[special_index].graph_width;i++) {
|
int j=0;
|
||||||
XDrawLine(display, window.drawable, window.gc, cur_x+(i*w*1.0/specials[special_index].graph_width)+2, by+h, cur_x+(i*w*1.0/specials[special_index].graph_width)+2, by+h-specials[special_index].graph[i]*h/specials[special_index].graph_scale); /* this is mugfugly, but it works */
|
for (i=0;i<w-3;i++) {
|
||||||
|
if (i / ((float)(w - 3) / (specials[special_index].graph_width)) > j) {
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
XDrawLine(display, window.drawable, window.gc,
|
||||||
|
cur_x+i+2, by+h,
|
||||||
|
cur_x+i+2,
|
||||||
|
by+h-specials[special_index].graph[j]*h/specials[special_index]
|
||||||
|
.graph_scale); /* this is mugfugly, but it works */
|
||||||
}
|
}
|
||||||
if (specials[special_index].height > font_h) {
|
if (specials[special_index].height > font_h) {
|
||||||
cur_y += specials[special_index].height;
|
cur_y += specials[special_index].height;
|
||||||
@ -3519,6 +3539,12 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, a) == 0)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CONF("override_utf8_locale") {
|
||||||
|
utf8_mode
|
||||||
|
=
|
||||||
|
string_to_bool
|
||||||
|
(value);
|
||||||
|
}
|
||||||
#ifdef XDBE
|
#ifdef XDBE
|
||||||
CONF("double_buffer") {
|
CONF("double_buffer") {
|
||||||
use_xdbe
|
use_xdbe
|
||||||
|
2
conky.h
2
conky.h
@ -237,7 +237,7 @@ struct net_stat *get_net_stat(const char *dev);
|
|||||||
void update_stuff();
|
void update_stuff();
|
||||||
|
|
||||||
#define SET_NEED(a) need_mask |= 1 << (a)
|
#define SET_NEED(a) need_mask |= 1 << (a)
|
||||||
extern unsigned int need_mask;
|
extern unsigned long long need_mask;
|
||||||
|
|
||||||
extern double current_update_time, last_update_time;
|
extern double current_update_time, last_update_time;
|
||||||
|
|
||||||
|
@ -98,6 +98,10 @@ cpu_avg_samples 4
|
|||||||
# set to 1 to disable averaging
|
# set to 1 to disable averaging
|
||||||
net_avg_samples 4
|
net_avg_samples 4
|
||||||
|
|
||||||
|
# Force UTF8? note that UTF8 support required XFT
|
||||||
|
override_utf8_locale no
|
||||||
|
|
||||||
|
|
||||||
# Add spaces to keep things from moving about? This only affects certain objects.
|
# Add spaces to keep things from moving about? This only affects certain objects.
|
||||||
use_spacer no
|
use_spacer no
|
||||||
|
|
||||||
@ -139,9 +143,11 @@ metar_station CYBW
|
|||||||
# cpu CPU usage in percents
|
# cpu CPU usage in percents
|
||||||
# cpubar (height) Bar that shows CPU usage, height is
|
# cpubar (height) Bar that shows CPU usage, height is
|
||||||
# bar's height in pixels
|
# bar's height in pixels
|
||||||
|
# cpugraph (height),(width)CPU usage graph
|
||||||
# downspeed net Download speed in kilobytes
|
# downspeed net Download speed in kilobytes
|
||||||
# downspeedf net Download speed in kilobytes with one
|
# downspeedf net Download speed in kilobytes with one
|
||||||
# decimal
|
# decimal
|
||||||
|
# downspeedgraph net (height),(width) Download speed graph
|
||||||
# exec shell command Executes a shell command and displays
|
# exec shell command Executes a shell command and displays
|
||||||
# the output in conky. warning: this
|
# the output in conky. warning: this
|
||||||
# takes a lot more resources than other
|
# takes a lot more resources than other
|
||||||
@ -152,6 +158,7 @@ metar_station CYBW
|
|||||||
# will use that number for a bar.
|
# will use that number for a bar.
|
||||||
# The size for the bar is currently fixed,
|
# The size for the bar is currently fixed,
|
||||||
# but that may change in the future.
|
# but that may change in the future.
|
||||||
|
# execgraph shell command Same as execbar, but graphs values
|
||||||
# execi interval, shell Same as exec but with specific interval.
|
# execi interval, shell Same as exec but with specific interval.
|
||||||
# command Interval can't be less than
|
# command Interval can't be less than
|
||||||
# update_interval in configuration.
|
# update_interval in configuration.
|
||||||
@ -277,6 +284,7 @@ metar_station CYBW
|
|||||||
# upspeed net Upload speed in kilobytes
|
# upspeed net Upload speed in kilobytes
|
||||||
# upspeedf net Upload speed in kilobytes with one
|
# upspeedf net Upload speed in kilobytes with one
|
||||||
# decimal
|
# decimal
|
||||||
|
# upspeedgraph net (height),(width) Upload speed graph
|
||||||
# uptime Uptime
|
# uptime Uptime
|
||||||
# uptime_short Uptime in a shorter format
|
# uptime_short Uptime in a shorter format
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user