summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid/Parser.cpp')
-rw-r--r--cpp/src/IceGrid/Parser.cpp58
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)