COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
agent_cpu_device_test.cpp File Reference
#include "support/configCosmos.h"
#include "support/elapsedtime.h"
#include "support/timeutils.h"
#include "agent/agentclass.h"
#include <iostream>
#include <string>
Include dependency graph for agent_cpu_device_test.cpp:

Macros

#define MAXBUFFERSIZE   256
 

Functions

int myagent ()
 
int32_t request_start (string &request, string &response_r, Agent *agent)
 
int main (int argc, char *argv[])
 

Variables

string agentname = "agent_cpu_device_test"
 
string nodename = "computer"
 
int waitsec = 5
 
int loopmsec = 1
 
char buf4 [512]
 
beatstruc beat_agent_cpu
 
Agentagent
 
ElapsedTime et
 

Macro Definition Documentation

#define MAXBUFFERSIZE   256

Function Documentation

int myagent ( )
81 {
82  cout << "agent " << agentname << " ...online " << endl;
83  string response;
84  int count = 1;
85 
86  // Start executing the agent
87  while(agent->running())
88  {
89  cout << "-------------------" << endl;
90  cout << "Cycle: \t\t\t\t" << count << endl;
91 
92 
94  "mem",
95  response,
96  2);
97  cout << "Memory used in KB: \t\t" << response << endl;
98 
100  "disk",
101  response,
102  2);
103  cout << "Disk used in KB: \t\t" << response << endl;
104 
105 
107  "load",
108  response,
109  2);
110  cout << "Load data in %: \t\t" << response << endl;
111 
112  count++;
113  COSMOS_SLEEP(2.00);
114 
115  }
116  return (0);
117 
118 }
int32_t send_request(beatstruc cbeat, string request, string &output, float waitsec=5.)
Send a request over AGENT.
Definition: agentclass.cpp:424
int count
Definition: rw_test.cpp:36
string agentname
Definition: agent_cpu_device_test.cpp:42
Agent * agent
Definition: agent_cpu_device_test.cpp:50
uint16_t running()
Check if we&#39;re supposed to be running.
Definition: agentclass.cpp:391
beatstruc beat_agent_cpu
Definition: agent_cpu_device_test.cpp:49
int32_t request_start ( string &  request,
string &  response_r,
Agent agent 
)
int main ( int  argc,
char *  argv[] 
)
56 {
57  int32_t iretn;
58  cout << "Starting agent CPU Device Test" << endl;
59 
60  // Establish the command channel and heartbeat
61  agent = new Agent(nodename, agentname);
62  if ((iretn = agent->wait()) < 0)
63  {
64  fprintf(agent->get_debug_fd(), "%16.10f %s Failed to start Agent %s on Node %s Dated %s : %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str(), cosmos_error_string(iretn).c_str());
65  exit(iretn);
66  }
67  else
68  {
69  fprintf(agent->get_debug_fd(), "%16.10f %s Started Agent %s on Node %s Dated %s\n",currentmjd(), mjd2iso8601(currentmjd()).c_str(), agent->getAgent().c_str(), agent->getNode().c_str(), utc2iso8601(data_ctime(argv[0])).c_str());
70  }
71 
72  beat_agent_cpu = agent->find_agent(nodename, "agent_cpu", 10.);
73 
74  // Start our own thread
75  myagent();
76 
77  return 0;
78 }
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
int iretn
Definition: rw_test.cpp:37
string agentname
Definition: agent_cpu_device_test.cpp:42
int32_t wait(State state=State::RUN, double waitsec=10.)
Definition: agentclass.cpp:398
Agent * agent
Definition: agent_cpu_device_test.cpp:50
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
string nodename
Definition: agent_cpu_device_test.cpp:43
string getAgent()
Definition: agentclass.cpp:2609
Definition: agentclass.h:139
double data_ctime(string path)
Definition: datalib.cpp:1910
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
beatstruc beat_agent_cpu
Definition: agent_cpu_device_test.cpp:49
int myagent()
Definition: agent_cpu_device_test.cpp:80
string utc2iso8601(double utc)
ISO 8601 version of time.
Definition: timelib.cpp:1286
beatstruc find_agent(string node, string agent, double waitsec=0.)
Find agent.
Definition: agentclass.cpp:559
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316

Variable Documentation

string agentname = "agent_cpu_device_test"
string nodename = "computer"
int waitsec = 5
int loopmsec = 1
char buf4[512]
beatstruc beat_agent_cpu
Agent* agent