X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydctl.c;h=11e5e8f3ae4fdfe0aaba40a8f20afab618a31cc5;hb=f31f6d8cf4bda52b8ef1b1d1d280884e904429a9;hp=b786fea3e9c7f5ae3bb662d53f7dd4f269182da9;hpb=3e3f47ec2fdbfaf0682d9790a99264a4e60e9bf1;p=onak.git diff --git a/keydctl.c b/keydctl.c index b786fea..11e5e8f 100644 --- a/keydctl.c +++ b/keydctl.c @@ -2,20 +2,34 @@ * keydctl.c - A simple program to control a running keyd instance * * Copyright 2011 Jonathan McDowell + * + * 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 #include #include #include +#include #include #include #include #include -#include "config.h" #include "keyd.h" #include "onak-conf.h" +#include "version.h" /* HACK: We need to stop onak-conf.o requiring this. */ void *DBFUNCS = NULL; @@ -138,18 +152,45 @@ 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; } static void usage(void) { - puts("keydctl " PACKAGE_VERSION " - control an onak keyd instance.\n"); + puts("keydctl " ONAK_VERSION " - control an onak keyd instance.\n"); puts("Usage:\n"); - puts("\tonak [options] \n"); + puts("\tkeydctl [options] \n"); puts("\tCommands:\n"); puts("\tcheck - check if keyd is running"); puts("\tquit - request that keyd cleanly shuts down");