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

Diff of /monit/util.c

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

revision 1.87 by chopp, Sun Sep 14 00:03:54 2003 UTC revision 1.88 by chopp, Mon Sep 15 13:02:02 2003 UTC
# Line 915  char *get_RFC822date(long *date) { Line 915  char *get_RFC822date(long *date) {
915   * @param pidfile A process pidfile   * @param pidfile A process pidfile
916   * @return an uptime string   * @return an uptime string
917   */   */
918  char *get_process_uptime(char *pidfile) {  char *get_process_uptime(char *pidfile, char *sep) {
919    
920    time_t ctime;    time_t ctime;
921    
# Line 926  char *get_process_uptime(char *pidfile) Line 926  char *get_process_uptime(char *pidfile)
926      time_t now= time(&now);      time_t now= time(&now);
927      time_t since= now-ctime;      time_t since= now-ctime;
928    
929      return get_uptime(since);      return get_uptime(since,sep);
930            
931    }    }
932    
# Line 941  char *get_process_uptime(char *pidfile) Line 941  char *get_process_uptime(char *pidfile)
941   * @param delta seconds.   * @param delta seconds.
942   * @return an uptime string   * @return an uptime string
943   */   */
944  char *get_uptime(time_t delta) {  char *get_uptime(time_t delta, char *sep) {
945    
946    static int min= 60;    static int min= 60;
947    static int hour= 3600;    static int hour= 3600;
# Line 955  char *get_uptime(time_t delta) { Line 955  char *get_uptime(time_t delta) {
955    *buf= 0;    *buf= 0;
956    
957    if((rest_d= delta/day)>0) {    if((rest_d= delta/day)>0) {
958      p+= snprintf(p, STRLEN-(p-buf), "%ldd ", rest_d);      p+= snprintf(p, STRLEN-(p-buf), "%ldd%s", rest_d,sep);
959      delta-= rest_d*day;      delta-= rest_d*day;
960    }    }
961    if((rest_h= delta/hour)>0 || (rest_d > 0)) {    if((rest_h= delta/hour)>0 || (rest_d > 0)) {
962      p+= snprintf(p, STRLEN-(p-buf),"%ldh ", rest_h);      p+= snprintf(p, STRLEN-(p-buf),"%ldh%s", rest_h,sep);
963      delta-= rest_h*hour;      delta-= rest_h*hour;
964    }    }
965        
966    rest_m= delta/min;    rest_m= delta/min;
967    p+= snprintf(p, STRLEN-(p-buf),"%ldm ", rest_m);    p+= snprintf(p, STRLEN-(p-buf),"%ldm%s", rest_m,sep);
968    delta-= rest_m*min;    delta-= rest_m*min;
969    
970    return xstrdup(buf);    return xstrdup(buf);

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.88

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