diff options
author | Benoit Foucher <benoit@zeroc.com> | 2009-12-08 14:37:44 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2009-12-08 14:37:44 +0100 |
commit | 33a83ee4f83e9c3ed820f90122d8106dc9b41e74 (patch) | |
tree | 246b83b711150264ff79d1433b45e534b8a765d6 /cpp/src/IceGrid/Parser.cpp | |
parent | Fixes for the plugin demo (diff) | |
download | ice-33a83ee4f83e9c3ed820f90122d8106dc9b41e74.tar.bz2 ice-33a83ee4f83e9c3ed820f90122d8106dc9b41e74.tar.xz ice-33a83ee4f83e9c3ed820f90122d8106dc9b41e74.zip |
Fix for bug 3234 - Initial support for getting processor socket count with IceGrid
Diffstat (limited to 'cpp/src/IceGrid/Parser.cpp')
-rw-r--r-- | cpp/src/IceGrid/Parser.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 9d5c37df304..1fa2f0c8c51 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -89,6 +89,10 @@ static const char* _commandsHelp[][3] = { { "node", "load", "node load NAME Print the load of the node NAME.\n" }, +{ "node", "processors", +"node processors [NAME] Print the number of processor socket of the\n" +" node NAME or all the nodes if NAME is omitted.\n" +}, { "node", "show", "node show [OPTIONS] NAME [stderr | stdout]\n" " Show node NAME stderr or stdout.\n" @@ -820,6 +824,60 @@ Parser::printLoadNode(const list<string>& args) } void +Parser::printNodeProcessors(const list<string>& args) +{ + if(args.size() > 1) + { + invalidCommand("node processors", "requires no more than one argument"); + return; + } + + try + { + if(args.size() == 1) + { + cout << _admin->getNodeProcessorSocketCount(args.front()) << endl; + } + else + { + Ice::StringSeq names = _admin->getAllNodeNames(); + map<string, pair< vector<string>, int> > processorSocketCounts; + for(Ice::StringSeq::const_iterator p = names.begin(); p != names.end(); p++) + { + try + { + NodeInfo info = _admin->getNodeInfo(*p); + processorSocketCounts[info.hostname].first.push_back(*p); + processorSocketCounts[info.hostname].second = _admin->getNodeProcessorSocketCount(*p); + } + catch(const NodeNotExistException&) + { + } + catch(const NodeUnreachableException&) + { + } + } + + cout.flags(ios::left); + cout << setw(20) << "Hostname" << setw(20) << "| # of sockets" << setw(39) << "| Nodes" << endl; + cout << setw(79) << "=====================================================================" << endl; + for(map<string, pair< vector<string>, int> >::const_iterator q = processorSocketCounts.begin(); + q != processorSocketCounts.end(); ++q) + { + cout << setw(20) << setiosflags(ios::left) <<q->first; + cout << "| " << setw(18) << setiosflags(ios::left) << q->second.second; + cout << "| " << setw(37) << setiosflags(ios::left) << toString(q->second.first); + cout << endl; + } + } + } + catch(const Ice::Exception& ex) + { + exception(ex); + } +} + +void Parser::shutdownNode(const list<string>& args) { if(args.size() != 1) |