Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / MemoryModel.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software 
11  * Foundation.  See file COPYING.
12  * 
13  */
14
15 #ifndef CEPH_MEMORYMODEL_H
16 #define CEPH_MEMORYMODEL_H
17
18 class CephContext;
19
20 class MemoryModel {
21 public:
22   struct snap {
23     long peak;
24     long size;
25     long hwm;
26     long rss;
27     long data;
28     long lib;
29     
30     long heap;
31
32     snap() : peak(0), size(0), hwm(0), rss(0), data(0), lib(0),
33              heap(0)
34     {}
35
36     long get_total() { return size; }
37     long get_rss() { return rss; }
38     long get_heap() { return heap; }
39   } last;
40
41 private:
42   CephContext *cct;
43   void _sample(snap *p);
44
45 public:
46   explicit MemoryModel(CephContext *cct);
47   void sample(snap *p = 0) {
48     _sample(&last);
49     if (p)
50       *p = last;
51   }
52 };
53
54 #endif