Commit 78297af6 authored by André Machado's avatar André Machado
Browse files

Merge branch 'development' into issue/103

parents c0ce294f c8cd8c57
Pipeline #10837 passed with stages
in 20 minutes and 3 seconds
......@@ -35,7 +35,7 @@ compile:
- make
- cd ..
- chmod +x generate_agent.sh
- ./generate_agent.sh -idp=1234 -ws=www.C3Sl.ufpr.br -pch=mumm -pcp=6666 -pcu=ninguem -pcpasswd=123mudar
- ./generate_agent.sh -idp=1234 -ws=www.C3Sl.ufpr.br -pch=mumm -pcp=6666 -pcu=ninguem -pcpasswd=123mudar -prj=simmc
- chmod +x agent-1234.run
testDebian:
......
{
"idPoint" : "%d",
"proxyConf" : "%s",
"webService": "%s",
"version": "%s"
"idPoint" : "%d",
"proxyConf" : "%s",
"webService": "%s",
"version": "%s",
"project" : "%s"
}
......@@ -30,6 +30,7 @@ port=""
usr=""
passwd=""
destination="./"
project="simmc"
dir=$(dirname $0)
cd $dir
......@@ -76,6 +77,10 @@ for i in $@; do
version="${i#*=}"
shift
;;
-prj=*)
project="${i#*=}"
shift
;;
*)
echo "wrong usage\ntry -h or --help for help"
exit 1
......@@ -96,7 +101,7 @@ tmp=$(cat ../../../conf/proxy-conf.json)
printf "$tmp\n" $host $port $usr $passwd > proxy.json
tmp=$(cat ../../../conf/datasid-conf.json)
printf "$tmp\n" $idPoint /opt/agentC3SL/conf/proxy.json $webService $version > datasid-conf.json
printf "$tmp\n" $idPoint /opt/agentC3SL/conf/proxy.json $webService $version $project > datasid-conf.json
cd ../../..
......
......@@ -20,6 +20,7 @@
*/
#include <agent/main.h>
#include <string>
#include <iostream>
#ifdef __linux__
std::string path_to_agent_tmp = // NOLINT(runtime/string)
......@@ -35,18 +36,27 @@
"./opt/agentC3SL/conf/"; // NOLINT(runtime/string)
#endif
bool agent_send_inventory = false;
bool agent_send_net_band = false;
bool agent_send_user_hist = false;
bool agent_send_database = false;
/** Run agent */
int run_agent(const sys::error_code& /*e*/, pt::ptime begin, bool print ) {
pt::ptime now;
now = pt::second_clock::local_time();
pt::time_duration t3 = now - begin;
if ((t3.minutes() % 5 == 0 )) {
if (agent_send_net_band && (t3.minutes() % 5 == 0 )) {
send_net_bandwidth(print);
}
if ((t3.hours() % 24 == 0) && (t3.minutes() %60 == 0 )) {
check_update();
send_inventory(print);
send_user_history(print);
if (agent_send_inventory) {
send_inventory(print);
}
if (agent_send_user_hist) {
send_user_history(print);
}
}
return(0);
}
......@@ -69,10 +79,18 @@ int set_begin(pt::ptime& begin, bool print) { // NOLINT (runtime/reference)
myfile << "\n";
check_update();
send_inventory(print);
send_net_bandwidth(print);
send_user_history(print);
if (agent_send_inventory) {
send_inventory(print);
}
if (agent_send_net_band) {
send_net_bandwidth(print);
}
if (agent_send_user_hist) {
send_user_history(print);
}
if (agent_send_database) {
// get database for PInSIS
}
myfile.close();
return(0);
} else {
......@@ -84,6 +102,34 @@ int set_begin(pt::ptime& begin, bool print) { // NOLINT (runtime/reference)
}
}
/** Configurate the agent
* if the agent is added to more projects, this function may be edited
*/
void config_agent() {
Json::Reader reader;
Json::Value conf;
std::ifstream agent_conf;
agent_conf.open(path_to_agent_conf + "datasid-conf.json",
std::ifstream::binary);
if (agent_conf.fail()) {
/* Nao conseguiu abrir o arquivo de configuracao.
Provavelmente está é um teste de desenvolvedor.
Assumindo que o projeto é o simmc.
*/
agent_send_inventory = true;
agent_send_net_band = true;
agent_send_user_hist = true;
}
reader.parse(agent_conf, conf, false);
if (conf["project"].compare("simmc") == 0) {
agent_send_inventory = true;
agent_send_net_band = true;
agent_send_user_hist = true;
} else if (conf["project"].compare("pinsis") == 0) {
agent_send_database = true;
}
}
/** Parse command line
* - Options:
* - Help - help message
......@@ -137,16 +183,26 @@ int main(int argc, char* argv[]) {
int increment = 0;
int lim = 1;
bool print;
pt::ptime begin;
if (parse_command_line(argc, argv, &increment, &lim, &print)) {
return (1);
}
pt::ptime begin;
config_agent();
if (set_begin(begin, print) && lim == 0) {
check_update();
send_inventory(print);
send_net_bandwidth(print);
send_user_history(print);
if (agent_send_inventory) {
send_inventory(print);
}
if (agent_send_net_band) {
send_net_bandwidth(print);
}
if (agent_send_user_hist) {
send_user_history(print);
}
if (agent_send_database) {
// get database for PInSIS
}
return (0);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment