check_nt.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /******************************************************************************
  2. *
  3. * CHECK_NT.C
  4. *
  5. * Program: Windows NT plugin for NetSaint
  6. * License: GPL
  7. * Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com)
  8. *
  9. * Description:
  10. *
  11. * License Information:
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. *
  27. *****************************************************************************/
  28. //#include "stdlib.h"
  29. #include "config.h"
  30. #include "common.h"
  31. #include "netutils.h"
  32. #include "utils.h"
  33. #define CHECK_NONE 0
  34. #define CHECK_CLIENTVERSION 1
  35. #define CHECK_CPULOAD 2
  36. #define CHECK_UPTIME 3
  37. #define CHECK_USEDDISKSPACE 4
  38. #define CHECK_SERVICESTATE 5
  39. #define CHECK_PROCSTATE 6
  40. #define CHECK_MEMUSE 7
  41. #define CHECK_COUNTER 8
  42. #define CHECK_FILEAGE 9
  43. #define MAX_VALUE_LIST 30
  44. #define PORT 1248
  45. char *server_address=NULL;
  46. char *volume_name=NULL;
  47. int server_port=PORT;
  48. char *value_list=NULL;
  49. char *req_password=NULL;
  50. unsigned long lvalue_list[MAX_VALUE_LIST];
  51. unsigned long warning_value=0L;
  52. unsigned long critical_value=0L;
  53. int check_value_list=FALSE;
  54. int check_warning_value=FALSE;
  55. int check_critical_value=FALSE;
  56. int vars_to_check=CHECK_NONE;
  57. int show_all=FALSE;
  58. const char *progname = "check_nt";
  59. int process_arguments(int, char **);
  60. void print_usage(void);
  61. void print_help(void);
  62. void preparelist(char *string);
  63. int main(int argc, char **argv){
  64. int result;
  65. int return_code;
  66. char *send_buffer=NULL;
  67. char recv_buffer[MAX_INPUT_BUFFER];
  68. char *output_message=NULL;
  69. char *temp_buffer=NULL;
  70. char *temp_string=NULL;
  71. char *sep_string=NULL;
  72. char *description=NULL;
  73. double total_disk_space=0;
  74. double free_disk_space=0;
  75. double percent_used_space=0;
  76. double mem_commitLimit=0;
  77. double mem_commitByte=0;
  78. unsigned long current_connections=0;
  79. unsigned long utilization;
  80. unsigned long uptime;
  81. unsigned long cache_hits;
  82. unsigned long cache_buffers;
  83. unsigned long lru_time;
  84. unsigned long age_in_minutes;
  85. double counter_value;
  86. int offset=0;
  87. int updays=0;
  88. int uphours=0;
  89. int upminutes=0;
  90. asprintf(&req_password,"None");
  91. if(process_arguments(argc,argv)==ERROR)
  92. usage("Could not parse arguments\n");
  93. /* initialize alarm signal handling */
  94. signal(SIGALRM,socket_timeout_alarm_handler);
  95. /* set socket timeout */
  96. alarm(socket_timeout);
  97. if (vars_to_check==CHECK_CLIENTVERSION) {
  98. asprintf(&send_buffer,strcat(req_password,"&1"));
  99. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  100. if(result!=STATE_OK)
  101. return result;
  102. asprintf(&output_message,recv_buffer);
  103. return_code=STATE_OK;
  104. }
  105. else if(vars_to_check==CHECK_CPULOAD){
  106. if (check_value_list==TRUE) {
  107. if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
  108. // -l parameters is present with only integers
  109. return_code=STATE_OK;
  110. asprintf(&temp_string,"CPU Load");
  111. while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 &&
  112. lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 &&
  113. lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) {
  114. // loop until one of the parameters is wrong or not present
  115. // Send request and retrieve data
  116. asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
  117. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  118. if(result!=STATE_OK)
  119. return result;
  120. if (!strncmp(recv_buffer,"ERROR",5)) {
  121. printf("NSClient - %s\n",recv_buffer);
  122. exit(STATE_UNKNOWN);
  123. }
  124. utilization=strtoul(recv_buffer,NULL,10);
  125. // Check if any of the request is in a warning or critical state
  126. if(utilization >= lvalue_list[2+offset])
  127. return_code=STATE_CRITICAL;
  128. else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
  129. return_code=STATE_WARNING;
  130. asprintf(&output_message," (%lu min. %lu%)",lvalue_list[0+offset], utilization);
  131. asprintf(&temp_string,"%s%s",temp_string,output_message);
  132. offset+=3; //move accross the array
  133. }
  134. if (strlen(temp_string)>10) {
  135. // we had at least on loop
  136. asprintf(&output_message,"%s",temp_string);
  137. }
  138. else
  139. asprintf(&output_message,"%s","not enough values for -l parameters");
  140. } else
  141. asprintf(&output_message,"wrong -l parameter.");
  142. } else
  143. asprintf(&output_message,"missing -l parameters");
  144. }
  145. else if(vars_to_check==CHECK_UPTIME){
  146. asprintf(&send_buffer,strcat(req_password,"&3"));
  147. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  148. if(result!=STATE_OK)
  149. return result;
  150. if (!strncmp(recv_buffer,"ERROR",5)) {
  151. printf("NSClient - %s\n",recv_buffer);
  152. exit(STATE_UNKNOWN);
  153. }
  154. uptime=strtoul(recv_buffer,NULL,10);
  155. updays = uptime / 86400;
  156. uphours = (uptime % 86400) / 3600;
  157. upminutes = ((uptime % 86400) % 3600) / 60;
  158. asprintf(&output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes);
  159. return_code=STATE_OK;
  160. }
  161. else if(vars_to_check==CHECK_USEDDISKSPACE){
  162. return_code=STATE_UNKNOWN;
  163. if (check_value_list==TRUE) {
  164. if (strlen(value_list)==1) {
  165. asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
  166. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  167. if(result!=STATE_OK)
  168. return result;
  169. if (!strncmp(recv_buffer,"ERROR",5)) {
  170. printf("NSClient - %s\n",recv_buffer);
  171. exit(STATE_UNKNOWN);
  172. }
  173. free_disk_space=atof(strtok(recv_buffer,"&"));
  174. total_disk_space=atof(strtok(NULL,"&"));
  175. percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
  176. if (free_disk_space>=0) {
  177. asprintf(&temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)",
  178. value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
  179. free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
  180. if(check_critical_value==TRUE && percent_used_space >= critical_value)
  181. return_code=STATE_CRITICAL;
  182. else if (check_warning_value==TRUE && percent_used_space >= warning_value)
  183. return_code=STATE_WARNING;
  184. else
  185. return_code=STATE_OK;
  186. asprintf(&output_message,"%s",temp_string);
  187. }
  188. else {
  189. asprintf(&output_message,"Free disk space : Invalid drive ");
  190. return_code=STATE_UNKNOWN;
  191. }
  192. }
  193. else
  194. asprintf(&output_message,"wrong -l argument");
  195. } else
  196. asprintf(&output_message,"missing -l parameters");
  197. }
  198. else if(vars_to_check==CHECK_SERVICESTATE || vars_to_check==CHECK_PROCSTATE){
  199. if (check_value_list==TRUE) {
  200. preparelist(value_list); // replace , between services with & to send the request
  201. asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
  202. (show_all==TRUE)?"ShowAll":"ShowFail",value_list);
  203. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  204. if(result!=STATE_OK)
  205. return result;
  206. if (!strncmp(recv_buffer,"ERROR",5)) {
  207. printf("NSClient - %s\n",recv_buffer);
  208. exit(STATE_UNKNOWN);
  209. }
  210. return_code=atoi(strtok(recv_buffer,"&"));
  211. temp_string=strtok(NULL,"&");
  212. asprintf(&output_message, "%s",temp_string);
  213. }
  214. else
  215. asprintf(&output_message,"No service/process specified");
  216. }
  217. else if(vars_to_check==CHECK_MEMUSE) {
  218. asprintf(&send_buffer,"%s&7", req_password);
  219. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  220. if (result!=STATE_OK)
  221. return result;
  222. if (!strncmp(recv_buffer,"ERROR",5)) {
  223. printf("NSClient - %s\n",recv_buffer);
  224. exit(STATE_UNKNOWN);
  225. }
  226. mem_commitLimit=atof(strtok(recv_buffer,"&"));
  227. mem_commitByte=atof(strtok(NULL,"&"));
  228. percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
  229. asprintf(&output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)",
  230. mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space,
  231. (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
  232. if(check_critical_value==TRUE && percent_used_space >= critical_value)
  233. return_code=STATE_CRITICAL;
  234. else if (check_warning_value==TRUE && percent_used_space >= warning_value)
  235. return_code=STATE_WARNING;
  236. else
  237. return_code=STATE_OK;
  238. }
  239. else if(vars_to_check==CHECK_COUNTER) {
  240. if (check_value_list==TRUE) {
  241. preparelist(value_list); // replace , between services with & to send the request
  242. asprintf(&send_buffer,"%s&8&%s", req_password,value_list);
  243. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  244. if (result!=STATE_OK)
  245. return result;
  246. if (!strncmp(recv_buffer,"ERROR",5)) {
  247. printf("NSClient - %s\n",recv_buffer);
  248. exit(STATE_UNKNOWN);
  249. }
  250. strtok(value_list,"&"); // burn the first parameters
  251. description = strtok(NULL,"&");
  252. counter_value = atof(recv_buffer);
  253. if (description == NULL)
  254. asprintf(&output_message, "%.f", counter_value);
  255. else
  256. asprintf(&output_message, description, counter_value);
  257. if (critical_value > warning_value) {
  258. // Normal thresholds
  259. if(check_critical_value==TRUE && counter_value >= critical_value)
  260. return_code=STATE_CRITICAL;
  261. else if (check_warning_value==TRUE && counter_value >= warning_value)
  262. return_code=STATE_WARNING;
  263. else
  264. return_code=STATE_OK;
  265. }
  266. else {
  267. // inverse thresholds
  268. if(check_critical_value==TRUE && counter_value <= critical_value)
  269. return_code=STATE_CRITICAL;
  270. else if (check_warning_value==TRUE && counter_value <= warning_value)
  271. return_code=STATE_WARNING;
  272. else
  273. return_code=STATE_OK;
  274. }
  275. }
  276. else {
  277. asprintf(&output_message,"No counter specified");
  278. result=STATE_UNKNOWN;
  279. }
  280. }
  281. else if(vars_to_check==CHECK_FILEAGE) {
  282. if (check_value_list==TRUE) {
  283. preparelist(value_list); // replace , between services with & to send the request
  284. asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
  285. result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
  286. if (result!=STATE_OK)
  287. return result;
  288. if (!strncmp(recv_buffer,"ERROR",5)) {
  289. printf("NSClient - %s\n",recv_buffer);
  290. exit(STATE_UNKNOWN);
  291. }
  292. age_in_minutes = atoi(strtok(recv_buffer,"&"));
  293. description = strtok(NULL,"&");
  294. asprintf(&output_message, description);
  295. if (critical_value > warning_value) {
  296. // Normal thresholds
  297. if(check_critical_value==TRUE && age_in_minutes >= critical_value)
  298. return_code=STATE_CRITICAL;
  299. else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
  300. return_code=STATE_WARNING;
  301. else
  302. return_code=STATE_OK;
  303. }
  304. else {
  305. // inverse thresholds
  306. if(check_critical_value==TRUE && age_in_minutes <= critical_value)
  307. return_code=STATE_CRITICAL;
  308. else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
  309. return_code=STATE_WARNING;
  310. else
  311. return_code=STATE_OK;
  312. }
  313. }
  314. else {
  315. asprintf(&output_message,"No file specified");
  316. result=STATE_UNKNOWN;
  317. }
  318. }
  319. /* reset timeout */
  320. alarm(0);
  321. printf("%s\n",output_message);
  322. return return_code;
  323. }
  324. /* process command-line arguments */
  325. int process_arguments(int argc, char **argv){
  326. int c;
  327. #ifdef HAVE_GETOPT_H
  328. int option_index = 0;
  329. static struct option long_options[] =
  330. {
  331. {"port", required_argument,0,'p'},
  332. {"timeout", required_argument,0,'t'},
  333. {"critical", required_argument,0,'c'},
  334. {"warning", required_argument,0,'w'},
  335. {"variable", required_argument,0,'v'},
  336. {"hostname", required_argument,0,'H'},
  337. {"version", no_argument, 0,'V'},
  338. {"help", no_argument, 0,'h'},
  339. {0,0,0,0}
  340. };
  341. #endif
  342. /* no options were supplied */
  343. if(argc<2) return ERROR;
  344. /* backwards compatibility */
  345. if (! is_option(argv[1])) {
  346. server_address=argv[1];
  347. argv[1]=argv[0];
  348. argv=&argv[1];
  349. argc--;
  350. }
  351. for (c=1;c<argc;c++) {
  352. if(strcmp("-to",argv[c])==0)
  353. strcpy(argv[c],"-t");
  354. else if (strcmp("-wv",argv[c])==0)
  355. strcpy(argv[c],"-w");
  356. else if (strcmp("-cv",argv[c])==0)
  357. strcpy(argv[c],"-c");
  358. }
  359. while (1){
  360. #ifdef HAVE_GETOPT_H
  361. c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",long_options,&option_index);
  362. #else
  363. c = getopt(argc,argv,"+hVH:t:c:w:p:v:l:s:d:");
  364. #endif
  365. if (c==-1||c==EOF||c==1)
  366. break;
  367. switch (c)
  368. {
  369. case '?': /* print short usage statement if args not parsable */
  370. printf("%s: Unknown argument: %s\n\n",progname,optarg);
  371. print_usage();
  372. exit(STATE_UNKNOWN);
  373. case 'h': /* help */
  374. print_help();
  375. exit(STATE_OK);
  376. case 'V': /* version */
  377. print_revision(progname,"$Revision$");
  378. exit(STATE_OK);
  379. case 'H': /* hostname */
  380. server_address=optarg;
  381. break;
  382. case 's': /* password */
  383. asprintf(&req_password,optarg);
  384. break;
  385. case 'p': /* port */
  386. if (is_intnonneg(optarg))
  387. server_port=atoi(optarg);
  388. else
  389. terminate(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname);
  390. break;
  391. case 'v':
  392. if(strlen(optarg)<4)
  393. return ERROR;
  394. if(!strcmp(optarg,"CLIENTVERSION"))
  395. vars_to_check=CHECK_CLIENTVERSION;
  396. else if(!strcmp(optarg,"CPULOAD"))
  397. vars_to_check=CHECK_CPULOAD;
  398. else if(!strcmp(optarg,"UPTIME"))
  399. vars_to_check=CHECK_UPTIME;
  400. else if(!strcmp(optarg,"USEDDISKSPACE"))
  401. vars_to_check=CHECK_USEDDISKSPACE;
  402. else if(!strcmp(optarg,"SERVICESTATE"))
  403. vars_to_check=CHECK_SERVICESTATE;
  404. else if(!strcmp(optarg,"PROCSTATE"))
  405. vars_to_check=CHECK_PROCSTATE;
  406. else if(!strcmp(optarg,"MEMUSE"))
  407. vars_to_check=CHECK_MEMUSE;
  408. else if(!strcmp(optarg,"COUNTER"))
  409. vars_to_check=CHECK_COUNTER;
  410. else if(!strcmp(optarg,"FILEAGE"))
  411. vars_to_check=CHECK_FILEAGE;
  412. else
  413. return ERROR;
  414. break;
  415. case 'l': /* value list */
  416. asprintf(&value_list,optarg);
  417. check_value_list=TRUE;
  418. break;
  419. case 'w': /* warning threshold */
  420. warning_value=strtoul(optarg,NULL,10);
  421. check_warning_value=TRUE;
  422. break;
  423. case 'c': /* critical threshold */
  424. critical_value=strtoul(optarg,NULL,10);
  425. check_critical_value=TRUE;
  426. break;
  427. case 'd': /* Display select for services */
  428. if (!strcmp(optarg,"SHOWALL"))
  429. show_all = TRUE;
  430. break;
  431. case 't': /* timeout */
  432. socket_timeout=atoi(optarg);
  433. if(socket_timeout<=0)
  434. return ERROR;
  435. }
  436. }
  437. return OK;
  438. }
  439. void print_usage(void)
  440. {
  441. printf("Usage: %s -H host [-p port] [-v variable] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout]\n",progname);
  442. }
  443. void print_help(void)
  444. {
  445. print_revision(progname,"$Revision$");
  446. printf
  447. ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n"
  448. "This plugin attempts to contact the NSClient service running on a Windows NT/2000/XP server to\n"
  449. "gather the requested system information.\n\n");
  450. print_usage();
  451. printf
  452. ("\nOptions:\n"
  453. "-H, --hostname=HOST\n"
  454. " Name of the host to check\n"
  455. "-p, --port=INTEGER\n"
  456. " Optional port number (default: %d)\n"
  457. "-s <password>\n"
  458. " Password needed for the request\n"
  459. "-v, --variable=STRING\n"
  460. " Variable to check. Valid variables are:\n"
  461. " CLIENTVERSION = Get the NSClient version\n"
  462. " CPULOAD = Average CPU load on last x minutes. Request a -l parameter with the following syntax:\n"
  463. " -l <minutes range>,<warning threshold>,<critical threshold>. <minute range> should be less than 24*60.\n"
  464. " Thresholds are percentage and up to 10 requests can be done in one shot. ie: -l 60,90,95,120,90,95\n"
  465. " UPTIME = Get the uptime of the machine. No specific parameters. No warning or critical threshold\n"
  466. " USEDDISKSPACE = Size and percentage of disk use. Request a -l parameter containing the drive letter only.\n"
  467. " Warning and critical thresholds can be specified with -w and -c.\n"
  468. " MEMUSE = Memory use. Warning and critical thresholds can be specified with -w and -c.\n"
  469. " SERVICESTATE = Check the state of one or several services. Request a -l parameters with the following syntax:\n"
  470. " -l <service1>,<service2>,<service3>,... You can specify -d SHOWALL in case you want to see working services\n"
  471. " in the returned string.\n"
  472. " PROCSTATE = Check if one or several process are running. Same syntax as SERVICESTATE.\n"
  473. " COUNTER = Check any performance counter of Windows NT/2000. Request a -l parameters with the following syntax:\n"
  474. " -l \"\\\\<performance object>\\\\counter\",\"<description>\" The <description> parameter is optional and \n"
  475. " is given to a printf output command which require a float parameters. Some examples:\n"
  476. " \"Paging file usage is %%.2f %%%%\" or \"%%.f %%%% paging file used.\"\n"
  477. " -w, --warning=INTEGER\n"
  478. " Threshold which will result in a warning status\n"
  479. " -c, --critical=INTEGER\n"
  480. " Threshold which will result in a critical status\n"
  481. " -t, --timeout=INTEGER\n"
  482. " Seconds before connection attempt times out (default: %d)\n"
  483. "-h, --help\n"
  484. " Print this help screen\n"
  485. "-V, --version\n"
  486. " Print version information\n\n"
  487. "Notes:\n"
  488. " - The NSClient service should be running on the server to get any information.\n"
  489. " - Critical thresholds should be lower than warning thresholds\n", PORT, DEFAULT_SOCKET_TIMEOUT);
  490. }
  491. int strtolarray(unsigned long *array, char *string, char *delim) {
  492. // split a <delim> delimited string into a long array
  493. int idx=0;
  494. char *t1;
  495. for (idx=0;idx<MAX_VALUE_LIST;idx++)
  496. array[idx]=-1;
  497. idx=0;
  498. for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
  499. if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
  500. array[idx]=strtoul(t1,NULL,10);
  501. idx++;
  502. } else
  503. return FALSE;
  504. }
  505. return TRUE;
  506. }
  507. void preparelist(char *string) {
  508. // Replace all , with & which is the delimiter for the request
  509. int i;
  510. for (i = 0; i < strlen(string); i++)
  511. if (string[i] == ',') {
  512. string[i]='&';
  513. }
  514. }