2
* statdb_dump.c -- dump contents of statd's monitor DB
4
* Copyright (C) 2010 Red Hat, Jeff Layton <jlayton@redhat.com>
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
28
#include <arpa/inet.h>
33
static char cookiebuf[(SM_PRIV_SIZE * 2) + 1];
34
static char addrbuf[INET6_ADDRSTRLEN + 1];
37
dump_host(const char *hostname, const struct sockaddr *sa, const struct mon *m,
38
const time_t timestamp)
42
const struct sockaddr_in *sin;
43
const struct sockaddr_in6 *sin6;
45
ret = nsm_priv_to_hex(m->priv, cookiebuf, sizeof(cookiebuf));
47
xlog(L_ERROR, "Unable to convert cookie to hex string.\n");
51
switch (sa->sa_family) {
53
sin = (struct sockaddr_in *)(char *)sa;
54
addr = inet_ntop(sa->sa_family, &sin->sin_addr.s_addr, addrbuf,
55
(socklen_t)sizeof(addrbuf));
58
sin6 = (struct sockaddr_in6 *)(char *)sa;
59
addr = inet_ntop(sa->sa_family, &sin6->sin6_addr, addrbuf,
60
(socklen_t)sizeof(addrbuf));
63
xlog(L_ERROR, "Unrecognized address family: %hu\n",
69
xlog(L_ERROR, "Unable to convert sockaddr to string: %s\n",
75
* Callers of this program should assume that in the future, extra
76
* fields may be added to the output. Anyone adding extra fields to
77
* the output should add them to the end of the line.
79
printf("%s %s %s %s %s %d %d %d\n",
80
hostname, addr, cookiebuf,
82
m->mon_id.my_id.my_name,
83
m->mon_id.my_id.my_prog,
84
m->mon_id.my_id.my_vers,
85
m->mon_id.my_id.my_proc);
91
main(int argc, char **argv)
97
nsm_load_monitor_list(dump_host);