From 33a83ee4f83e9c3ed820f90122d8106dc9b41e74 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Tue, 8 Dec 2009 14:37:44 +0100 Subject: Fix for bug 3234 - Initial support for getting processor socket count with IceGrid --- cpp/src/IceGrid/Parser.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'cpp/src/IceGrid/Parser.cpp') 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" @@ -819,6 +823,60 @@ Parser::printLoadNode(const list& args) } } +void +Parser::printNodeProcessors(const list& 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, 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, int> >::const_iterator q = processorSocketCounts.begin(); + q != processorSocketCounts.end(); ++q) + { + cout << setw(20) << setiosflags(ios::left) <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& args) { -- cgit v1.2.3