summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Machine_Properties.h
blob: 99c6079a4193881779f93225a0240be419a0a60b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* -*- C++ -*- */

// ============================================================================
// $Id$
//
// = FILENAME
//    Machine_Properties.h
//
// = DESCRIPTION
//    As a trading service dynamic property, retrieves machine
//    statistics from the rstatd using Sun RPC.
//
// = AUTHORS
//    Seth Widoff <sbw1@cs.wustl.edu>
//
// ============================================================================

#if (! defined TAO_MACHINE_PROPERTIES)
#define TAO_MACHINE_PROPERTIES

#include "orbsvcs/Trader/Trader_Utils.h"
#include "Property_Exporter.h"

//RPC related includes
#include <rpc/rpc.h>
#include <rpcsvc/rstat.h>

class TAO_Machine_Properties :
  public TAO_Dynamic_Property,
  public TAO_Exportable
{
public:

  enum PROP_TYPES
  {
    CPU,
    DISK,
    PAGES,
    SWAPS,
    PACKETS,
    ERRORS,
    CONTEXT_SWITCHES,
    COLLISIONS,
    INTERRUPTS,
    LOAD
  };

  static const int NUM_PROPERTIES;
  static const char* PROP_NAMES[];

  TAO_Machine_Properties (void);

  TAO_Machine_Properties (const ACE_Time_Value& timeout);

  virtual CORBA::Any* evalDP (const char* name,
                              CORBA::TypeCode_ptr returned_type,
                              const CORBA::Any& extra_info,
                              CORBA::Environment& _env)
    TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure));
  // Return the value of a machine performance property whose name is
  // contained in <extra_info>, which in essence is another
  // demultiplexing key.

  virtual void export_properties (TAO_Property_Exporter& prop_exporter);

  virtual int define_properties
    (CosTradingRepos::ServiceTypeRepository::PropStructSeq& prop_seq,
     CORBA::ULong offset = 0) const;

private:

  void init (void);

  int retrieve_stats (void);

  void compute_cpu (CORBA::Any& value, int elapsed_time);
  void compute_disk (CORBA::Any& value, int elapsed_time);
  void compute_pages (CORBA::Any& value, int elapsed_time);
  void compute_swaps (CORBA::Any& value, int elapsed_time);
  void compute_packets (CORBA::Any& value, int elapsed_time);
  void compute_errors (CORBA::Any& value, int elapsed_time);
  void compute_context (CORBA::Any& value, int elapsed_time);
  void compute_collisions (CORBA::Any& value, int elapsed_time);
  void compute_interrupts (CORBA::Any& value, int elapsed_time);
  void compute_load (CORBA::Any& value, int elapsed_time);

  const ACE_Time_Value timeout_;
  ACE_Time_Value timestamp_;
  ACE_Time_Value sample_time_;

  statstime stats_;
  statstime old_stats_;
  CLIENT* rstat_client_;

};

#endif /* TAO_MACHINE_PROPERTIES */