home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2870 / stats.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  1.8 KB  |  73 lines

  1. /*
  2.  * Copyright 1988, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #ifndef    lint
  13. static    char    sccsid[] = "@(#)stats.c    1.2    22:55:39    2/21/91";
  14. #endif
  15.  
  16. #include <sys/param.h>
  17. #include <sys/sysmacros.h>
  18. #include <sys/types.h>
  19. #include <sys/utsname.h>
  20. #include <sys/param.h>
  21. #include <a.out.h>
  22. #include <time.h>
  23. #include "crash.h"
  24.  
  25. #define    MINUTE    (60L)
  26. #define    HOUR    (MINUTE*60L)
  27. #define    DAY    (HOUR*24L)
  28.  
  29. prstats ()
  30. {
  31.     l_lseek (kmemfd, namelist[NM_UTSNAME].xl_value, 0);
  32.     r_read (kmemfd, &utsname, sizeof utsname);
  33.  
  34.     l_lseek (kmemfd, namelist[NM_TIME].xl_value, 0);
  35.     r_read (kmemfd, &ktime, sizeof ktime);
  36.  
  37.     l_lseek (kmemfd, namelist[NM_LBOLT].xl_value, 0);
  38.     r_read (kmemfd, &klbolt, sizeof klbolt);
  39.  
  40.     printf ("    sysname: %.*s\n",
  41.         sizeof utsname.sysname, utsname.sysname);
  42.     printf ("    nodename: %.*s\n",
  43.         sizeof utsname.nodename, utsname.nodename);
  44.     printf ("    release: %.*s\n",
  45.         sizeof utsname.release, utsname.release);
  46.     printf ("    version: %.*s\n",
  47.         sizeof utsname.version, utsname.version);
  48.     printf ("    machine: %.*s\n",
  49.         sizeof utsname.machine, utsname.machine);
  50.  
  51.     printf ("    time of crash: %s", ctime (&ktime));
  52.  
  53.     klbolt /= HZ;            /* convert to seconds */
  54.  
  55.     printf ("    age of system:");
  56.  
  57.     if (klbolt >= DAY)
  58.         printf (" %d %s,", klbolt / DAY,
  59.             klbolt >= (2*DAY) ? "days":"day");
  60.  
  61.     klbolt %= DAY;
  62.  
  63.     if (klbolt >= HOUR)
  64.         printf (" %d %s,", klbolt / HOUR,
  65.             klbolt >= (2*HOUR) ? "hrs.":"hr.");
  66.  
  67.     klbolt %= HOUR;
  68.     klbolt /= MINUTE;
  69.  
  70.     printf (" %d %s\n", klbolt,
  71.         klbolt == 0 || klbolt >= 2 ? "mins.":"min.");
  72. }
  73.