pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
pmm_load.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2010 Robert Higgins
3  Author: Robert Higgins <robert.higgins@ucd.ie>
4 
5  This file is part of PMM.
6 
7  PMM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  PMM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with PMM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 /*!
21  * @file pmm_load.h
22  * @brief Load data structures
23  *
24  * Data structures representing the load and load history of a system
25  *
26  */
27 
28 #ifndef PMM_LOAD_H_
29 #define PMM_LOAD_H_
30 
31 #if HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34 
35 #include <pthread.h> // for pthread_rwlock_t
36 
37 /*!
38  * this is a circular array of load history, size determined at run time
39  */
40 typedef struct pmm_loadhistory {
41  int write_period; /*!< how often to write load history to disk */
42 
43  struct pmm_load *history; /*!< pointer to the circular array */
44  int size; /*!< size of circular array */
45  int size_mod;
46 
47  struct pmm_load *start; /*!< pointer to starting element of c.array */
48  struct pmm_load *end; /*!< pointer to ending element of c.array */
49  int start_i; /*!< ending element of the circular array */
50  int end_i; /*!< starting element in the circular array */
51 
52  char *load_path; /*!< path to load history file */
53 
54  pthread_rwlock_t history_rwlock; /*!< mutex for accessing history */
56 
57 /*!
58  * this is a record of system load
59  */
60 typedef struct pmm_load {
61  time_t time; /*!< time at which load was recorded */
62  double load[3]; /*!< 1, 5 & 15 minute load averages TODO use float? */
63 } PMM_Load;
64 
65 
66 struct pmm_load* new_load();
68 int init_loadhistory(struct pmm_loadhistory *h, int size);
69 void add_load(struct pmm_loadhistory *h, struct pmm_load *l);
70 int check_loadhistory(struct pmm_loadhistory *h);
71 void print_loadhistory(const char *output, struct pmm_loadhistory *h);
72 void print_load(const char *output, struct pmm_load *l);
73 
74 
75 #endif /*PMM_LOAD_H_*/
76