#include <iostream>
#include <cstdio>
#include <unistd.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "XrdApps/XrdMpxXml.hh"
#include "XrdCl/XrdClBuffer.hh"
#include "XrdCl/XrdClFileSystem.hh"
#include "XrdCl/XrdClURL.hh"
#include "XrdCl/XrdClXRootDResponses.hh"
Go to the source code of this file.
◆ Fatal()
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 87 of file XrdQStats.cc.
93 const char *
Stats =
"bldpsu", *pgm =
"xrdqstats: ";
94 const char *valOpts =
"df:i:n:s:z";
95 int WTime = 0, Count = 0;
98 bool Debug =
false, nozed =
false;
103 if (argc > 1 &&
'-' == *argv[1])
104 while ((c = getopt(argc,argv,valOpts)) && ((
unsigned char)c != 0xff))
107 case 'd':
Debug =
true;
112 else {std::cerr <<pgm <<
"Invalid format - " <<optarg <<std::endl;
118 case 'i':
if ((WTime = atoi(optarg)) <= 0)
119 {std::cerr <<pgm <<
"Invalid interval - " <<optarg <<std::endl;
123 case 'n':
if ((Count = atoi(optarg)) <= 0)
124 {std::cerr <<pgm <<
"Invalid count - " <<optarg <<std::endl;
128 case 's': sP = optarg;
130 {
if (!index(
"abcdipsuz", *sP))
131 {std::cerr <<pgm<<
"Invalid statistic letter - "<<*sP<<std::endl;
133 }
else if (*sP ==
'c') *sP =
'l';
138 case 'z': nozed =
true;
140 default: std::cerr <<pgm <<
'-' <<char(
optopt);
141 if (c ==
':') std::cerr <<
" value not specified." <<std::endl;
142 else std::cerr <<
" option is invalid" <<std::endl;
151 {std::cerr <<pgm <<
"Host has not been specified." <<std::endl;
Usage(1);}
155 std::string sURL(
"root://");
158 if (!fsURL.IsValid())
159 {std::cerr <<pgm <<
"Invalid host specification - " <<argv[
optind] <<std::endl;
170 if (!WTime && Count) WTime = 10;
171 else if (WTime && !Count) Count = -1;
172 else if (!WTime && !Count) Count = 1;
189 if (!xP) std::cout <<theStats->
GetBuffer() <<std::endl;
193 {
do {rc =
write(STDOUT_FILENO, bP, wLen);}
194 while(rc < 0 && errno == EINTR);
195 wLen -= rc; bP += rc;
199 if (WTime) sleep(WTime);
200 if (Count) std::cout <<
"\n";
ssize_t write(int fildes, const void *buf, size_t nbyte)
void Fatal(const XrdCl::XRootDStatus &Status)
Binary blob representation.
void FromString(const std::string str)
Fill the buffer from a string.
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Send file/filesystem queries to an XRootD cluster.
int Format(const char *Host, char *ibuff, char *obuff)
@ Stats
Query server stats.
bool IsOK() const
We're fine.
References Macaroons::Debug, Fatal(), XrdMpxXml::fmtCGI, XrdMpxXml::fmtFlat, XrdMpxXml::fmtText, XrdMpxXml::fmtXML, XrdMpxXml::Format(), XrdCl::Buffer::FromString(), XrdCl::Buffer::GetBuffer(), XrdCl::Status::IsOK(), XrdCl::URL::IsValid(), optind, optopt, XrdCl::QueryCode::Stats, XrdPosixGlobals::Stats, XrdSsi::theFS, Usage(), and write().
◆ Usage()
Definition at line 67 of file XrdQStats.cc.
69 std::cerr <<
"\nUsage: xrdqstats [opts] <host>[:<port>]\n"
70 "\nopts: -f {cgi|flat|xml} -h -i <sec> -n <cnt> -s what -z\n"
71 "\n-f specify display format (default is wordy text format)."
72 "\n-i number of seconds to wait before between redisplays, default 10."
73 "\n-n number of redisplays; if -s > 0 and -n unspecified goes forever."
74 "\n-z does not display items with a zero value (wordy text only).\n"
75 "\nwhat: one or more of the following letters to select statistics:"
76 "\na - All (default) b - Buffer usage d - Device polling"
77 "\ni - Identification c - Connections p - Protocols"
78 "\ns - Scheduling u - Usage data z - Synchronized info"
Referenced by main().