1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 04:06:03 +00:00

added , , for crypto freaks

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@797 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2006-11-30 20:46:34 +00:00
parent 57688b94d5
commit 9a016c9377
10 changed files with 126 additions and 0 deletions

View File

@ -1,5 +1,9 @@
# $Id$ # $Id$
2006-11-30
* Added $entropy_avail, $entropy_poolsize and $entropy_bar
for the crypto freaks.
2006-11-28 2006-11-28
* Rearrange retry attempts in pop3 and imap code, removing sleep() * Rearrange retry attempts in pop3 and imap code, removing sleep()
calls which cause the whole process to sleep, not just the thread. calls which cause the whole process to sleep, not just the thread.

12
README
View File

@ -551,6 +551,18 @@ VARIABLES
else Text to show if any of the above are not true else Text to show if any of the above are not true
entropy_avail
Current entropy available for crypto freaks
entropy_bar (height),(width)
Normalized bar of available entropy for crypto freaks
entropy_poolsize
Total size of system entropy pool for crypto freaks
exec command exec command
Executes a shell command and displays the output in conky. warn- Executes a shell command and displays the output in conky. warn-
ing: this takes a lot more resources than other variables. I'd ing: this takes a lot more resources than other variables. I'd

View File

@ -519,6 +519,18 @@ Download speed graph, colours defined in hex, minus the #. If scale is non-zero,
\fB\*(T<\fBelse\fR\*(T>\fR \fB\*(T<\fBelse\fR\*(T>\fR
Text to show if any of the above are not true Text to show if any of the above are not true
.TP
\fB\*(T<\fBentropy_avail\fR\*(T>\fR
Current entropy available for crypto freaks
.TP
\fB\*(T<\fBentropy_bar\fR\*(T>\fR \*(T<\fB(height),(width)\fR\*(T>
Normalized bar of available entropy for crypto freaks
.TP
\fB\*(T<\fBentropy_poolsize\fR\*(T>\fR
Total size of system entropy pool for crypto freaks
.TP .TP
\fB\*(T<\fBexec\fR\*(T>\fR \*(T<\fBcommand\fR\*(T> \fB\*(T<\fBexec\fR\*(T>\fR \*(T<\fBcommand\fR\*(T>
Executes a shell command and displays the output in conky. warning: this takes a lot more resources than other variables. I'd recommend coding wanted behaviour in C and posting a patch. Executes a shell command and displays the output in conky. warning: this takes a lot more resources than other variables. I'd recommend coding wanted behaviour in C and posting a patch.

View File

@ -409,6 +409,35 @@
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command><option>entropy_avail</option></command>
</term>
<listitem>
Current entropy available for crypto freaks
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>entropy_bar</option></command>
<option>(height),(width)</option>
</term>
<listitem>
Normalized bar of available entropy for crypto freaks
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>entropy_poolsize</option></command>
</term>
<listitem>
Total size of system entropy pool for crypto freaks
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command><option>exec</option></command> <command><option>exec</option></command>

View File

@ -257,6 +257,8 @@ void update_stuff()
if (NEED(INFO_TCP_PORT_MONITOR)) if (NEED(INFO_TCP_PORT_MONITOR))
update_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection ); update_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
#endif #endif
if (NEED(INFO_ENTROPY))
update_entropy();
} }
int round_to_int(float f) int round_to_int(float f)

View File

@ -1081,6 +1081,9 @@ enum text_object_type {
#ifdef HDDTEMP #ifdef HDDTEMP
OBJ_hddtemp, OBJ_hddtemp,
#endif #endif
OBJ_entropy_avail,
OBJ_entropy_poolsize,
OBJ_entropy_bar
}; };
struct text_object { struct text_object {
@ -1947,6 +1950,10 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
free(objs[i].data.hddtemp.addr); free(objs[i].data.hddtemp.addr);
break; break;
#endif #endif
case OBJ_entropy_avail:
case OBJ_entropy_poolsize:
case OBJ_entropy_bar:
break;
} }
} }
free(objs); free(objs);
@ -2966,6 +2973,12 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
} }
END END
#endif #endif
OBJ(entropy_avail, INFO_ENTROPY) END
OBJ(entropy_poolsize, INFO_ENTROPY) END
OBJ(entropy_bar, INFO_ENTROPY)
(void) scan_bar(arg, &obj->a, &obj->b);
END
{ {
char buf[256]; char buf[256];
ERR("unknown variable %s", s); ERR("unknown variable %s", s);
@ -4687,6 +4700,22 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
iconv_selected = 0; iconv_selected = 0;
} }
#endif #endif
OBJ(entropy_avail)
{
snprintf(p, p_max_size, "%d", cur->entropy.entropy_avail);
}
OBJ(entropy_poolsize)
{
snprintf(p, p_max_size, "%d", cur->entropy.poolsize);
}
OBJ(entropy_bar)
{
double entropy_perc;
entropy_perc = (double)cur->entropy.entropy_avail /
(double)cur->entropy.poolsize;
new_bar(p,obj->a,obj->b,(int)(entropy_perc * 255.0f));
}
break; break;
} }

View File

@ -186,6 +186,12 @@ struct bmpx_s {
}; };
#endif #endif
void update_entropy();
struct entropy_s {
unsigned int entropy_avail;
unsigned int poolsize;
};
#ifdef TCP_PORT_MONITOR #ifdef TCP_PORT_MONITOR
#include "libtcp-portmon.h" #include "libtcp-portmon.h"
#define MIN_PORT_MONITORS_DEFAULT 16 #define MIN_PORT_MONITORS_DEFAULT 16
@ -226,6 +232,7 @@ enum {
#ifdef XMMS2 #ifdef XMMS2
INFO_XMMS2 = 22, INFO_XMMS2 = 22,
#endif #endif
INFO_ENTROPY = 23,
}; };
@ -288,6 +295,7 @@ struct information {
tcp_port_monitor_collection_t * p_tcp_port_monitor_collection; tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
#endif #endif
short kflags; /* kernel settings, see enum KFLAG */ short kflags; /* kernel settings, see enum KFLAG */
struct entropy_s entropy;
}; };
enum { enum {

View File

@ -876,6 +876,11 @@ char
#endif #endif
void update_entropy (void)
{
/* mirrorbox: can you do anything equivalent in freebsd? -drphibes. */
}
/* empty stub so conky links */ /* empty stub so conky links */
void void
free_all_processes(void) free_all_processes(void)

View File

@ -1756,3 +1756,24 @@ Peter Tarjan (ptarjan@citromail.hu)
return; return;
} }
void update_entropy (void)
{
static int rep;
const char *entropy_avail = "/proc/sys/kernel/random/entropy_avail";
const char *entropy_poolsize = "/proc/sys/kernel/random/poolsize";
FILE *fp1, *fp2;
info.entropy.entropy_avail=0;
info.entropy.poolsize=0;
if ( ((fp1 = open_file (entropy_avail, &rep))==NULL) ||
((fp2 = open_file (entropy_poolsize, &rep))==NULL) )
return;
fscanf (fp1, "%u", &info.entropy.entropy_avail);
fscanf (fp2, "%u", &info.entropy.poolsize);
fclose (fp1);
fclose (fp2);
}

View File

@ -366,3 +366,7 @@ void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
return; return;
} }
void update_entropy (void)
{
}