Update Debian Vcs-* fields to point to git repository
[onak.git] / keydctl.c
index 96af7d2e61c12e018ffa9fb0238fbb191e990b0c..e46a355c5aa41aa5030c75c0cd3c04e1e1eb6815 100644 (file)
--- a/keydctl.c
+++ b/keydctl.c
@@ -2,12 +2,26 @@
  * keydctl.c - A simple program to control a running keyd instance
  *
  * Copyright 2011 Jonathan McDowell <noodles@earth.li>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -138,10 +152,37 @@ static void keyd_close(void)
 static void keyd_status(void)
 {
        uint32_t reply;
+       struct keyd_stats stats;
 
        keyd_do_command(KEYD_CMD_VERSION, &reply, sizeof(reply));
        printf("Using keyd protocol version %d.\n", reply);
 
+       keyd_do_command(KEYD_CMD_STATS, &stats, sizeof(stats));
+       printf("keyd running since %s", ctime(&stats.started));
+       printf("%d client connections received\n", stats.connects);
+
+       printf("Command statistics:\n");
+       printf("  Version:          %d\n",
+               stats.command_stats[KEYD_CMD_VERSION]);
+       printf("  Get key:          %d\n", stats.command_stats[KEYD_CMD_GET]);
+       printf("  Store key:        %d\n",
+               stats.command_stats[KEYD_CMD_STORE]);
+       printf("  Delete key:       %d\n",
+               stats.command_stats[KEYD_CMD_DELETE]);
+       printf("  Search key:       %d\n",
+               stats.command_stats[KEYD_CMD_GETTEXT]);
+       printf("  Get full keyid:   %d\n",
+               stats.command_stats[KEYD_CMD_GETFULLKEYID]);
+       printf("  Iterate all keys: %d\n",
+               stats.command_stats[KEYD_CMD_KEYITER]);
+       printf("  Close:            %d\n",
+               stats.command_stats[KEYD_CMD_CLOSE]);
+       printf("  Quit:             %d\n", stats.command_stats[KEYD_CMD_QUIT]);
+       printf("  Get statistics:   %d\n",
+               stats.command_stats[KEYD_CMD_STATS]);
+       printf("  Unknown:          %d\n",
+               stats.command_stats[KEYD_CMD_UNKNOWN]);
+
        return;
 }