Jump to content
xisto Community

vipervoid

Members
  • Content Count

    15
  • Joined

  • Last visited

About vipervoid

  • Rank
    Newbie [Level 1]
  1. 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?
  2. ewcreators is right. i want to see the last person who posted. the reason that i've created my own forum is i just want to experience doing one. thanks for the help guys. i'll test that update thing.
  3. hi guys. I have a little problem here. Im making my own version of forum, just got into this problem on the last post from the topic and displaying the users avatar.i already have a upload script but not for images. I tried making some experiments but it didnt work. maybe someone here could help me. just want to:1.) query the last post.2.)display the avatar of the user
  4. Very nice! I like this post! thanks for all the links guys!
  5. thats nice.. , that could be helpful for some newbies.
  6. Hi guys, can somebody help me with this problem. I want to make my URL static. something like this: http://www.example.com/ whenever click some buttons like add/edit/delete... the URL should stay as is... (http://www.example.com/).
  7. vipervoid

    Session2

    Maybe next time you should post specific topics so that no one would complain.
  8. it would be nice if most of the Xisto users post about this topic.
  9. Can i see the codes pls?
  10. Im still using C right now! Its really good to use! especially when you're doing you're work on linux.. Its really handy to have a background in C!
  11. wow! that code from a winner of world most obsfucated code contest was very great! I dont know how will i say it but if you'll ask me to rate it... hmmm 10/10! That's really amazing! wish i could make something like that someday! hehe!
  12. I've never tried accupuncture... but most say that it reliefs your body and is a treatment for many ailments.
  13. Im not satisfied with my body right now... I also want to gain weight, I eat 5x a day, I checked my weight after a week but still the same nothing has changed my weight didnt changed a bit. That made me wonder, Maybe because of the daily routine that i do. Im not the kind of person who sits and stays in bed eating or watching TV or movies. hmmm... maybe it will take more than a week to see results...
  14. wow! That's really cool! but still i would prefer having my body parts natural.. :XD:
  15. Right now, im extremely addicted to smoking, its really hard to quit this addiction. I even say to myself most of the time that i will quit smoking. BUT its just all in my mind! I think my body get used to this daily routine. I started smoking when i was just 13 years old. But then i was just trippin, never thought that i would be addicted with this. :XD: But then it turn to a serious addiction that gave me a big headache! can somebody help me? need advices...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.