-> | GETVAL myhost/cpu-0/cpu-user
<- | 1 value=1.260000e+00
+=item B<LISTVAL>
+
+Returnes a list of the values available in the value cache together with the
+time of the last update, so that querying applications can issue a B<GETVAL>
+command for the values that have changed.
+
+The first line's status number is the number of identifiers returned or less
+than zero if an error occured. Each of the following lines containes the
+update time as an epoch value and the identifier, seperated by a space.
+
+Example:
+ -> | LISTVAL
+ <- | 69 Values found
+ <- | 1182204284 leeloo/cpu-0/cpu-idle
+ <- | 1182204284 leeloo/cpu-0/cpu-nice
+ <- | 1182204284 leeloo/cpu-0/cpu-system
+ <- | 1182204284 leeloo/cpu-0/cpu-user
+ ...
+
=item B<PUTVAL> I<Identifier> I<Valuelist>
Submits a value (identified by I<Identifier>, see below) to the daemon which
} /* while (this != NULL) */
pthread_mutex_unlock (&cache_lock);
-} /* int cache_flush */
+} /* void cache_flush */
static int us_open_socket (void)
{
return (0);
} /* int us_handle_putval */
+static int us_handle_listval (FILE *fh, char **fields, int fields_num)
+{
+ char buffer[1024];
+ char **value_list = NULL;
+ int value_list_len = 0;
+ value_cache_t *entry;
+ int i;
+
+ if (fields_num != 1)
+ {
+ DEBUG ("unixsock plugin: us_handle_listval: "
+ "Wrong number of fields: %i", fields_num);
+ fprintf (fh, "-1 Wrong number of fields: Got %i, expected 1.\n",
+ fields_num);
+ fflush (fh);
+ return (-1);
+ }
+
+ pthread_mutex_lock (&cache_lock);
+
+ for (entry = cache_head; entry != NULL; entry = entry->next)
+ {
+ char **tmp;
+
+ snprintf (buffer, sizeof (buffer), "%u %s\n",
+ (unsigned int) entry->time, entry->name);
+ buffer[sizeof (buffer) - 1] = '\0';
+
+ tmp = realloc (value_list, sizeof (char *) * (value_list_len + 1));
+ if (tmp == NULL)
+ continue;
+ value_list = tmp;
+
+ value_list[value_list_len] = strdup (buffer);
+
+ if (value_list[value_list_len] != NULL)
+ value_list_len++;
+ } /* for (entry) */
+
+ pthread_mutex_unlock (&cache_lock);
+
+ DEBUG ("unixsock plugin: us_handle_listval: value_list_len = %i", value_list_len);
+ fprintf (fh, "%i Values found\n", value_list_len);
+ for (i = 0; i < value_list_len; i++)
+ fputs (value_list[i], fh);
+ fflush (fh);
+
+ return (0);
+} /* int us_handle_listval */
+
static void *us_handle_client (void *arg)
{
int fd;
{
us_handle_putval (fh, fields, fields_num);
}
+ else if (strcasecmp (fields[0], "listval") == 0)
+ {
+ us_handle_listval (fh, fields, fields_num);
+ }
else
{
fprintf (fh, "-1 Unknown command: %s\n", fields[0]);