/[machmon]/machmon/linux/source/sys.c
ViewVC logotype

Diff of /machmon/linux/source/sys.c

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

revision 1.5 by pbastos, Tue Jul 9 14:48:59 2002 UTC revision 1.6 by clorets, Mon Jul 15 20:41:36 2002 UTC
# Line 44  Line 44 
44  #include "global.h"  #include "global.h"
45  #include "extern.h"  #include "extern.h"
46    
47    
48  double                  maxload;  double                  maxload;
49  volatile sig_atomic_t   sigrecv;  volatile sig_atomic_t   sigrecv;
50    
# Line 115  d_htnm(void) Line 116  d_htnm(void)
116  int  int
117  d_users(void)  d_users(void)
118  {  {
119          char buf[16];          char buf[16];
120          int f, tmp, nusers = 0;          int f, tmp, nusers = 0;
121          time_t diff;          time_t diff;
122          struct utmp utmp_str;          struct utmp utmp_str;
123          struct tm tm;          struct tm tm;
124          FILE *utmp_file;          FILE *utmp_file;
125    
126          if (!(utmp_file = (FILE *) fopen(_PATH_UTMP, "r")))          if (!(utmp_file = (FILE *) fopen(_PATH_UTMP, "r")))
# Line 128  d_users(void) Line 129  d_users(void)
129          (void) memset(buf, 0, sizeof buf);          (void) memset(buf, 0, sizeof buf);
130          (void) output("~WUsers logged on: ");          (void) output("~WUsers logged on: ");
131    
132          while (fread((char *) &utmp_str, sizeof(utmp_str), 1, utmp_file) == 1)          while (fread((char *) &utmp_str, sizeof(utmp_str), 1, utmp_file) == 1)
133          {          {
134                  if (*utmp_str.ut_name && *utmp_str.ut_line)  {          
135                          output("~w\n%s\ton %s", utmp_str.ut_name,          if (*utmp_str.ut_name && *utmp_str.ut_line)  {
                             utmp_str.ut_line);  
136    
137                          if (!*utmp_str.ut_host)         output("~w\n%s\ton %s", utmp_str.ut_name, utmp_str.ut_line);
138                                  output(" from (local) ");    
139                    if (!*utmp_str.ut_host)
140                    output(" from (local) ");
141                          else                          else
142                                  output(" from ~G%s~w ", utmp_str.ut_host);                          output(" from ~G%s~w ", utmp_str.ut_host);
143    
144                          tm = *localtime(&utmp_str.ut_time);                          tm = *localtime(&utmp_str.ut_time);
145                          (void) strftime(buf, sizeof buf, "%H:%M, %d/%m", &tm);                          (void) strftime(buf, sizeof buf, "%H:%M, %m/%d", &tm);
146                                                    
147                          diff = difftime(time(NULL), utmp_str.ut_time);                          diff = difftime(time(NULL), utmp_str.ut_time);
148                          tmp = (diff / SECSPERDAY);                          tmp = (diff / SECSPERDAY);
# Line 201  load_ks(double loads[], int howmany) Line 203  load_ks(double loads[], int howmany)
203                          tm = *localtime(&maxload_t);                          tm = *localtime(&maxload_t);
204                  }                  }
205    
206          (void) strftime(buff, sizeof buff, "%R, %d/%m", &tm);          (void) strftime(buff, sizeof buff, "%R, %m/%d", &tm);
207          output("~WMaximum Load: ~w%.2f on %s\n", maxload, buff);          output("~WMaximum Load: ~w%.2f on %s\n", maxload, buff);
208    
209          return;          return;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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