int sprdsht(int fnum, int depth) { /* this funtion displays a form in a spreadsheet like manner */ int x, y, orgtop, orgbot; showform(fnum,LABOVE); orgtop=grfxform[fnum].fld[0].top; orgbot=grfxform[fnum].fld[0].bot; for(x=1;x<depth;x++) { for(y=0;y<=grfxform[fnum].number;y++) { grfxform[fnum].fld[y].top+=20; grfxform[fnum].fld[y].bot+=20; } showform(fnum,WITHOUT); } for(y=0;y<=grfxform[fnum].number;y++) { grfxform[fnum].fld[y].top=orgtop; grfxform[fnum].fld[y].bot=orgbot; } return(0); }
int main(int argc, char *argv[]) { int argi; char *envarea = NULL; for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } } redirect_cgilog("hobbit-notifylog"); load_hostnames(xgetenv("BBHOSTS"), NULL, get_fqdn()); fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); cgidata = cgi_request(); if (cgidata == NULL) { /* Present the query form */ sethostenv("", "", "", colorname(COL_BLUE), NULL); showform(stdout, "notify", "notify_form", COL_BLUE, getcurrenttime(NULL), NULL, NULL); return 0; } parse_query(); /* Now generate the webpage */ headfoot(stdout, "notify", "", "header", COL_GREEN); fprintf(stdout, "<center>\n"); do_notifylog(stdout, maxcount, maxminutes, fromtime, totime, pageregex, expageregex, hostregex, exhostregex, testregex, extestregex, rcptregex, exrcptregex); fprintf(stdout, "</center>\n"); headfoot(stdout, "notify", "", "footer", COL_GREEN); return 0; }
int main(int argc, char *argv[]) { char dirid[PATH_MAX]; char outdir[PATH_MAX]; char xymonwebenv[PATH_MAX]; char xymongencmd[PATH_MAX]; char xymongentimeopt[100]; char csvdelimopt[100]; char *xymongen_argv[20]; pid_t childpid; int childstat; char htmldelim[100]; char startstr[30], endstr[30]; int cleanupoldreps = 1; int argi, newargi; char *envarea = NULL; char *useragent = NULL; int usemultipart = 1; newargi = 0; xymongen_argv[newargi++] = xymongencmd; xymongen_argv[newargi++] = xymongentimeopt; for (argi=1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[1], "--noclean") == 0) { cleanupoldreps = 0; } else { xymongen_argv[newargi++] = argv[argi]; } } redirect_cgilog("report"); cgidata = cgi_request(); if (cgidata == NULL) { /* Present the query form */ sethostenv("", "", "", colorname(COL_BLUE), NULL); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); showform(stdout, "report", "report_form", COL_BLUE, getcurrenttime(NULL)-86400, NULL, NULL); return 0; } useragent = getenv("HTTP_USER_AGENT"); if (useragent && strstr(useragent, "KHTML")) { /* KHTML (Konqueror, Safari) cannot handle multipart documents. */ usemultipart = 0; } envcheck(reqenv); parse_query(); /* * We need to set these variables up AFTER we have put them into the xymongen_argv[] array. * We cannot do it before, because we need the environment that the command-line options * might provide. */ if (xgetenv("XYMONGEN")) sprintf(xymongencmd, "%s", xgetenv("XYMONGEN")); else sprintf(xymongencmd, "%s/bin/xymongen", xgetenv("XYMONHOME")); snprintf(xymongentimeopt, sizeof(xymongentimeopt)-1,"--reportopts=%u:%u:1:%s", (unsigned int)starttime, (unsigned int)endtime, style); sprintf(dirid, "%u-%u", (unsigned int)getpid(), (unsigned int)getcurrenttime(NULL)); if (!csvoutput) { sprintf(outdir, "%s/%s", xgetenv("XYMONREPDIR"), dirid); mkdir(outdir, 0755); xymongen_argv[newargi++] = outdir; sprintf(xymonwebenv, "XYMONWEB=%s/%s", xgetenv("XYMONREPURL"), dirid); putenv(xymonwebenv); } else { sprintf(outdir, "--csv=%s/%s.csv", xgetenv("XYMONREPDIR"), dirid); xymongen_argv[newargi++] = outdir; sprintf(csvdelimopt, "--csvdelim=%c", csvdelim); xymongen_argv[newargi++] = csvdelimopt; } xymongen_argv[newargi++] = NULL; if (usemultipart) { /* Output the "please wait for report ... " thing */ snprintf(htmldelim, sizeof(htmldelim)-1, "xymonrep-%u-%u", (int)getpid(), (unsigned int)getcurrenttime(NULL)); printf("Content-type: multipart/mixed;boundary=%s\n", htmldelim); printf("\n"); printf("--%s\n", htmldelim); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); /* It's ok with these hardcoded values, as they are not used for this page */ sethostenv("", "", "", colorname(COL_BLUE), NULL); sethostenv_report(starttime, endtime, 97.0, 99.995); headfoot(stdout, "repnormal", "", "header", COL_BLUE); strftime(startstr, sizeof(startstr), "%b %d %Y", localtime(&starttime)); strftime(endstr, sizeof(endstr), "%b %d %Y", localtime(&endtime)); printf("<CENTER><A NAME=begindata> </A>\n"); printf("<BR><BR><BR><BR>\n"); printf("<H3>Generating report for the period: %s", htmlquoted(startstr)); printf(" - %s ", htmlquoted(endstr)); printf("(%s)<BR>\n", htmlquoted(style)); printf("<P><P>\n"); fflush(stdout); } /* Go do the report */ childpid = fork(); if (childpid == 0) { execv(xymongencmd, xymongen_argv); } else if (childpid > 0) { wait(&childstat); /* Ignore SIGHUP so we dont get killed during cleanup of XYMONREPDIR */ signal(SIGHUP, SIG_IGN); if (WIFEXITED(childstat) && (WEXITSTATUS(childstat) != 0) ) { char msg[4096]; if (usemultipart) printf("--%s\n\n", htmldelim); sprintf(msg, "Could not generate report.<br>\nCheck that the %s/www/rep/ directory has permissions '-rwxrwxr-x' (775)<br>\n and that is is set to group %d", xgetenv("XYMONHOME"), (int)getgid()); errormsg(msg); } else { /* Send the browser off to the report */ if (usemultipart) { printf("Done...Report is <A HREF=\"%s/%s/%s\">here</a>.</P></BODY></HTML>\n", xgetenv("XYMONREPURL"), dirid, suburl); fflush(stdout); printf("--%s\n\n", htmldelim); } printf("Content-Type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); printf("<HTML><HEAD>\n"); if (!csvoutput) { printf("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=%s/%s/%s\"\n", xgetenv("XYMONREPURL"), dirid, suburl); printf("</HEAD><BODY>Report is available <a href=\"%s/%s/%s\">here</a></BODY></HTML>\n", xgetenv("XYMONREPURL"), dirid, suburl); } else { printf("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=%s/%s.csv\"\n", xgetenv("XYMONREPURL"), dirid); printf("</HEAD><BODY>Report is available <a href=\"%s/%s.csv\">here</a></BODY></HTML>\n", xgetenv("XYMONREPURL"), dirid); } if (usemultipart) printf("\n--%s\n", htmldelim); fflush(stdout); } if (cleanupoldreps) cleandir(xgetenv("XYMONREPDIR")); } else { if (usemultipart) printf("--%s\n\n", htmldelim); printf("Content-Type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); errormsg("Fork failed"); } return 0; }
int main(int argc, char *argv[]) { char dirid[PATH_MAX]; char outdir[PATH_MAX]; char xymongencmd[PATH_MAX]; char xymonwebenv[PATH_MAX]; char xymongentimeopt[100]; char *xymongen_argv[20]; pid_t childpid; int childstat; char htmldelim[100]; char startstr[20]; int argi, newargi; char *envarea = NULL; char *useragent; int usemultipart = 1; newargi = 0; xymongen_argv[newargi++] = xymongencmd; xymongen_argv[newargi++] = xymongentimeopt; for (argi=1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else { xymongen_argv[newargi++] = argv[argi]; } } xymongen_argv[newargi++] = outdir; xymongen_argv[newargi++] = NULL; redirect_cgilog("snapshot"); cgidata = cgi_request(); if (cgidata == NULL) { /* Present the query form */ sethostenv("", "", "", colorname(COL_BLUE), NULL); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); showform(stdout, "snapshot", "snapshot_form", COL_BLUE, getcurrenttime(NULL), NULL, NULL); return 0; } parse_query(); useragent = getenv("HTTP_USER_AGENT"); if (useragent && strstr(useragent, "KHTML")) { /* KHTML (Konqueror, Safari) cannot handle multipart documents. */ usemultipart = 0; } /* * Need to set these up AFTER putting them into xymongen_argv, since we * need to have option parsing done first. */ if (xgetenv("XYMONGEN")) sprintf(xymongencmd, "%s", xgetenv("XYMONGEN")); else sprintf(xymongencmd, "%s/bin/xymongen", xgetenv("XYMONHOME")); snprintf(xymongentimeopt, sizeof(xymongentimeopt), "--snapshot=%u", (unsigned int)starttime); sprintf(dirid, "%lu-%u", (unsigned long)getpid(), (unsigned int)getcurrenttime(NULL)); sprintf(outdir, "%s/%s", xgetenv("XYMONSNAPDIR"), dirid); if (mkdir(outdir, 0755) == -1) errormsg("Cannot create output directory"); sprintf(xymonwebenv, "XYMONWEB=%s/%s", xgetenv("XYMONSNAPURL"), dirid); putenv(xymonwebenv); if (usemultipart) { /* Output the "please wait for report ... " thing */ snprintf(htmldelim, sizeof(htmldelim)-1, "xymonrep-%lu-%u", (unsigned long)getpid(), (unsigned int)getcurrenttime(NULL)); printf("Content-type: multipart/mixed;boundary=%s\n", htmldelim); printf("\n"); printf("%s\n", htmldelim); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); /* It's ok with these hardcoded values, as they are not used for this page */ sethostenv("", "", "", colorname(COL_BLUE), NULL); sethostenv_report(starttime, starttime, 97.0, 99.995); headfoot(stdout, "snapshot", "", "header", COL_BLUE); strftime(startstr, sizeof(startstr), "%b %d %Y", localtime(&starttime)); printf("<CENTER><A NAME=begindata> </A>\n"); printf("<BR><BR><BR><BR>\n"); printf("<H3>Generating snapshot: %s<BR>\n", htmlquoted(startstr)); printf("<P><P>\n"); fflush(stdout); } /* Go do the report */ childpid = fork(); if (childpid == 0) { execv(xymongencmd, xymongen_argv); } else if (childpid > 0) { wait(&childstat); /* Ignore SIGHUP so we don't get killed during cleanup of XYMONSNAPDIR */ signal(SIGHUP, SIG_IGN); if (WIFEXITED(childstat) && (WEXITSTATUS(childstat) != 0) ) { if (usemultipart) printf("%s\n\n", htmldelim); printf("Content-Type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); errormsg("Could not generate report"); } else { /* Send the browser off to the report */ if (usemultipart) { printf("Done...<P></BODY></HTML>\n"); fflush(stdout); printf("%s\n\n", htmldelim); } printf("Content-Type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); printf("<HTML><HEAD>\n"); printf("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=%s/%s/\"\n", xgetenv("XYMONSNAPURL"), dirid); printf("</HEAD><BODY BGCOLOR=\"000000\"></BODY></HTML>\n"); if (usemultipart) printf("\n%s\n", htmldelim); fflush(stdout); } cleandir(xgetenv("XYMONSNAPDIR")); } else { if (usemultipart) printf("%s\n\n", htmldelim); printf("Content-Type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); errormsg("Fork failed"); } return 0; }
int main(int argc, char *argv[]) { void *hostwalk, *clonewalk; int argi; char *envarea = NULL; strbuffer_t *outbuf; char msgline[4096]; char oneurl[10240]; int gotany = 0; enum { OP_INITIAL, OP_YES, OP_NO } gotonepage = OP_INITIAL; /* Tracks if all matches are on one page */ char *onepage = NULL; /* If gotonepage==OP_YES, then this is the page */ /*[wm] regex support */ #define BUFSIZE 256 regex_t re; char re_errstr[BUFSIZE]; int re_status; for (argi=1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } } redirect_cgilog("findhost"); cgidata = cgi_request(); if (cgidata == NULL) { /* Present the query form */ sethostenv("", "", "", colorname(COL_BLUE), NULL); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); showform(stdout, "findhost", "findhost_form", COL_BLUE, getcurrenttime(NULL), NULL, NULL); return 0; } parse_query(); if ( (re_status = regcomp(&re, pSearchPat, re_flag)) != 0 ) { regerror(re_status, &re, re_errstr, BUFSIZE); print_header(); printf("<tr><td align=left><font color=red>%s</font></td>\n", pSearchPat); printf("<td align=left><font color=red>%s</font></td></tr>\n", re_errstr); print_footer(); return 0; } outbuf = newstrbuffer(0); load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); hostwalk = first_host(); while (hostwalk) { /* * [wm] - Allow the search to be done on the hostname * also on the "displayname" and the host comment * Maybe this should be implemented by changing the HTML form, but until than.. * we're supposing that hostname will NEVER be null */ char *hostname, *displayname, *comment, *ip; hostname = xmh_item(hostwalk, XMH_HOSTNAME); displayname = xmh_item(hostwalk, XMH_DISPLAYNAME); comment = xmh_item(hostwalk, XMH_COMMENT); ip = xmh_item(hostwalk, XMH_IP); if ( regexec (&re, hostname, (size_t)0, NULL, 0) == 0 || (regexec(&re, ip, (size_t)0, NULL, 0) == 0) || (displayname && regexec (&re, displayname, (size_t)0, NULL, 0) == 0) || (comment && regexec (&re, comment, (size_t)0, NULL, 0) == 0) ) { /* match */ addtobuffer(outbuf, "<tr>\n"); sprintf(msgline, "<td align=left> %s </td>\n", displayname ? displayname : hostname); addtobuffer(outbuf, msgline); sprintf(oneurl, "%s/%s/#%s", xgetenv("XYMONWEB"), xmh_item(hostwalk, XMH_PAGEPATH), hostname); sprintf(msgline, "<td align=left> <a href=\"%s\">%s</a>\n", oneurl, xmh_item(hostwalk, XMH_PAGEPATHTITLE)); addtobuffer(outbuf, msgline); gotany++; /* See if all of the matches so far are on one page */ switch (gotonepage) { case OP_INITIAL: gotonepage = OP_YES; onepage = xmh_item(hostwalk, XMH_PAGEPATH); break; case OP_YES: if (strcmp(onepage, xmh_item(hostwalk, XMH_PAGEPATH)) != 0) gotonepage = OP_NO; break; case OP_NO: break; } clonewalk = next_host(hostwalk, 1); while (clonewalk && (strcmp(xmh_item(hostwalk, XMH_HOSTNAME), xmh_item(clonewalk, XMH_HOSTNAME)) == 0)) { sprintf(msgline, "<br><a href=\"%s/%s/#%s\">%s</a>\n", xgetenv("XYMONWEB"), xmh_item(clonewalk, XMH_PAGEPATH), xmh_item(clonewalk, XMH_HOSTNAME), xmh_item(clonewalk, XMH_PAGEPATHTITLE)); addtobuffer(outbuf, msgline); clonewalk = next_host(clonewalk, 1); gotany++; } addtobuffer(outbuf, "</td>\n</tr>\n"); hostwalk = clonewalk; } else { hostwalk = next_host(hostwalk, 0); } } regfree (&re); /*[wm] - free regex compiled patern */ if (dojump) { if (gotany == 1) { printf("Location: %s%s\n\n", xgetenv("XYMONWEBHOST"), oneurl); return 0; } else if ((gotany > 1) && (gotonepage == OP_YES)) { printf("Location: %s%s/%s/\n\n", xgetenv("XYMONWEBHOST"), xgetenv("XYMONWEB"), onepage); return 0; } } print_header(); if (!gotany) { printf("<tr><td align=left>%s</td><td align=left>Not found</td></tr>\n", pSearchPat); } else { printf("%s", grabstrbuffer(outbuf)); } print_footer(); /* [wm] - Free the strdup allocated memory */ if (pSearchPat) xfree(pSearchPat); return 0; }
int main(int argc, char *argv[]) { int argi; char *envarea = NULL; for (argi=1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (argnmatch(argv[argi], "--top")) { topcount = 10; webfile_hf = "topchanges"; webfile_form = "topchanges_form"; maxminutes = -1; maxcount = -1; } else if (strcmp(argv[argi], "--debug=")) { debug = 1; } } redirect_cgilog("eventlog"); load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); cgidata = cgi_request(); if (cgidata == NULL) { /* Present the query form */ sethostenv("", "", "", colorname(COL_BLUE), NULL); showform(stdout, webfile_hf, webfile_form, COL_BLUE, getcurrenttime(NULL), NULL, NULL); return 0; } *periodstring = '\0'; parse_query(); if ((*periodstring == '\0') && (fromtime || totime)) { if (fromtime && totime) sprintf(periodstring, "Events between %s - %s", fromtime, totime); else if (fromtime) sprintf(periodstring, "Events since %s", fromtime); else if (totime) sprintf(periodstring, "Events until %s", totime); } /* Now generate the webpage */ headfoot(stdout, webfile_hf, "", "header", COL_GREEN); fprintf(stdout, "<center>\n"); if (topcount == 0) { do_eventlog(stdout, maxcount, maxminutes, fromtime, totime, pageregex, expageregex, hostregex, exhostregex, testregex, extestregex, colorregex, ignoredialups, NULL, NULL, NULL, NULL, counttype, summarybar, periodstring); } else { countlist_t *hcounts, *scounts; event_t *events; time_t firstevent, lastevent; do_eventlog(NULL, -1, -1, fromtime, totime, pageregex, expageregex, hostregex, exhostregex, testregex, extestregex, colorregex, ignoredialups, NULL, &events, &hcounts, &scounts, counttype, XYMON_S_NONE, NULL); lastevent = (totime ? eventreport_time(totime) : getcurrenttime(NULL)); if (fromtime) { firstevent = eventreport_time(fromtime); } else if (events) { event_t *ewalk; ewalk = events; while (ewalk->next) ewalk = ewalk->next; firstevent = ewalk->eventtime; } else firstevent = 0; show_topchanges(stdout, hcounts, scounts, events, topcount, firstevent, lastevent); } fprintf(stdout, "</center>\n"); headfoot(stdout, webfile_hf, "", "footer", COL_GREEN); return 0; }
/* main menu */ void main(void) { int key, buton = 1, h, v, dbon=0, dpon=0; startup(); /* standard startup sequence */ mainbuttons(); mainplates(); defform("70,70,16,Name,70,90,4,Left,70,110,4,Top,70,130,6,Button," "70,150,8,Action"); initrat(&rat); raton(&rat); /* while exit not requested */ do { key = checkinput(); h = rat.horiz; v = rat.verti; if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v))) { ratoff(&rat); if(!dbon) { showform(0,LLEFT); dbon=1; } else { eraseform(0,LLEFT); dbon=0; } raton(&rat); } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v))) { ratoff(&rat); if(!dpon) { showform(0,LLEFT); dpon=1; } else { eraseform(0,LLEFT); dpon=0; } raton(&rat); } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v))) { } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v))) { ratoff(&rat); clearplates(); raton(&rat); options(); ratoff(&rat); mainplates(); raton(&rat); } if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v))) { ratoff(&rat); if(buton) { buttonoff(1); buton = 0; } else { buttonon(1); buton = 1; } raton(&rat); } if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v))) { ratoff(&rat); if(buton) { buttonoff(1); buton = 0; } else { buttonon(1); buton = 1; } raton(&rat); } } while(!(((rat.buttons == LBUTTON && key == RELEASE) || (key == ENTER)) && checkhit(0,h,v) || key == ESC)); ratoff(&rat); shutdown(); /* standard shutdown sequence */ }
void main(void) { int key, formon = 0, buton = 1, f2 = 0, busy = 0, v, h, z; char test; int garb; startup(); /* standard startup sequence */ /* Button */ defbutton(100,450,"End"); defbutton(400,450,"Help"); defplate(0,25,"File"); defplate(58,25,"Form"); defplate(150,25,"DOS"); defplate(350,25,"Display"); defplate(450,25,"Clear"); defplate(522,25,"Edit"); defform("50,50,4,test,50,70,8,test2,50,90,6,test3"); initrat(&rat); raton(&rat); do { key = checkinput(); h = rat.horiz; v = rat.verti; if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v))) { ratoff(&rat); if(formon) { if(f2) busy = 0; removeform(); formon = 0; } else { if(f2) busy = 1; displayform(); formon = 1; } raton(&rat); } if((rat.buttons == RBUTTON && key == PRESS) && (platehit(2,h,v))) { garb = spawnle(P_WAIT,"c:\\command.com",NULL,NULL); if(garb == -1) { shutdown(); perror("\nError"); getch(); exit(1); } } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v))) { if(f2 && !busy) { ratoff(&rat); showdata(0,0,testform.fld1); showdata(0,1,testform.fld2); showdata(0,2,testform.fld3); raton(&rat); } } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(4,h,v))) { if(f2 && !busy) { ratoff(&rat); cleanform(0,0,testform.fld1); cleanform(0,1,testform.fld2); cleanform(0,2,testform.fld3); raton(&rat); } } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(5,h,v))) { if(f2 && !busy) { ratoff(&rat); cleanform(0,0,testform.fld1); for(z=0;z<=10;z++) testform.fld1[z]=NULL; test=get_key(); z=0; while(test != ENTER && z < 4) { testform.fld1[z]=test; showdata(0,0,testform.fld1); z++; test=get_key(); } cleanform(0,1,testform.fld2); for(z=0;z<=10;z++) testform.fld2[z]=NULL; test=get_key(); z=0; while(test != ENTER && z < 8) { testform.fld2[z]=test; showdata(0,1,testform.fld2); z++; test=get_key(); } cleanform(0,2,testform.fld3); for(z=0;z<=10;z++) testform.fld3[z]=NULL; test=get_key(); z=0; while(test != ENTER && z < 6) { testform.fld3[z]=test; showdata(0,2,testform.fld3); test=get_key(); z++; } raton(&rat); } } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v))) { ratoff(&rat); if(f2) { eraseform(0,WITHOUT); f2 = 0; } else { showform(0,WITHOUT); f2 = 1; } raton(&rat); } if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v))) { ratoff(&rat); if(buton) { buttonoff(1); buton = 0; } else { buttonon(1); buton = 1; } raton(&rat); } if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v))) { ratoff(&rat); if(buton) { buttonoff(1); buton = 0; } else { buttonon(1); buton = 1; } raton(&rat); } } while(!(((rat.buttons == LBUTTON && key == RELEASE) || (key == ENTER)) && checkhit(0,h,v) || key == ESC)); ratoff(&rat); shutdown(); }
int deffrm(void) { int key, buton = 1, h, v, end=0; /* on=0; */ dbutplt(); showform(1,LLEFT); /* while exit not requested */ do { key = checkinput(); h = rat.horiz; v = rat.verti; if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v))) { } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v))) { } if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v))) { key = ESC; end = 1; } if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v))) { if(buton) { buttonoff(1); buton = 0; } else { buttonon(1); buton = 1; } } if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v))) { if(buton) { buttonoff(1); buton = 0; } else { buttonon(1); buton = 1; } } } while(!(((rat.buttons == LBUTTON && key == PRESS) || (key == ENTER)) && checkhit(0,h,v) || key == ESC)); eraseform(1,LLEFT); clearplates(); if(end) return(0); else return(1); }
int main(int argc, char *argv[]) { int argi, i; char *username = getenv("REMOTE_USER"); char *userhost = getenv("REMOTE_HOST"); char *userip = getenv("REMOTE_ADDR"); char *fullmsg = "No cause specified"; char *envarea = NULL; int obeycookies = 1; char *accessfn = NULL; if ((username == NULL) || (strlen(username) == 0)) username = "******"; if ((userhost == NULL) || (strlen(userhost) == 0)) userhost = userip; for (argi=1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--no-cookies") == 0) { obeycookies = 0; } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } else if (argnmatch(argv[argi], "--access=")) { char *p = strchr(argv[argi], '='); accessfn = strdup(p+1); } } redirect_cgilog("enadis"); parse_cgi(); if (debug) preview = 1; if (cgi_method == CGI_GET) { /* * It's a GET, so the initial request. * If we have a pagepath cookie, use that as the initial * host-name filter. */ char *pagepath; action = ACT_FILTER; pagepath = get_cookie("pagepath"); if (obeycookies && pagepath && *pagepath) pagepattern = strdup(pagepath); } if (action == ACT_FILTER) { /* Present the query form */ load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); sethostenv("", "", "", colorname(COL_BLUE), NULL); sethostenv_filter(hostpattern, pagepattern, ippattern, classpattern); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); showform(stdout, "maint", "maint_form", COL_BLUE, getcurrenttime(NULL), NULL, NULL); return 0; } fullmsg = (char *)malloc(1024 + strlen(username) + strlen(userhost) + strlen(disablemsg)); sprintf(fullmsg, "\nDisabled by: %s @ %s\nReason: %s\n", username, userhost, disablemsg); /* * Ready ... go build the webpage. */ printf("Content-Type: %s\n", xgetenv("HTMLCONTENTTYPE")); if (!preview) { char *returl; // dbgprintf("Not a preview: sending to %s\n", textornull(getenv("HTTP_REFERER"))); /* We're done -- figure out where to send them */ if (getenv("HTTP_REFERER")) printf("Location: %s\n\n", getenv("HTTP_REFERER")); else { returl = (char *)malloc(1024); snprintf(returl, sizeof(returl), "%s/%s", xgetenv("SECURECGIBINURL"), "enadis.sh"); printf("Location: %s?\n\n", returl); } } else { printf("\n"); } /* It's ok with these hardcoded values, as they are not used for this page */ sethostenv("", "", "", colorname(COL_BLUE), NULL); if (preview) headfoot(stdout, "maintact", "", "header", COL_BLUE); if (debug) { printf("<pre>\n"); switch (action) { case ACT_NONE : dbgprintf("Action = none\n"); break; case ACT_FILTER : dbgprintf("Action = filter\n"); break; case ACT_ENABLE : dbgprintf("Action = enable\n"); dbgprintf("Tests = "); for (i=0; (i < enablecount); i++) printf("%s ", enabletest[i]); printf("\n"); break; case ACT_DISABLE: dbgprintf("Action = disable\n"); dbgprintf("Tests = "); for (i=0; (i < disablecount); i++) printf("%s ", disabletest[i]); printf("\n"); if (disableend == DISABLE_UNTIL) { dbgprintf("Disable until: endtime = %d, duration = %d, scale = %d\n", endtime, duration, scale); } else { dbgprintf("Duration = %d, scale = %d\n", duration, scale); } dbgprintf("Cause = %s\n", textornull(disablemsg)); break; case ACT_SCHED_DISABLE: dbgprintf("Action = schedule\n"); dbgprintf("Time = %s\n", ctime(&schedtime)); dbgprintf("Tests = "); for (i=0; (i < disablecount); i++) printf("%s ", disabletest[i]); printf("\n"); if (disableend == DISABLE_UNTIL) { dbgprintf("Disable until: endtime = %d, duration = %d, scale = %d\n", endtime, duration, scale); } else { dbgprintf("Duration = %d, scale = %d\n", duration, scale); } dbgprintf("Cause = %s\n", textornull(disablemsg)); break; case ACT_SCHED_CANCEL: dbgprintf("Action = cancel\n"); dbgprintf("ID = %d\n", cancelid); break; } printf("</pre>\n"); } if (preview) printf("<table align=\"center\" summary=\"Actions performed\" width=\"60%%\">\n"); if (action == ACT_SCHED_CANCEL) { do_one_host(NULL, NULL, username); } else { /* Load the host data (for access control) */ if (accessfn) { load_web_access_config(accessfn); for (i = 0; (i < hostcount); i++) { if (web_access_allowed(getenv("REMOTE_USER"), hostnames[i], NULL, WEB_ACCESS_CONTROL)) { do_one_host(hostnames[i], fullmsg, username); } } } else { for (i = 0; (i < hostcount); i++) do_one_host(hostnames[i], fullmsg, username); } } if (preview) { printf("<tr><td align=center><br><br><form method=\"GET\" ACTION=\"%s\"><input type=submit value=\"Continue\"></form></td></tr>\n", xgetenv("HTTP_REFERER")); printf("</table>\n"); headfoot(stdout, "maintact", "", "footer", COL_BLUE); } return 0; }
int main(int argc, char *argv[]) { int argi; char *envarea = NULL; int obeycookies = 1; char *accessfn = NULL; for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } else if (strcmp(argv[argi], "--no-pin") == 0) { nopin = 1; } else if (strcmp(argv[argi], "--no-cookies") == 0) { obeycookies = 0; } else if (argnmatch(argv[argi], "--access=")) { char *p = strchr(argv[argi], '='); accessfn = strdup(p+1); } } redirect_cgilog("ack"); cgidata = cgi_request(); if ( (nopin && (cgi_method == CGI_GET)) || (!nopin && (cgidata == NULL)) ) { /* Present the query form */ sethostenv("", "", "", colorname(COL_RED), NULL); printf("Content-Type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); if (!nopin) { showform(stdout, "acknowledge", "acknowledge_form", COL_RED, getcurrenttime(NULL), NULL, NULL); } else { char *cmd; char *respbuf = NULL; char *hostname, *pagename; int gotfilter = 0, filtererror = 0; sendreturn_t *sres = NULL; int col, firstcolor = 1, alertcolors = colorset(xgetenv("ALERTCOLORS"), ((1 << COL_GREEN) | (1 << COL_BLUE))); headfoot(stdout, "acknowledge", "", "header", COL_RED); cmd = (char *)malloc(1024); strcpy(cmd, "xymondboard fields=hostname,testname,cookie color="); for (col = 0; (col < COL_COUNT); col++) { if ((1 << col) & alertcolors) { if (!firstcolor) strcat(cmd, ","); strcat(cmd, colorname(col)); firstcolor = 0; } } // printf("<!-- cmd = %s -->\n", cmd); if (obeycookies && !gotfilter && ((hostname = get_cookie("host")) != NULL)) { if (*hostname) { pcre *dummy; char *re; re = (char *)malloc(3+strlen(hostname)); sprintf(re, "^%s$", hostname); dummy = compileregex(re); if (dummy) { /* Valid expression */ freeregex(dummy); cmd = (char *)realloc(cmd, 1024 + strlen(cmd) + strlen(re)); sprintf(cmd + strlen(cmd), " host=%s", re); gotfilter = 1; } else { filtererror = 1; printf("<p align=\"center\">Invalid hostname filter</p>\n"); } } } if (obeycookies && !gotfilter && ((pagename = get_cookie("pagepath")) != NULL)) { if (*pagename) { pcre *dummy; char *re; re = (char *)malloc(8 + strlen(pagename)*2); sprintf(re, "%s$|^%s/.+", pagename, pagename); dummy = compileregex(re); if (dummy) { /* Valid expression */ freeregex(dummy); cmd = (char *)realloc(cmd, 1024 + strlen(cmd) + strlen(re)); sprintf(cmd + strlen(cmd), " page=%s", re); gotfilter = 1; } else { filtererror = 1; printf("<p align=\"center\">Invalid pagename filter</p>\n"); } } } sres = newsendreturnbuf(1, NULL); if (!filtererror && (sendmessage(cmd, NULL, XYMON_TIMEOUT, sres) == XYMONSEND_OK)) { char *bol, *eoln; int first = 1; respbuf = getsendreturnstr(sres, 1); bol = respbuf; while (bol) { char *hname, *tname, *ackcode; eoln = strchr(bol, '\n'); if (eoln) *eoln = '\0'; hname = tname = ackcode = NULL; hname = strtok(bol, "|"); if (hname) tname = strtok(NULL, "|"); if (tname) ackcode = strtok(NULL, "|"); if (hname && tname && ackcode && (strcmp(hname, "summary") != 0)) { if (first) { fprintf(stdout, "<form method=\"POST\" ACTION=\"%s\">\n", getenv("SCRIPT_NAME")); fprintf(stdout, "<center><table cellpadding=5 summary=\"Ack data\">\n"); fprintf(stdout, "<tr><th align=left>Host</th><th align=left>Test</th><th align=left>Duration</th><th align=left>Cause</th><th>Ack</th><th>Ack Multiple</tr>\n"); first = 0; } generate_ackline(stdout, hname, tname, ackcode); } if (eoln) bol = eoln+1; else bol = NULL; } if (first) { fprintf(stdout, "<center><font size=\"+1\"><b>No active alerts</b></font></center>\n"); } else { generate_ackline(stdout, NULL, NULL, NULL); fprintf(stdout, "</table></center>\n"); fprintf(stdout, "</form>\n"); } } freesendreturnbuf(sres); headfoot(stdout, "acknowledge", "", "footer", COL_RED); } } else if ( (nopin && (cgi_method == CGI_POST)) || (!nopin && (cgidata != NULL)) ) { char *xymonmsg; char *acking_user = ""; acklist_t *awalk; strbuffer_t *response = newstrbuffer(0); int count = 0; /* We only want to accept posts from certain pages */ { char cgisource[1024]; char *p; p = csp_header("acknowledge"); if (p) fprintf(stdout, "%s", p); snprintf(cgisource, sizeof(cgisource), "%s/%s", xgetenv("SECURECGIBINURL"), "acknowledge"); if (!cgi_refererok(cgisource)) { fprintf(stdout, "Location: %s.sh?\n\n", cgisource); return 0; } } parse_query(); if (getenv("REMOTE_USER")) { char *remaddr = getenv("REMOTE_ADDR"); acking_user = (char *)malloc(1024 + strlen(getenv("REMOTE_USER")) + (remaddr ? strlen(remaddr) : 0)); sprintf(acking_user, "\nAcked by: %s", getenv("REMOTE_USER")); if (remaddr) sprintf(acking_user + strlen(acking_user), " (%s)", remaddr); } /* Load the host data (for access control) */ if (accessfn) { load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); load_web_access_config(accessfn); } addtobuffer(response, "<center>\n"); for (awalk = ackhead; (awalk); awalk = awalk->next) { char *msgline = (char *)malloc(1024 + (awalk->hostname ? strlen(awalk->hostname) : 0) + (awalk->testname ? strlen(awalk->testname) : 0)); if (!awalk->checked) continue; if (accessfn && (!web_access_allowed(getenv("REMOTE_USER"), awalk->hostname, awalk->testname, WEB_ACCESS_CONTROL))) continue; if ((reqtype == ACK_ONE) && (awalk->id != sendnum)) continue; if (reqtype == ACK_MANY) { if (!awalk->ackmsg) awalk->ackmsg = ackmsgall; if (!awalk->validity && validityall) awalk->validity = durationvalue(validityall); if (periodall) awalk->period = periodall; } if (strncmp(awalk->period, "hour", 4) == 0) awalk->validity *= 60; else if (strncmp(awalk->period, "day", 4) == 0) awalk->validity *= 60*24; count++; if (!awalk->ackmsg || !awalk->validity || !awalk->acknum) { if (awalk->hostname && awalk->testname) { sprintf(msgline, "<b>NO ACK</b> sent for host %s / test %s", htmlquoted(awalk->hostname), htmlquoted(awalk->testname)); } else { sprintf(msgline, "<b>NO ACK</b> sent for item %d", awalk->id); } addtobuffer(response, msgline); addtobuffer(response, ": Duration or message not set<br>\n"); continue; } xymonmsg = (char *)malloc(1024 + strlen(awalk->ackmsg) + strlen(acking_user)); sprintf(xymonmsg, "xymondack %d %d %s %s", awalk->acknum, awalk->validity, awalk->ackmsg, acking_user); if (sendmessage(xymonmsg, NULL, XYMON_TIMEOUT, NULL) == XYMONSEND_OK) { if (awalk->hostname && awalk->testname) { sprintf(msgline, "Acknowledge sent for host %s / test %s<br>\n", htmlquoted(awalk->hostname), htmlquoted(awalk->testname)); } else { sprintf(msgline, "Acknowledge sent for code %d<br>\n", awalk->acknum); } } else { if (awalk->hostname && awalk->testname) { sprintf(msgline, "Failed to send acknowledge for host %s / test %s<br>\n", htmlquoted(awalk->hostname), htmlquoted(awalk->testname)); } else { sprintf(msgline, "Failed to send acknowledge for code %d<br>\n", awalk->acknum); } } addtobuffer(response, msgline); xfree(xymonmsg); } if (count == 0) addtobuffer(response, "<b>No acks requested</b>\n"); addtobuffer(response, "</center>\n"); fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); headfoot(stdout, "acknowledge", "", "header", COL_RED); fprintf(stdout, "%s", STRBUF(response)); headfoot(stdout, "acknowledge", "", "footer", COL_RED); } return 0; }
int main(int argc, char *argv[]) { int argi; char *envarea = NULL; char *hffile = "useradm"; int bgcolor = COL_BLUE; char *passfile = NULL; FILE *fd; char *infomsg = NULL; for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } else if (argnmatch(argv[argi], "--passwdfile=")) { char *p = strchr(argv[argi], '='); passfile = strdup(p+1); } } if (passfile == NULL) { passfile = (char *)malloc(strlen(xgetenv("XYMONHOME")) + 20); sprintf(passfile, "%s/etc/xymonpasswd", xgetenv("XYMONHOME")); } switch (parse_query()) { case ACT_NONE: /* Show the form */ break; case ACT_CREATE: /* Add a user */ { char *cmd; int n, ret; cmd = (char *)malloc(1024 + strlen(passfile) + strlen(adduser_name) + strlen(adduser_password)); sprintf(cmd, "htpasswd -b '%s' '%s' '%s'", passfile, adduser_name, adduser_password); n = system(cmd); n = system(cmd); ret = WEXITSTATUS(n); if ((n == -1) || (ret != 0)) { infomsg = "<SCRIPT LANGUAGE=\"Javascript\" type=\"text/javascript\"> alert('Update FAILED'); </SCRIPT>\n"; } else { infomsg = "<SCRIPT LANGUAGE=\"Javascript\" type=\"text/javascript\"> alert('User added/updated'); </SCRIPT>\n"; } xfree(cmd); } break; case ACT_DELETE: /* Delete a user */ { char *cmd; int n, ret; cmd = (char *)malloc(1024 + strlen(passfile) + strlen(deluser_name)); snprintf(cmd, sizeof(cmd), "htpasswd -D '%s' '%s'", passfile, deluser_name); n = system(cmd); ret = WEXITSTATUS(n); if ((n == -1) || (ret != 0)) { infomsg = "<SCRIPT LANGUAGE=\"Javascript\" type=\"text/javascript\"> alert('Update delete FAILED'); </SCRIPT>\n"; } else { infomsg = "<SCRIPT LANGUAGE=\"Javascript\" type=\"text/javascript\"> alert('User deleted'); </SCRIPT>\n"; } xfree(cmd); } break; } sethostenv_clearlist(NULL); sethostenv_addtolist(NULL, "", "", NULL, 1); /* Have a blank entry first so we won't delete one by accident */ fd = fopen(passfile, "r"); if (fd != NULL) { char l[1024]; char *id, *delim; int usercount; char **userlist; int i; usercount = 0; userlist = (char **)calloc(usercount+1, sizeof(char *)); while (fgets(l, sizeof(l), fd)) { id = l; delim = strchr(l, ':'); if (delim) { *delim = '\0'; usercount++; userlist = (char **)realloc(userlist, (usercount+1)*sizeof(char *)); userlist[usercount-1] = strdup(id); userlist[usercount] = NULL; } } fclose(fd); qsort(&userlist[0], usercount, sizeof(char *), idcompare); for (i=0; (userlist[i]); i++) sethostenv_addtolist(NULL, userlist[i], userlist[i], NULL, 0); } fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); showform(stdout, hffile, "useradm_form", COL_BLUE, getcurrenttime(NULL), infomsg, NULL); return 0; }
int main(int argc, char *argv[]) { int argi; char *envarea = NULL; char *hffile = "hostgraphs"; char *formfile = "hostgraphs_form"; for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } else if (argnmatch(argv[argi], "--hffile=")) { char *p = strchr(argv[argi], '='); hffile = strdup(p+1); formfile = (char *)malloc(strlen(hffile) + 6); sprintf(formfile, "%s_form", hffile); } } parse_query(); fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); if (action == A_SELECT) { char *cookie; cookie = get_cookie("pagepath"); if (!pagepattern && cookie && *cookie) { /* Match the exact pagename and sub-pages */ pagepattern = (char *)malloc(10 + 2*strlen(cookie)); sprintf(pagepattern, "^%s$|^%s/.+", cookie, cookie); } if (hostpattern || pagepattern || ippattern || classpattern) sethostenv_filter(hostpattern, pagepattern, ippattern, classpattern); showform(stdout, hffile, formfile, COL_BLUE, getcurrenttime(NULL), NULL, NULL); } else if ((action == A_GENERATE) && hosts && hosts[0] && tests && tests[0]) { int hosti, testi; headfoot(stdout, hffile, "", "header", COL_GREEN); fprintf(stdout, "<table align=\"center\" summary=\"Graphs\">\n"); for (testi=0; (tests[testi]); testi++) { fprintf(stdout, "<tr><td><img src=\"%s/showgraph.sh?host=%s", xgetenv("CGIBINURL"), htmlquoted(hosts[0])); for (hosti=1; (hosts[hosti]); hosti++) fprintf(stdout, ",%s", htmlquoted(hosts[hosti])); fprintf(stdout, "&service=%s&graph_start=%ld&graph_end=%ld&graph=custom&action=view&graph_height=%s&graph_width=%s\"></td></tr>\n", htmlquoted(tests[testi]), (long int)starttime, (long int)endtime, xgetenv("RRDHEIGHT"), xgetenv("RRDWIDTH")); } fprintf(stdout, "</table><br><br>\n"); headfoot(stdout, hffile, "", "footer", COL_GREEN); } return 0; }
int main(int argc, char **argv) { pcre *hostptn, *exhostptn, *pageptn, *expageptn; void *hwalk; char *hostname, *pagename; hostptn = exhostptn = pageptn = expageptn = NULL; if (getenv("QUERY_STRING") == NULL) { /* Not invoked through the CGI */ if (argc < 4) { errprintf("Usage:\n%s HOSTNAME-PATTERN STARTTIME ENDTIME", argv[0]); return 1; } hostpattern = argv[1]; if (strncmp(hostpattern, "--page=", 7) == 0) { pagepattern = strchr(argv[1], '=') + 1; hostpattern = NULL; } starttimedate = argv[2]; starttimehm = "00:00:00"; endtimedate = argv[3]; endtimehm = "00:00:00"; if (argc > 4) { if (strncmp(argv[4], "--csv", 5) == 0) { char *p; outform = O_CSV; if ((p = strchr(argv[4], '=')) != NULL) csvdelim = *(p+1); } } } else { char *envarea = NULL; int argi; for (argi = 1; (argi < argc); argi++) { if (argnmatch(argv[argi], "--env=")) { char *p = strchr(argv[argi], '='); loadenv(p+1, envarea); } else if (argnmatch(argv[argi], "--area=")) { char *p = strchr(argv[argi], '='); envarea = strdup(p+1); } else if (strcmp(argv[argi], "--debug") == 0) { debug = 1; } } /* Parse CGI parameters */ parse_query(); format_rrdtime(starttime, &starttimedate, &starttimehm); format_rrdtime(endtime, &endtimedate, &endtimehm); switch (outform) { case O_XML: printf("Content-type: application/xml\n\n"); break; case O_CSV: printf("Content-type: text/csv\n\n"); break; case O_NONE: load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); printf("Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE")); showform(stdout, "perfdata", "perfdata_form", COL_BLUE, getcurrenttime(NULL), NULL, NULL); return 0; } } load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn()); if (hostpattern) hostptn = compileregex(hostpattern); if (exhostpattern) exhostptn = compileregex(exhostpattern); if (pagepattern) pageptn = compileregex(pagepattern); if (expagepattern) expageptn = compileregex(expagepattern); switch (outform) { case O_XML: printf("<?xml version='1.0' encoding='ISO-8859-1'?>\n"); printf("<datasets>\n"); break; default: break; } dbgprintf("Got hosts, it is %s\n", (first_host() == NULL) ? "empty" : "not empty"); for (hwalk = first_host(); (hwalk); hwalk = next_host(hwalk, 0)) { hostname = xmh_item(hwalk, XMH_HOSTNAME); pagename = xmh_item(hwalk, XMH_PAGEPATH); dbgprintf("Processing host %s\n", hostname); if (hostpattern && !matchregex(hostname, hostptn)) continue; if (exhostpattern && matchregex(hostname, exhostptn)) continue; if (pagepattern && !matchregex(pagename, pageptn)) continue; if (expagepattern && matchregex(pagename, expageptn)) continue; onehost(hostname, starttime, endtime); } switch (outform) { case O_XML: printf("</datasets>\n"); break; default: break; } return 0; }