int main(void) { char cmd[1024]; char *l, *lines; int x_p, offset; s_cgi **c; printf("Pragma: no-cache\nContent-type: text/plain\n\n"); fflush(stdout); c = cgiInit(); if(!c) return 0; if(!isFileExisted(RRDTOOL_PATH)){ printf("no_rrdtool"); return 0; } if(! (l = cgiGetValue(c, "w")) ){ return 0; } x_p = atoi(l); if(! (l = cgiGetValue(c, "offset")) ){ printf("no offset"); return 0; } offset = atoi(l); if(! x_p || !offset) return 0; if(! (l = cgiGetValue(c, "lines")) ){ printf("no lines"); return 0; } if(! (lines = strdup(l)) ) return 0; cgiDecodeString(lines); if(! isValidString(lines)){ goto end; } snprintf(cmd, 1024, "%s graph /var/anything %s -w %d -s %d", RRDTOOL_PATH, lines, x_p, time(NULL)+offset ); system(cmd); system("ls / > /var/wow"); fflush(stdout); end: free(lines); return 0; }
INT32 _dpsLogFilter::doParse() { INT32 rc = SDB_OK ; BOOLEAN Open = FALSE ; CHAR dstFile[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ; OSSFILE fileFrom, fileTo ; if( isDir( _cmdData->dstPath ) ) { INT32 len = ossStrlen( _cmdData->dstPath ) ; if ( OSS_FILE_SEP_CHAR == _cmdData->dstPath[ len - 1 ] ) { ossSnprintf( dstFile, OSS_MAX_PATHSIZE, "%s%s", _cmdData->dstPath, "tmpLog.log" ) ; } else { ossSnprintf( dstFile, OSS_MAX_PATHSIZE, "%s"OSS_FILE_SEP"%s", _cmdData->dstPath, "tmpLog.log" ) ; } } else { ossSnprintf( dstFile, OSS_MAX_PATHSIZE, "%s", _cmdData->dstPath ) ; } if( !_cmdData->output ) { rc = ossOpen( dstFile, OSS_REPLACE | OSS_READWRITE, OSS_RU | OSS_WU | OSS_RG, fileTo ) ; if( rc ) { printf( "Unable to open file: %s\n", dstFile ) ; goto error ; } Open = TRUE ; } if ( SDB_LOG_FILTER_META == _filter->getType() ) { rc = _filter->doFilte( _cmdData, fileTo, NULL ) ; if( rc ) { goto error ; } goto done ; } if( isDir( _cmdData->srcPath ) ) { if( SDB_LOG_FILTER_LAST == _filter->getType() ) { printf( "Error: Cannot specify a dir path when using --last/-e\n" ); rc = SDB_INVALIDARG ; goto error ; } INT32 const MAX_FILE_COUNT = getFileCount( _cmdData->srcPath ) ; if( 0 >= MAX_FILE_COUNT ) { printf( "Cannot find any Log files\nPlease check" " and input the correct log file path\n" ) ; rc = SDB_INVALIDPATH ; goto error ; } for( INT32 idx = 0 ; idx < MAX_FILE_COUNT ; ++idx ) { fs::path fileDir( _cmdData->srcPath ) ; const CHAR *filepath = fileDir.string().c_str() ; CHAR filename[ OSS_MAX_PATHSIZE * 2 ] = { 0 } ; ossSnprintf( filename, OSS_MAX_PATHSIZE, "%s/sequoiadbLog.%d", filepath, idx ) ; if( !isFileExisted( filename ) ) { rc = SDB_INVALIDPATH ; goto error ; } rc = _filter->doFilte( _cmdData, fileTo, filename ) ; if( rc && idx != MAX_FILE_COUNT - 1 ) { rc = SDB_OK ; continue ; } } } else { if( !isFileExisted( _cmdData->srcPath ) ) { rc = SDB_INVALIDPATH ; goto error ; } rc = _filter->doFilte( _cmdData, fileTo, _cmdData->srcPath ) ; if( rc ) { goto error ; } } done: if( Open ) { ossClose( fileTo ) ; } return rc ; error: goto done ; }