added , , for crypto freaks
authorPhilip Kovacs <pkovacs@users.sourceforge.net>
Thu, 30 Nov 2006 20:46:34 +0000 (20:46 +0000)
committerPhilip Kovacs <pkovacs@users.sourceforge.net>
Thu, 30 Nov 2006 20:46:34 +0000 (20:46 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@797 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
README
doc/conky.1
doc/variables.xml
src/common.c
src/conky.c
src/conky.h
src/freebsd.c
src/linux.c
src/netbsd.c

index eb5cb49..973ba6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 # $Id$
 
+2006-11-30
+       * Added $entropy_avail, $entropy_poolsize and $entropy_bar
+       for the crypto freaks.
+
 2006-11-28
        * Rearrange retry attempts in pop3 and imap code, removing sleep() 
        calls which cause the whole process to sleep, not just the thread.
diff --git a/README b/README
index 62d3e33..d894dff 100644 (file)
--- a/README
+++ b/README
@@ -551,6 +551,18 @@ VARIABLES
        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
              Executes a shell command and displays the output in conky. warn-
              ing:  this  takes a lot more resources than other variables. I'd
index 520135e..644d933 100644 (file)
@@ -520,6 +520,18 @@ Download speed graph, colours defined in hex, minus the #. If scale is non-zero,
 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 
 \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.
 
index 93dd23d..9c5ab0d 100644 (file)
 
 <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>
+       <term>
                <command><option>exec</option></command>
        <option>command</option>
        </term>
index e0d6365..6ac265a 100644 (file)
@@ -257,6 +257,8 @@ void update_stuff()
        if (NEED(INFO_TCP_PORT_MONITOR))
                update_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
 #endif
+       if (NEED(INFO_ENTROPY))
+               update_entropy();
 }
 
 int round_to_int(float f)
index 23ba263..ade1f8e 100644 (file)
@@ -1081,6 +1081,9 @@ enum text_object_type {
 #ifdef HDDTEMP
        OBJ_hddtemp,
 #endif
+       OBJ_entropy_avail,
+       OBJ_entropy_poolsize,
+       OBJ_entropy_bar
 };
 
 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);
                                break;
 #endif
+                       case OBJ_entropy_avail:
+                       case OBJ_entropy_poolsize:
+                       case OBJ_entropy_bar:
+                               break;
                }
        }
        free(objs);
@@ -2966,6 +2973,12 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
        }
        END
 #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];
                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;
                        }
 #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;
                }
index 67f9c65..4693df7 100644 (file)
@@ -186,6 +186,12 @@ struct bmpx_s {
 };
 #endif
 
+void update_entropy();
+struct entropy_s {
+       unsigned int entropy_avail;
+       unsigned int poolsize;
+};
+
 #ifdef TCP_PORT_MONITOR
 #include "libtcp-portmon.h"
 #define MIN_PORT_MONITORS_DEFAULT 16
@@ -226,6 +232,7 @@ enum {
 #ifdef XMMS2
        INFO_XMMS2 = 22,
 #endif
+       INFO_ENTROPY = 23,
 };
 
 
@@ -288,6 +295,7 @@ struct information {
         tcp_port_monitor_collection_t * p_tcp_port_monitor_collection;
 #endif
        short kflags;  /* kernel settings, see enum KFLAG */
+       struct entropy_s entropy;
 };
 
 enum {
index 4ffeb8a..1ddc2a1 100644 (file)
@@ -876,6 +876,11 @@ char
 
 #endif
 
+void update_entropy (void)
+{
+     /* mirrorbox: can you do anything equivalent in freebsd? -drphibes. */
+}
+
 /* empty stub so conky links */
 void
 free_all_processes(void)
index 4a63514..8193a38 100644 (file)
@@ -1756,3 +1756,24 @@ Peter Tarjan (ptarjan@citromail.hu)
     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);
+}
index 5a335f0..57b4ebb 100644 (file)
@@ -366,3 +366,7 @@ void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
 
        return;
 }
+
+void update_entropy (void)
+{
+}