1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#include <ndbapi/NdbApi.hpp>
22
* export LD_LIBRARY_PATH=../../../libmysql_r/.libs:../../../ndb/src/.libs
27
fprintf(stderr, "code: %d msg: %s\n", \
28
ndb_mgm_get_latest_error(h), \
29
ndb_mgm_get_latest_error_msg(h)); \
33
#define LOGEVENTERROR(h) \
35
fprintf(stderr, "code: %d msg: %s\n", \
36
ndb_logevent_get_latest_error(h), \
37
ndb_logevent_get_latest_error_msg(h)); \
41
int main(int argc, char** argv)
45
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP,
46
15, NDB_MGM_EVENT_CATEGORY_CONNECTION,
47
15, NDB_MGM_EVENT_CATEGORY_NODE_RESTART,
48
15, NDB_MGM_EVENT_CATEGORY_STARTUP,
49
15, NDB_MGM_EVENT_CATEGORY_ERROR,
51
struct ndb_logevent event;
55
printf("Arguments are <connect_string cluster> [<iterations>].\n");
58
const char *connectstring = argv[1];
61
iterations = atoi(argv[2]);
64
h= ndb_mgm_create_handle();
67
printf("Unable to create handle\n");
70
if (ndb_mgm_set_connectstring(h, connectstring) == -1)
72
printf("Unable to set connectstring\n");
75
if (ndb_mgm_connect(h,0,0,0)) MGMERROR(h);
77
le= ndb_mgm_create_logevent_handle(h, filter);
78
if ( le == 0 ) MGMERROR(h);
80
while (iterations-- != 0)
83
int r= ndb_logevent_get_next(le,&event,timeout);
85
printf("No event within %d milliseconds\n", timeout);
91
case NDB_LE_BackupStarted:
92
printf("Node %d: BackupStarted\n", event.source_nodeid);
93
printf(" Starting node ID: %d\n", event.BackupStarted.starting_node);
94
printf(" Backup ID: %d\n", event.BackupStarted.backup_id);
96
case NDB_LE_BackupCompleted:
97
printf("Node %d: BackupCompleted\n", event.source_nodeid);
98
printf(" Backup ID: %d\n", event.BackupStarted.backup_id);
100
case NDB_LE_BackupAborted:
101
printf("Node %d: BackupAborted\n", event.source_nodeid);
103
case NDB_LE_BackupFailedToStart:
104
printf("Node %d: BackupFailedToStart\n", event.source_nodeid);
107
case NDB_LE_NodeFailCompleted:
108
printf("Node %d: NodeFailCompleted\n", event.source_nodeid);
110
case NDB_LE_ArbitResult:
111
printf("Node %d: ArbitResult\n", event.source_nodeid);
112
printf(" code %d, arbit_node %d\n",
113
event.ArbitResult.code & 0xffff,
114
event.ArbitResult.arbit_node);
116
case NDB_LE_DeadDueToHeartbeat:
117
printf("Node %d: DeadDueToHeartbeat\n", event.source_nodeid);
118
printf(" node %d\n", event.DeadDueToHeartbeat.node);
121
case NDB_LE_Connected:
122
printf("Node %d: Connected\n", event.source_nodeid);
123
printf(" node %d\n", event.Connected.node);
125
case NDB_LE_Disconnected:
126
printf("Node %d: Disconnected\n", event.source_nodeid);
127
printf(" node %d\n", event.Disconnected.node);
129
case NDB_LE_NDBStartCompleted:
130
printf("Node %d: StartCompleted\n", event.source_nodeid);
131
printf(" version %d.%d.%d\n",
132
event.NDBStartCompleted.version >> 16 & 0xff,
133
event.NDBStartCompleted.version >> 8 & 0xff,
134
event.NDBStartCompleted.version >> 0 & 0xff);
136
case NDB_LE_ArbitState:
137
printf("Node %d: ArbitState\n", event.source_nodeid);
138
printf(" code %d, arbit_node %d\n",
139
event.ArbitState.code & 0xffff,
140
event.ArbitResult.arbit_node);
149
ndb_mgm_destroy_logevent_handle(&le);
150
ndb_mgm_destroy_handle(&h);