88{
89 extern char *optarg;
93 const char *
Stats =
"bldpsu", *pgm =
"xrdqstats: ";
94 const char *valOpts = "df:i:n:s:z";
95 int WTime = 0, Count = 0;
96 char obuff[65536];
97 char *sP, c;
98 bool Debug =
false, nozed =
false;
99
100
101
102 opterr = 0;
103 if (argc > 1 && '-' == *argv[1])
104 while ((c = getopt(argc,argv,valOpts)) && ((unsigned char)c != 0xff))
105 { switch(c)
106 {
107 case 'd':
Debug =
true;
108 break;
112 else {std::cerr <<pgm <<"Invalid format - " <<optarg <<std::endl;
114 }
115 break;
117 break;
118 case 'i': if ((WTime = atoi(optarg)) <= 0)
119 {std::cerr <<pgm <<"Invalid interval - " <<optarg <<std::endl;
121 }
122 break;
123 case 'n': if ((Count = atoi(optarg)) <= 0)
124 {std::cerr <<pgm <<"Invalid count - " <<optarg <<std::endl;
126 }
127 break;
128 case 's': sP = optarg;
129 while(*sP)
130 {if (!index("abcdipsuz", *sP))
131 {std::cerr <<pgm<<"Invalid statistic letter - "<<*sP<<std::endl;
133 } else if (*sP == 'c') *sP = 'l';
134 sP++;
135 }
137 break;
138 case 'z': nozed = true;
139 break;
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;
144 break;
145 }
146 }
147
148
149
151 {std::cerr <<pgm <<
"Host has not been specified." <<std::endl;
Usage(1);}
152
153
154
155 std::string sURL("root://");
158 if (!fsURL.IsValid())
159 {std::cerr <<pgm <<
"Invalid host specification - " <<argv[
optind] <<std::endl;
161 }
162
163
164
167
168
169
170 if (!WTime && Count) WTime = 10;
171 else if (WTime && !Count) Count = -1;
172 else if (!WTime && !Count) Count = 1;
173
174
175
177
178
179
181
182
183
186 while(Count--)
189 if (!xP) std::cout <<theStats->
GetBuffer() <<std::endl;
191 char *bP = obuff;
192 while(wLen > 0)
193 {
do {rc =
write(STDOUT_FILENO, bP, wLen);}
194 while(rc < 0 && errno == EINTR);
195 wLen -= rc; bP += rc;
196 }
197 }
198 delete theStats;
199 if (WTime) sleep(WTime);
200 if (Count) std::cout <<"\n";
201 }
202
203
204
205 return 0;
206}
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.