~ubuntu-branches/ubuntu/oneiric/sysstat/oneiric

« back to all changes in this revision

Viewing changes to sa_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2006-08-27 23:49:02 UTC
  • mto: (2.2.1 squeeze) (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20060827234902-3kzbeojeu685ecwr
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <fcntl.h>
30
30
#include <sys/types.h>
31
31
#include <sys/ioctl.h>
32
 
#include <sys/param.h>  /* for HZ */
33
32
 
34
33
#include "sa.h"
35
34
#include "common.h"
289
288
 
290
289
/*
291
290
 ***************************************************************************
 
291
 * Set current daily datafile
 
292
 ***************************************************************************
 
293
 */
 
294
void set_default_file(struct tm *loc_time, char *datafile)
 
295
{
 
296
   get_time(loc_time);
 
297
   snprintf(datafile, MAX_FILE_LEN,
 
298
            "%s/sa%02d", SA_DIR, loc_time->tm_mday);
 
299
   datafile[MAX_FILE_LEN - 1] = '\0';
 
300
}
 
301
 
 
302
 
 
303
/*
 
304
 ***************************************************************************
292
305
 * Set interval value.
293
306
 * g_itv is the interval in jiffies multiplied by the # of proc.
294
307
 * itv is the interval in jiffies.
331
344
 
332
345
/*
333
346
 ***************************************************************************
334
 
 * Print report header
 
347
 * Fill loc_time structure according to data saved in file header
335
348
 ***************************************************************************
336
349
 */
337
 
void print_report_hdr(unsigned short format, unsigned int flags,
338
 
                      struct tm *loc_time, struct file_hdr *file_hdr)
 
350
void set_hdr_loc_time(unsigned int flags, struct tm *loc_time,
 
351
                      struct file_hdr *file_hdr)
339
352
{
 
353
   struct tm *loc_t;
340
354
 
341
355
   if (PRINT_TRUE_TIME(flags)) {
342
356
      /* Get local time */
343
 
      get_localtime(loc_time);
 
357
      get_time(loc_time);
344
358
 
345
359
      loc_time->tm_mday = file_hdr->sa_day;
346
360
      loc_time->tm_mon  = file_hdr->sa_month;
352
366
      loc_time->tm_hour = loc_time->tm_min = loc_time->tm_sec = 0;
353
367
      mktime(loc_time);
354
368
   }
355
 
   else
356
 
      loc_time = localtime(&(file_hdr->sa_ust_time));
357
 
 
358
 
   if (!format)
359
 
      /* No output format (we are not using sadf) */
360
 
      print_gal_header(loc_time, file_hdr->sa_sysname, file_hdr->sa_release,
361
 
                       file_hdr->sa_nodename);
 
369
   else {
 
370
      loc_t = localtime(&(file_hdr->sa_ust_time));
 
371
      *loc_time = *loc_t;
 
372
   }
 
373
}
 
374
 
 
375
 
 
376
/*
 
377
 ***************************************************************************
 
378
 * Print report header
 
379
 ***************************************************************************
 
380
 */
 
381
void print_report_hdr(unsigned int flags, struct tm *loc_time,
 
382
                      struct file_hdr *file_hdr)
 
383
{
 
384
 
 
385
   set_hdr_loc_time(flags, loc_time, file_hdr);
 
386
 
 
387
   print_gal_header(loc_time, file_hdr->sa_sysname, file_hdr->sa_release,
 
388
                    file_hdr->sa_nodename);
362
389
}
363
390
 
364
391