34 #include <sys/types.h>
59 std::cerr <<
"xrdqstats: Unable to obtain statistic - " <<eText <<std::endl;
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"
87 int main(
int argc,
char *argv[])
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://");
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)
int main(int argc, char *argv[])
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.
bool IsValid() const
Is the url valid.
const std::string & GetErrorMessage() const
Get error message.
std::string ToStr() const
Convert to string.
int Format(const char *Host, char *ibuff, char *obuff)
const uint16_t errErrorResponse
@ Stats
Query server stats.
uint16_t code
Error type, or additional hints on what to do.
bool IsOK() const
We're fine.