19 #include <ndb_global.h>
23 #include "Sysfile.hpp"
28 usage(
const char * prg){
29 ndbout <<
"Usage " << prg
30 <<
" P[0-1].sysfile" << endl;
40 { Sysfile::NS_Active,
"Active " },
41 { Sysfile::NS_ActiveMissed_1,
"Active missed 1" },
42 { Sysfile::NS_ActiveMissed_2,
"Active missed 2" },
43 { Sysfile::NS_ActiveMissed_3,
"Active missed 3" },
44 { Sysfile::NS_NotActive_NotTakenOver,
"Not active " },
45 { Sysfile::NS_TakeOver,
"Take over " },
46 { Sysfile::NS_NotActive_TakenOver,
"Taken over " },
47 { Sysfile::NS_NotDefined,
"Not defined " }
48 ,{ Sysfile::NS_Configured,
"Configured " }
52 char * getNSString(Uint32 ns){
53 for(Uint32
i = 0;
i<(
sizeof(NodeStatusStrings)/
sizeof(
NSString));
i++)
54 if((Uint32)NodeStatusStrings[
i].NodeStatus == ns)
55 return NodeStatusStrings[
i].desc;
56 return "<Unknown state>";
60 fill(
const char *
buf,
int mod){
61 int len = strlen(buf)+1;
63 while((len % mod) != 0){
70 print(
const char * filename,
const Sysfile * sysfile){
72 ndbout <<
"----- Sysfile: " << filename
75 ndbout <<
"Initial start ongoing: "
79 ndbout <<
"Restart Ongoing: "
80 << Sysfile::getRestartOngoing(sysfile->systemRestartBits)
83 ndbout <<
"LCP Ongoing: "
84 << Sysfile::getLCPOngoing(sysfile->systemRestartBits)
88 ndbout <<
"-- Global Checkpoint Identities: --" << endl;
89 sprintf(buf,
"keepGCI = %u", sysfile->keepGCI);
91 ndbout <<
" -- Tail of REDO log" << endl;
93 sprintf(buf,
"oldestRestorableGCI = %u", sysfile->oldestRestorableGCI);
95 ndbout <<
" -- " << endl;
97 sprintf(buf,
"newestRestorableGCI = %u", sysfile->newestRestorableGCI);
99 ndbout <<
" -- " << endl;
101 sprintf(buf,
"latestLCP = %u", sysfile->latestLCP_ID);
103 ndbout <<
" -- " << endl;
105 ndbout <<
"-- Node status: --" << endl;
106 for(
int i = 1;
i < MAX_NDB_NODES;
i++){
107 if(g_all || Sysfile::getNodeStatus(
i, sysfile->nodeStatus) !=Sysfile::NS_NotDefined){
109 "Node %.2d -- %s GCP: %d, NodeGroup: %d, TakeOverNode: %d, "
112 getNSString(Sysfile::getNodeStatus(
i,sysfile->nodeStatus)),
114 Sysfile::getNodeGroup(
i, sysfile->nodeGroups),
115 Sysfile::getTakeOverNode(
i, sysfile->takeOver),
118 ndbout << buf << endl;
123 NDB_COMMAND(printSysfile,
124 "printSysfile",
"printSysfile",
"Prints a sysfile", 16384){
131 for(
int i = 1;
i<argc;
i++){
132 const char * filename = argv[
i];
134 if (strcmp(filename,
"--all") == 0)
142 if(stat(filename, &sbuf) != 0)
144 ndbout <<
"Could not find file: \"" << filename <<
"\"" << endl;
147 const Uint32 bytes = sbuf.st_size;
149 Uint32 * buf =
new Uint32[bytes/4+1];
151 FILE * f = fopen(filename,
"rb");
153 ndbout <<
"Failed to open file" << endl;
157 Uint32 sz = (Uint32)fread(buf, 1, bytes, f);
160 ndbout <<
"Failure while reading file" << endl;
165 print(filename, (
Sysfile *)&buf[0]);