/[monit]/monit/util.c
ViewVC logotype

Diff of /monit/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by hauk, Thu Sep 5 14:05:53 2002 UTC revision 1.29 by chopp, Fri Sep 6 08:27:57 2002 UTC
# Line 749  char *get_uptime(time_t delta) { Line 749  char *get_uptime(time_t delta) {
749    static int min= 60;    static int min= 60;
750    static int hour= 3600;    static int hour= 3600;
751    static int day= 86400;    static int day= 86400;
752    long rest;    long rest_d;
753      long rest_h;
754      long rest_m;
755    char buf[STRLEN];    char buf[STRLEN];
756    char *p= buf;    char *p= buf;
757    
758    *buf= 0;    *buf= 0;
759        
760    if((rest= delta/day)>0) {    if((rest_d= delta/day)>0) {
761      p+= sprintf(p, "%ldd ", rest);      p+= sprintf(p, "%ldd ", rest_d);
762      delta-= rest*day;      delta-= rest_d*day;
763    }    }
764    if((rest= delta/hour)>0) {    if((rest_h= delta/hour)>0 || ( rest_d > 0 )) {
765      p+= sprintf(p, "%ldh ", rest);      p+= sprintf(p, "%ldh ", rest_h);
766      delta-= rest*hour;      delta-= rest_h*hour;
   }  
   if((rest= delta/min)>0) {  
     p+= sprintf(p, "%ldm ", rest);  
     delta-= rest*min;  
767    }    }
768      
769      rest_m= delta/min;
770      p+= sprintf(p, "%ldm ", rest_m);
771      delta-= rest_m*min;
772    
773    return xstrdup(buf);    return xstrdup(buf);
774    

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26