| 64 |
|
if ( debug == 1 ){ |
| 65 |
|
std::cout << "Using Default Tolerance\n"; |
| 66 |
|
} // if |
| 67 |
< |
MaxFilterRetrys = 5; |
| 67 |
> |
MaxFilterRetrys = 1; |
| 68 |
|
} // if |
| 69 |
|
|
| 70 |
|
|
| 71 |
< |
std::cout << "Configuring Alerter\n"; |
| 71 |
> |
// std::cout << "Configuring Alerter\n"; |
| 72 |
|
// Set the values at which the Alerter should kick in. and how many packets it should |
| 73 |
|
// send |
| 74 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
localTime = time(NULL); |
| 137 |
– |
// std::cout << "."; |
| 137 |
|
// keep going while no non-fatal errors have occurred |
| 138 |
|
int waitTime = 0; |
| 139 |
|
|
| 140 |
|
if ( nextTCPTime <= nextAveragerTime ){ |
| 142 |
– |
// std::cout << "-"; |
| 141 |
|
if ( nextTCPTime >= nextUDPTime ){ |
| 144 |
– |
// std::cout << "}"; |
| 142 |
|
nextAction = 3; |
| 143 |
|
waitTime = nextUDPTime - localTime; |
| 144 |
|
} else { |
| 145 |
|
// set the heartbeat to be the next item |
| 149 |
– |
// std::cout << "{"; |
| 146 |
|
nextAction = 1; |
| 147 |
|
waitTime = nextTCPTime - localTime; |
| 148 |
|
} // if |
| 149 |
|
} else { |
| 154 |
– |
// std::cout << "+"; |
| 150 |
|
if ( nextAveragerTime >= nextUDPTime ){ |
| 156 |
– |
// std::cout << "["; |
| 151 |
|
nextAction = 3; |
| 152 |
|
waitTime = nextUDPTime - localTime; |
| 153 |
|
} else { |
| 154 |
|
// set grabstats to be in the next action |
| 161 |
– |
// std::cout << "]"; |
| 155 |
|
nextAction = 2; |
| 156 |
|
waitTime = nextAveragerTime - localTime; |
| 157 |
|
} // if |
| 159 |
|
|
| 160 |
|
// sleep until this time only if it is greater than 1! |
| 161 |
|
if ( waitTime >= 1 ){ |
| 162 |
< |
sleep(waitTime); /// crashes here |
| 162 |
> |
sleep(waitTime); |
| 163 |
|
|
| 164 |
|
} |
| 165 |
|
|
| 195 |
|
|
| 196 |
|
break; |
| 197 |
|
case 2: nextAveragerTime = localTime + AveragerUpdateTime; |
| 198 |
+ |
/* |
| 199 |
|
if ( sysMon.collect() > 0 ){ |
| 200 |
|
// suggests that there should be an alert |
| 201 |
|
std::cout << "Alert Status" << endl; |
| 202 |
< |
} |
| 202 |
> |
}*/ |
| 203 |
|
break; |
| 204 |
|
default: std::cout << "Scheduled UDP Connection" << endl; |
| 205 |
+ |
sysMon.collect(); |
| 206 |
|
nextUDPTime = localTime + UDPUpdateTime; |
| 207 |
|
// package up the system data |
| 208 |
< |
string host = (config.getSmallNet())->getHostName(); |
| 209 |
< |
string ip = (config.getSmallNet())->getHostIP(); |
| 208 |
> |
string host = config.getFQDN(); |
| 209 |
> |
// string ip = (config.getSmallNet())->getHostIP(); |
| 210 |
|
|
| 211 |
|
string seq = ""; |
| 212 |
|
// char * buffer; |
| 216 |
|
string date = ""; |
| 217 |
|
sprintf(buffer,"%u", localTime); |
| 218 |
|
date = buffer; |
| 219 |
< |
string attributes = "type=\"data\" machine_name=\""+host+"\" ip=\""+ip+"\" date=\""+date+"\" seq_no=\""+seq+"\""; |
| 219 |
> |
string attributes = "type=\"data\" machine_name=\""+host+"\" ip=\"0.0.0.0\" date=\""+date+"\" seq_no=\""+seq+"\""; |
| 220 |
|
|
| 221 |
|
XMLFormatter xml("packet",attributes); |
| 222 |
|
// put in the data |
| 223 |
|
xml.addString(sysMon.getData()); |
| 224 |
|
(config.getSmallNet())->sendUPDPacket(config.getUDPFilterName(), config.getUDPFilterPort(), xml.returnXML()); |
| 225 |
+ |
// now clear the averaged data |
| 226 |
+ |
sysMon.clearData(); |
| 227 |
|
sequence++; |
| 228 |
|
break; |
| 229 |
|
} // switch |