HOME       >>       Programming

Help Pls.. help pls..


vipervoid

hi guys, can somebody help me out with this case.. Im making a daemon which will automize the services(i.e. check if load if high, then stop services) with config files.this is how my program works:1.) check config files which is placed folder(i.e httpd.conf, mysqld.conf).2.) open each file and check the configuration(make checks if load is greater than the limit which the daemon will execute a command).3.) check if service is running or not(check on the /proc/pid/status, opens all folder which is numeric).4.) stop or start service (depends on what is configured inside the file).5.) back to step 1.now the problem is the daemon suddenly dies after a few minutes(30-50mins).i think its in this function...

int is_up(char *svc){DIR *dir_pn;struct dirent *dir_entry_pn;char _name[64], name[64], _state[64], stat[2], state[64], _sleepavg[64], sleepavg[64], _tgid[64], _pid[64], _ppid[64],_tracerpid[64],_uid[16],_gid[16];char _fdsize[16],_groups[16],_vmpeak[16],_vmsize[16],_vmlck[16],_vmhwm[16];char _vmrss[16], _vmdata[16], _vmstk[16],_vmexe[16],_vmlib[16],_vmpte[16];char _stabrk[16],_brk[16],_stastk[16],_execlim[16],_threads[16],_sigq[16];char _sigpnd[16],_shdpnd[16],_sigblk[16],_sigign[16],_sigcgt[16],_capinh[16];char _capprm[16],_capeff[16],_cpus_allowed[16],_mems_allowed[16];int tgid = 0, pid = 0, ppid = 0,tracerpid = 0,uid1 = 0,uid2 = 0,uid3 = 0,uid4 = 0;int gid1 = 0,gid2 = 0,gid3 = 0,gid4 = 0,fdsize = 0,vmpeak = 0,vmsize = 0,vmlck = 0;int vmhwm = 0,vmrss = 0,vmdata = 0,vmstk = 0,vmexe = 0,vmlib = 0,vmpte = 0;int threads = 0,mems_allowed = 0;char stastk[16],execlim[16],brk[16],stabrk[16],sigq[16],sigpnd[16],shdpnd[16],sigblk[16],sigign[16],sigcgt[16],capinh[16];char capprm[16],capeff[16],cpus_allowed[16];char kb1[2],kb2[2],kb3[2],kb4[2],kb5[2],kb6[2],kb7[2],kb8[2],kb9[2],kb10[2],kb11[2],kb12[2],kb13[2];int ctr = 0;char *svcstore;dir_pn = opendir("/proc");FILE *fp, *file;while(NULL != (dir_entry_pn = readdir(dir_pn))){char *newdir, *_newdir;char dir[] = "/proc/";char status[] = "/status";if(isnum(dir_entry_pn->d_name) == 1){newdir = strcat(dir, dir_entry_pn->d_name);_newdir = strcat(newdir, status);fp = fopen(_newdir, "r");while(fscanf(fp, "%s %s\n%s %s %s\n%s %s\n%s %d\n%s %d\n%s %d\n%s %d\n%s %d %d %d %d\n%s %d %d %d %d\n%s %d\n%s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %d %s\n%s %s\n%s %d\n%s %s\n%s %s\n%s %s\n%s %s\n%s %s\n%s %s\n%s %s\n%s %s\n%s %s\n%s %d", &_name, &name, &_state, &stat, &state, &_sleepavg, &sleepavg, &_tgid, &tgid, &_pid, &pid, &_ppid, &ppid,&_tracerpid,&tracerpid,&_uid,&uid1,&uid2,&uid3,&uid4,&_gid,&gid1,&gid2,&gid3,&gid4,&_fdsize,&fdsize,&_groups,&_vmpeak,&vmpeak,&kb1,&_vmsize,&vmsize,&kb2,&_vmlck,&vmlck,&kb3,&_vmhwm,&vmhwm,&kb4,&_vmrss,&vmrss,&kb5,&_vmdata,&vmdata,&kb6,&_vmstk,&vmstk,&kb7,&_vmexe,&vmexe,&kb8,&_vmlib,&vmlib,&kb9,&_vmpte,&vmpte,&kb10,&_stabrk,&stabrk,&kb11,&_brk,&brk,&kb12,&_stastk,&stastk,&kb13,&_execlim,&execlim,&_threads,&threads,&_sigq,&sigq,&_sigpnd,&sigpnd,&_sigblk,&sigblk,&_sigign,&sigign,&_sigcgt,&sigcgt,&_capinh,&capinh,&_capprm,&capprm,&_capeff,&capeff,&_cpus_allowed,&cpus_allowed,&_mems_allowed,&mems_allowed)!= EOF){if(strcmp(svc, name) == 0)return(1);}fclose(fp);}}closedir(dir_pn);free(svc);return(0);}

what do you think can be the problem?



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.