--- projects/cms/source/host/c++/Host.cpp 2001/03/06 00:40:28 1.3 +++ projects/cms/source/host/c++/Host.cpp 2002/05/21 16:47:11 1.7 @@ -1,3 +1,23 @@ +/* + * i-scream central monitoring system + * http://www.i-scream.org.uk + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + #include #include // linux header for the sleep function #include // itoa() @@ -64,11 +84,11 @@ int main(){ if ( debug == 1 ){ std::cout << "Using Default Tolerance\n"; } // if - MaxFilterRetrys = 5; + MaxFilterRetrys = 1; } // if - std::cout << "Configuring Alerter\n"; + // std::cout << "Configuring Alerter\n"; // Set the values at which the Alerter should kick in. and how many packets it should // send @@ -134,31 +154,24 @@ int main(){ localTime = time(NULL); - // std::cout << "."; // keep going while no non-fatal errors have occurred int waitTime = 0; if ( nextTCPTime <= nextAveragerTime ){ - // std::cout << "-"; if ( nextTCPTime >= nextUDPTime ){ - // std::cout << "}"; nextAction = 3; waitTime = nextUDPTime - localTime; } else { // set the heartbeat to be the next item - // std::cout << "{"; nextAction = 1; waitTime = nextTCPTime - localTime; } // if } else { - // std::cout << "+"; if ( nextAveragerTime >= nextUDPTime ){ - // std::cout << "["; nextAction = 3; waitTime = nextUDPTime - localTime; } else { // set grabstats to be in the next action - // std::cout << "]"; nextAction = 2; waitTime = nextAveragerTime - localTime; } // if @@ -166,7 +179,7 @@ int main(){ // sleep until this time only if it is greater than 1! if ( waitTime >= 1 ){ - sleep(waitTime); /// crashes here + sleep(waitTime); } @@ -202,16 +215,18 @@ int main(){ break; case 2: nextAveragerTime = localTime + AveragerUpdateTime; + /* if ( sysMon.collect() > 0 ){ // suggests that there should be an alert std::cout << "Alert Status" << endl; - } + }*/ break; default: std::cout << "Scheduled UDP Connection" << endl; + sysMon.collect(); nextUDPTime = localTime + UDPUpdateTime; // package up the system data - string host = (config.getSmallNet())->getHostName(); - string ip = (config.getSmallNet())->getHostIP(); + string host = config.getFQDN(); + // string ip = (config.getSmallNet())->getHostIP(); string seq = ""; // char * buffer; @@ -221,12 +236,14 @@ int main(){ string date = ""; sprintf(buffer,"%u", localTime); date = buffer; - string attributes = "type=\"data\" machine_name=\""+host+"\" ip=\""+ip+"\" date=\""+date+"\" seq_no=\""+seq+"\""; + string attributes = "type=\"data\" machine_name=\""+host+"\" ip=\"0.0.0.0\" date=\""+date+"\" seq_no=\""+seq+"\""; XMLFormatter xml("packet",attributes); // put in the data xml.addString(sysMon.getData()); (config.getSmallNet())->sendUPDPacket(config.getUDPFilterName(), config.getUDPFilterPort(), xml.returnXML()); + // now clear the averaged data + sysMon.clearData(); sequence++; break; } // switch