Fix typo.
[glibc/history.git] / nscd / nscd_stat.c
blobd8182885ac9231c712c9fdada65cd9290bf6a92d
1 /* Copyright (c) 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <sys/types.h>
24 #include "nscd.h"
26 void
27 print_stat (void)
29 int sock = __nscd_open_socket ();
30 request_header req;
31 stat_response_header resp;
32 ssize_t nbytes;
34 if (sock == -1)
36 fputs (_("nscd not running!\n"), stdout);
37 exit (EXIT_FAILURE);
40 req.version = NSCD_VERSION;
41 req.type = GETSTAT;
42 req.key_len = 0;
43 nbytes = write (sock, &req, sizeof (request_header));
44 if (nbytes != sizeof (request_header))
46 perror (_("write incomplete"));
47 close (sock);
48 exit (EXIT_FAILURE);
51 nbytes = read (sock, &resp, sizeof (stat_response_header));
52 if (nbytes != sizeof (stat_response_header))
54 perror (_("read incomplete"));
55 close (sock);
56 exit (EXIT_FAILURE);
59 close (sock);
61 printf (_("nscd configuration:\n\n"));
62 printf (_("%12d server debug level\n\n"), resp.debug_level);
64 printf (_("passwd cache:\n\n"));
65 printf (_("%12s cache is enabled\n"), resp.pw_enabled ? _("Yes") : _("No"));
66 printf (_("%12ld cache hits on positive entries\n"), resp.pw_poshit);
67 printf (_("%12ld cache hits on negative entries\n"), resp.pw_neghit);
68 printf (_("%12ld cache misses on positive entries\n"), resp.pw_posmiss);
69 printf (_("%12ld cache misses on negative entries\n"), resp.pw_negmiss);
70 printf (_("%12ld suggested size\n"), resp.pw_size);
71 printf (_("%12ld seconds time to live for positive entries\n"),
72 resp.pw_posttl);
73 printf (_("%12ld seconds time to live for negative entries\n\n"),
74 resp.pw_negttl);
76 printf (_("group cache:\n\n"));
77 printf (_("%12s cache is enabled\n"), resp.gr_enabled ? _("Yes") : _("No"));
78 printf (_("%12ld cache hits on positive entries\n"), resp.gr_poshit);
79 printf (_("%12ld cache hits on negative entries\n"), resp.gr_neghit);
80 printf (_("%12ld cache misses on positive entries\n"), resp.gr_posmiss);
81 printf (_("%12ld cache misses on negative entries\n"), resp.gr_negmiss);
82 printf (_("%12ld suggested size\n"), resp.gr_size);
83 printf (_("%12ld seconds time to live for positive entries\n"),
84 resp.gr_posttl);
85 printf (_("%12ld seconds time to live for negative entries\n"),
86 resp.gr_negttl);