CpuStat.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_CpuStat_
18 #define HH_SENF_Utils_CpuStat_ 1
19 
20 // Custom includes
21 #include <list>
22 #include <senf/Utils/singleton.hh>
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 namespace senf {
27 
28  struct CpuStat
29  {
31  unsigned user;
32  unsigned system;
33  unsigned nice;
34  unsigned idle;
35  unsigned iowait;
36  unsigned irq;
37  unsigned softirq;
38  unsigned steal;
39  unsigned guest;
40 
42  unsigned user=0,
43  unsigned system=0,
44  unsigned nice=0,
45  unsigned idle=0,
46  unsigned iowait=0,
47  unsigned irq=0,
48  unsigned softirq=0,
49  unsigned steal=0,
50  unsigned guest=0);
51  };
52 
54  {
55  public:
56  CpuStat cpuStat();
57 
58  private:
59  typedef std::vector<boost::long_long_type> CpuStatProbs;
60  CpuStatProbs probs;
62  };
63 
64 
66  {
67  public:
69  void dump(std::ostream & os);
70 
71  private:
72  CpuStatProb procStats_;
73  };
74 
75  std::ostream & operator<<(std::ostream & os, CpuStat const & cs);
76 
77 }
78 
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
80 //#include "CpuStat.cci"
81 //#include "CpuStat.ct"
82 //#include "CpuStat.cti"
83 #endif
config::time_type clock_type
unsigned idle
Definition: CpuStat.hh:34
unsigned steal
Definition: CpuStat.hh:38
unsigned system
Definition: CpuStat.hh:32
static SENF_CLOCKSERVICE_CONSTEXPR clock_type milliseconds(int64_type const &v)
void dump(std::ostream &os, DirectoryNode &dir=root())
unsigned softirq
Definition: CpuStat.hh:37
std::ostream & operator<<(std::ostream &os, CpuStat const &cs)
Definition: CpuStat.cc:103
unsigned user
Definition: CpuStat.hh:31
singleton public header
unsigned iowait
Definition: CpuStat.hh:35
CpuStat(ClockService::clock_type duration=ClockService::milliseconds(0), unsigned user=0, unsigned system=0, unsigned nice=0, unsigned idle=0, unsigned iowait=0, unsigned irq=0, unsigned softirq=0, unsigned steal=0, unsigned guest=0)
Definition: CpuStat.cc:28
unsigned guest
Definition: CpuStat.hh:39
ClockService::clock_type duration
Definition: CpuStat.hh:30
unsigned irq
Definition: CpuStat.hh:36
unsigned nice
Definition: CpuStat.hh:33