ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/Host.cpp
(Generate patch)

Comparing projects/cms/source/host/c++/Host.cpp (file contents):
Revision 1.2 by ab11, Mon Mar 5 12:40:32 2001 UTC vs.
Revision 1.5 by ab11, Tue Mar 27 00:05:47 2001 UTC

# Line 64 | Line 64 | int main(){
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          
# Line 76 | Line 76 | int main(){
76          
77          std::cout << "Starting Data Collection\n";
78          // work out which is closer, the next heartbeat or the next data collection
79 <        long localTime = time(NULL);
79 >        int localTime = time(NULL);
80          // std::cout << "#";
81          int nextUDPTime = localTime + UDPUpdateTime;
82          int nextAveragerTime = localTime + AveragerUpdateTime;
83          int nextTCPTime = localTime + TCPUpdateTime;
84 <        long sequence = 0;
84 >        int sequence = 0;
85                  
86          int nextAction = 0;
87          while ( noErrors == 1){
# Line 127 | Line 127 | int main(){
127                                  } // if
128                                  MaxFilterRetrys = 5;
129                          } // if
130 <                        
130 >                        // reloadConfig is done now
131 >                        reloadConfig = 0;
132                  } // if reloadconfig
133                  
134                  
135 +                
136                  localTime = time(NULL);
135                //  std::cout << ".";
137                  // keep going while no non-fatal errors have occurred
138                  int waitTime = 0;
139                  
140                  if ( nextTCPTime  <= nextAveragerTime ){
140                        // std::cout << "-";
141                          if ( nextTCPTime >= nextUDPTime ){
142                                // std::cout << "}";
142                                  nextAction = 3;
143                                  waitTime = nextUDPTime - localTime;
144                          } else {
145                                  // set the heartbeat to be the next item
147                                // std::cout << "{";
146                                  nextAction = 1;
147                                  waitTime = nextTCPTime - localTime;
148                          } // if
149                  } else {
152                        // std::cout << "+";
150                          if ( nextAveragerTime >=  nextUDPTime ){
154                                // std::cout << "[";
151                                  nextAction = 3;
152                                  waitTime = nextUDPTime - localTime;
153                          } else {
154                                  // set grabstats to be in the next action
159                                // std::cout << "]";
155                                  nextAction = 2;
156                                  waitTime = nextAveragerTime - localTime;
157                          } // if
# Line 164 | Line 159 | int main(){
159                  
160                  // sleep until this time only if it is greater than 1!
161                  if ( waitTime >= 1 ){
162 <                        // need to output \n to std::cout or the wait is infinate!!!! ?????
168 <                        // will core dump if debug = 0
169 <                        sleep(waitTime); /// crashes here
162 >                        sleep(waitTime);
163                          
164                  }
165                  
# Line 202 | Line 195 | int main(){
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 <                                 char * buffer;
212 <                                 buffer = l64a( sequence );
213 <                                 char * seq = buffer;
214 <                                 buffer = l64a( localTime );
215 <                                 char * date = buffer;
216 <                                
217 <                                                                                                
218 <                                 string attributes = "type=\"data\" machine_name=\""+host+"\" ip=\""+ip+"\" date=\""+date+"\" seq_no=\""+seq+"\"";
211 >                                 string seq = "";
212 >                                 // char * buffer;
213 >                                 char buffer[32];
214 >                                 sprintf(buffer,"%u", sequence);
215 >                                 seq = buffer;
216 >                                 string date = "";
217 >                                 sprintf(buffer,"%u", localTime);
218 >                                 date = buffer;
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 <                                
225 >                                 // now clear the averaged data
226 >                                 sysMon.clearData();
227 >                                 sequence++;
228                                   break;
229                  } // switch
230                  
# Line 240 | Line 238 | int main(){
238          
239          return 0;
240          
241 < } // main
241 > } // main

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines