Diagnostics

- Added server info to the diagnostics command output.
This commit is contained in:
Paul Beckingham 2012-10-06 09:05:20 -04:00
parent ce2f7054f7
commit 5a9810a423
2 changed files with 28 additions and 24 deletions

View file

@ -74,7 +74,7 @@ int CmdDiagnostics::execute (std::string& output)
<< bold.colorize (PACKAGE_STRING) << bold.colorize (PACKAGE_STRING)
<< "\n"; << "\n";
out << " " << STRING_CMD_DIAG_PLATFORM << ": " out << " " << STRING_CMD_DIAG_PLATFORM << ": "
<< <<
#if defined (DARWIN) #if defined (DARWIN)
"Darwin" "Darwin"
@ -95,16 +95,19 @@ int CmdDiagnostics::execute (std::string& output)
#else #else
STRING_CMD_DIAG_UNKNOWN STRING_CMD_DIAG_UNKNOWN
#endif #endif
<< "\n"
<< STRING_CMD_DIAG_SERVER << ": "
<< context.config.get ("taskd.server")
<< "\n\n"; << "\n\n";
// Compiler. // Compiler.
out << bold.colorize (STRING_CMD_DIAG_COMPILER) out << bold.colorize (STRING_CMD_DIAG_COMPILER)
<< "\n" << "\n"
#ifdef __VERSION__ #ifdef __VERSION__
<< " " << STRING_CMD_DIAG_VERSION << ": " << " " << STRING_CMD_DIAG_VERSION << ": "
<< __VERSION__ << "\n" << __VERSION__ << "\n"
#endif #endif
<< " " << STRING_CMD_DIAG_CAPS << ":" << " " << STRING_CMD_DIAG_CAPS << ":"
#ifdef __STDC__ #ifdef __STDC__
<< " +stdc" << " +stdc"
#endif #endif
@ -135,7 +138,7 @@ int CmdDiagnostics::execute (std::string& output)
out << bold.colorize (STRING_CMD_DIAG_LIBRARIES) out << bold.colorize (STRING_CMD_DIAG_LIBRARIES)
<< "\n"; << "\n";
out << " Lua: " out << " Lua: "
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
<< LUA_RELEASE << LUA_RELEASE
#else #else
@ -143,7 +146,7 @@ int CmdDiagnostics::execute (std::string& output)
#endif #endif
<< "\n"; << "\n";
out << " libuuid: " out << " libuuid: "
#if defined (HAVE_UUID) and defined (HAVE_UUID_UNPARSE_LOWER) #if defined (HAVE_UUID) and defined (HAVE_UUID_UNPARSE_LOWER)
<< "libuuid + uuid_unparse_lower" << "libuuid + uuid_unparse_lower"
#elif defined (HAVE_UUID) and !defined (HAVE_UUID_UNPARSE_LOWER) #elif defined (HAVE_UUID) and !defined (HAVE_UUID_UNPARSE_LOWER)
@ -157,10 +160,10 @@ int CmdDiagnostics::execute (std::string& output)
<< "\n" << "\n"
// Build date. // Build date.
<< " " << STRING_CMD_DIAG_BUILT << ": " << __DATE__ << " " << __TIME__ << "\n" << " " << STRING_CMD_DIAG_BUILT << ": " << __DATE__ << " " << __TIME__ << "\n"
<< " " << STRING_CMD_DIAG_COMMIT << ": " << COMMIT << "\n" << " " << STRING_CMD_DIAG_COMMIT << ": " << COMMIT << "\n"
<< " CMake: " << CMAKE_VERSION << "\n" << " CMake: " << CMAKE_VERSION << "\n"
<< " " << STRING_CMD_DIAG_CAPS << ":" << " " << STRING_CMD_DIAG_CAPS << ":"
#ifdef HAVE_LIBPTHREAD #ifdef HAVE_LIBPTHREAD
<< " +pthreads" << " +pthreads"
#else #else
@ -189,7 +192,7 @@ int CmdDiagnostics::execute (std::string& output)
// Config: .taskrc found, readable, writable // Config: .taskrc found, readable, writable
out << bold.colorize (STRING_CMD_DIAG_CONFIG) out << bold.colorize (STRING_CMD_DIAG_CONFIG)
<< "\n" << "\n"
<< " File: " << context.config._original_file._data << " " << " File: " << context.config._original_file._data << " "
<< (context.config._original_file.exists () << (context.config._original_file.exists ()
? STRING_CMD_DIAG_FOUND ? STRING_CMD_DIAG_FOUND
: STRING_CMD_DIAG_MISSING) : STRING_CMD_DIAG_MISSING)
@ -201,7 +204,7 @@ int CmdDiagnostics::execute (std::string& output)
// Config: data.location found, readable, writable // Config: data.location found, readable, writable
File location (context.config.get ("data.location")); File location (context.config.get ("data.location"));
out << " Data: " << location._data << " " out << " Data: " << location._data << " "
<< (location.exists () << (location.exists ()
? STRING_CMD_DIAG_FOUND ? STRING_CMD_DIAG_FOUND
: STRING_CMD_DIAG_MISSING) : STRING_CMD_DIAG_MISSING)
@ -211,11 +214,11 @@ int CmdDiagnostics::execute (std::string& output)
<< location.mode () << location.mode ()
<< "\n"; << "\n";
out << " Server: " out << " Server: "
<< context.config.get ("taskd.server") << context.config.get ("taskd.server")
<< "\n"; << "\n";
out << " Locking: " out << " Locking: "
<< (context.config.getBoolean ("locking") << (context.config.getBoolean ("locking")
? STRING_CMD_DIAG_ENABLED ? STRING_CMD_DIAG_ENABLED
: STRING_CMD_DIAG_DISABLED) : STRING_CMD_DIAG_DISABLED)
@ -224,11 +227,11 @@ int CmdDiagnostics::execute (std::string& output)
// Determine rc.editor/$EDITOR/$VISUAL. // Determine rc.editor/$EDITOR/$VISUAL.
char* peditor; char* peditor;
if (context.config.get ("editor") != "") if (context.config.get ("editor") != "")
out << " rc.editor: " << context.config.get ("editor") << "\n"; out << " rc.editor: " << context.config.get ("editor") << "\n";
else if ((peditor = getenv ("VISUAL")) != NULL) else if ((peditor = getenv ("VISUAL")) != NULL)
out << " $VISUAL: " << peditor << "\n"; out << " $VISUAL: " << peditor << "\n";
else if ((peditor = getenv ("EDITOR")) != NULL) else if ((peditor = getenv ("EDITOR")) != NULL)
out << " $EDITOR: " << peditor << "\n"; out << " $EDITOR: " << peditor << "\n";
out << "\n"; out << "\n";
@ -246,7 +249,7 @@ int CmdDiagnostics::execute (std::string& output)
RX r ("usage", false); RX r ("usage", false);
if (p) if (p)
out << " scp: " out << " scp: "
<< (r.match (buffer) << (r.match (buffer)
? STRING_CMD_DIAG_FOUND ? STRING_CMD_DIAG_FOUND
: STRING_CMD_DIAG_MISSING) : STRING_CMD_DIAG_MISSING)
@ -264,7 +267,7 @@ int CmdDiagnostics::execute (std::string& output)
RX r ("version ([0-9]+\\.[0-9]+\\.[0-9]+)", false); RX r ("version ([0-9]+\\.[0-9]+\\.[0-9]+)", false);
matches.clear (); matches.clear ();
r.match (matches, buffer); r.match (matches, buffer);
out << " rsync: " out << " rsync: "
<< (matches.size () ? matches[0] : STRING_CMD_DIAG_MISSING) << (matches.size () ? matches[0] : STRING_CMD_DIAG_MISSING)
<< "\n"; << "\n";
} }
@ -281,7 +284,7 @@ int CmdDiagnostics::execute (std::string& output)
RX r ("curl ([0-9]+\\.[0-9]+\\.[0-9]+)", false); RX r ("curl ([0-9]+\\.[0-9]+\\.[0-9]+)", false);
matches.clear (); matches.clear ();
r.match (matches, buffer); r.match (matches, buffer);
out << " curl: " out << " curl: "
<< (matches.size () ? matches[0] : STRING_CMD_DIAG_MISSING) << (matches.size () ? matches[0] : STRING_CMD_DIAG_MISSING)
<< "\n"; << "\n";
} }
@ -294,7 +297,7 @@ int CmdDiagnostics::execute (std::string& output)
out << bold.colorize (STRING_CMD_DIAG_TESTS) out << bold.colorize (STRING_CMD_DIAG_TESTS)
<< "\n"; << "\n";
{ {
out << " UUID gen: "; out << " UUID gen: ";
std::vector <std::string> uuids; std::vector <std::string> uuids;
std::string id; std::string id;
for (int i = 0; i < 1000; i++) for (int i = 0; i < 1000; i++)
@ -314,7 +317,7 @@ int CmdDiagnostics::execute (std::string& output)
// Determine terminal details. // Determine terminal details.
const char* term = getenv ("TERM"); const char* term = getenv ("TERM");
out << " $TERM: " out << " $TERM: "
<< (term ? term : STRING_CMD_DIAG_NONE) << (term ? term : STRING_CMD_DIAG_NONE)
<< " (" << " ("
<< context.getWidth () << context.getWidth ()
@ -337,7 +340,7 @@ int CmdDiagnostics::execute (std::string& output)
seen[uuid] = 0; seen[uuid] = 0;
} }
out << " Dups: " out << " Dups: "
<< format (STRING_CMD_DIAG_UUID_SCAN, all.size ()) << format (STRING_CMD_DIAG_UUID_SCAN, all.size ())
<< "\n"; << "\n";
@ -345,11 +348,11 @@ int CmdDiagnostics::execute (std::string& output)
{ {
std::vector <std::string>::iterator d; std::vector <std::string>::iterator d;
for (d = dups.begin (); d != dups.end (); ++d) for (d = dups.begin (); d != dups.end (); ++d)
out << " " << format (STRING_CMD_DIAG_UUID_DUP, *d) << "\n"; out << " " << format (STRING_CMD_DIAG_UUID_DUP, *d) << "\n";
} }
else else
{ {
out << " " << STRING_CMD_DIAG_UUID_NO_DUP out << " " << STRING_CMD_DIAG_UUID_NO_DUP
<< "\n"; << "\n";
} }
} }

View file

@ -433,6 +433,7 @@
#define STRING_CMD_DIAG_UUID_SCAN "Scanned {1} tasks for duplicate UUIDs:" #define STRING_CMD_DIAG_UUID_SCAN "Scanned {1} tasks for duplicate UUIDs:"
#define STRING_CMD_DIAG_UUID_DUP "Found duplicate {1}" #define STRING_CMD_DIAG_UUID_DUP "Found duplicate {1}"
#define STRING_CMD_DIAG_UUID_NO_DUP "No duplicates found" #define STRING_CMD_DIAG_UUID_NO_DUP "No duplicates found"
#define STRING_CMD_DIAG_SERVER "Task Server"
#define STRING_CMD_DIAG_NONE "-none-" #define STRING_CMD_DIAG_NONE "-none-"
#define STRING_CMD_PUSH_USAGE "Pushes the local files to the URL" #define STRING_CMD_PUSH_USAGE "Pushes the local files to the URL"
#define STRING_CMD_PUSH_SAME "Cannot push files when the source and destination are the same." #define STRING_CMD_PUSH_SAME "Cannot push files when the source and destination are the same."