***********************
** FILE NAME : message.cpp
** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.2 $
**
** DESCRIPTION : Implementation of the message handling classes
**
********************************
** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
** CREATION DATE : Sep 16, 2002
-** LAST UPDATE : Oct 05, 2002
+** LAST UPDATE : Nov 04, 2002
** MODIFICATIONS :
**************************************************************************/
/*****************************
$Log: message.cpp,v $
- Revision 1.1 2002-10-05 10:25:49 arjen
+ Revision 1.2 2002-11-04 10:13:36 arjen
+ Use proper namespace for iostream classes
+
+ Revision 1.1 2002/10/05 10:25:49 arjen
Creation of gcm_input and a first approach to a web interface
*****************************/
-static const char *RCSID = "$Id: message.cpp,v 1.1 2002-10-05 10:25:49 arjen Exp $";
+static const char *RCSID = "$Id: message.cpp,v 1.2 2002-11-04 10:13:36 arjen Exp $";
#include "message.h"
** VARS CHANGED :
** FUNCTIONS USED :
** SEE ALSO :
-** LAST MODIFIED : Sep 30, 2002
+** LAST MODIFIED : Nov 04, 2002
**=========================================================================
*/
{
String l;
- //cout << " buffer is depleted.\n";
if (*(b.input) >> l)
{
b.buffer.push_back(l);
s = l;
input_ok = true;
- //cout << " new line from input.\n";
}
}
else
{
- //cout << " reading from cache.\n";
s = *(b.next_line);
b.next_line++;
input_ok = true;
return input_ok;
}
-client_message::client_message(istream *in, gnucomo_database db)
+client_message::client_message(std::istream *in, gnucomo_database db)
{
input.from(in);
database = db;
** VARS CHANGED :
** FUNCTIONS USED :
** SEE ALSO :
-** LAST MODIFIED : Oct 05, 2002
+** LAST MODIFIED : Nov 04, 2002
**=========================================================================
*/
while (input >> line && certainty < 0.9)
{
- cout << " testing: " << line << "\n";
+ std::cout << " testing: " << line << "\n";
if (line == re_syslog)
{
certainty = 1.0;
classification = SYSLOG;
if (verbose)
{
- cout << "Syslog detected.\n";
+ std::cout << "Syslog detected.\n";
}
}
else if (line == re_PGP)
{
certainty = 1.0;
gpg_encrypted = true;
- cerr << "The message is PGP/GnuPG encrypted.\n";
+ std::cerr << "The message is PGP/GnuPG encrypted.\n";
}
else if (line == re_dump)
{
certainty = 1.0;
if (verbose)
{
- cout << "DUMP output detected.\n";
+ std::cout << "DUMP output detected.\n";
}
}
else if (line == re_accesslog)
service = "httpd";
if (verbose)
{
- cout << "HTTP access log detected.\n";
+ std::cout << "HTTP access log detected.\n";
}
}
else if (line == re_errorlog)
service = "httpd";
if (verbose)
{
- cout << "HTTP error log detected.\n";
+ std::cout << "HTTP error log detected.\n";
}
}
}
if (hostname == "")
{
- cerr << "Can not determine the hostname where the message came from.\n";
+ std::cerr << "Can not determine the hostname where the message came from.\n";
certainty = 0.0;
}
else if (!arrival.proper())
{
- cerr << "Arrival time is not knwon.\n";
+ std::cerr << "Arrival time is not knwon.\n";
certainty = 0.0;
}
else
** VARS CHANGED :
** FUNCTIONS USED :
** SEE ALSO :
-** LAST MODIFIED : Oct 05, 2002
+** LAST MODIFIED : Nov 04, 2002
**=========================================================================
*/
objectid = database.find_host(hostname);
if (objectid == "")
{
- cerr << "Please define the host " << hostname << " in the database.\n";
+ std::cerr << "Please define the host " << hostname << " in the database.\n";
return 0;
}
if (verbose)
{
- cout << "Object id for " << hostname << " is " << objectid << "\n";
+ std::cout << "Object id for " << hostname << " is " << objectid << "\n";
}
/* Scan the input line by line, entring records into the database */
{
if (verbose)
{
- cout << line << "\n";
+ std::cout << line << "\n";
}
if (verbose)
{
- cout << " Log timestamp = " << log_date << " " << log_time << "\n";
+ std::cout << " Log timestamp = " << log_date << " " << log_time << "\n";
}
rest = line << 16;
i = rest.index(' ');
rest <<= i + 1;
if (verbose)
{
- cout << " Hostname matches.\n";
- cout << " rest = " << rest << "\n";
+ std::cout << " Hostname matches.\n";
+ std::cout << " rest = " << rest << "\n";
}
for (i = 0; isalpha(rest[i]) && i < ~rest; i++);
if (verbose)
{
- cout << " Service name = " << rest(0,i) << "\n";
+ std::cout << " Service name = " << rest(0,i) << "\n";
}
/* Insert a new record into the log table */
if (testmode)
{
- cout << insertion << "\n";
+ std::cout << insertion << "\n";
}
else
{
if (verbose)
{
- cout << "\n\n";
+ std::cout << "\n\n";
}
nr_lines++;
}
else
{
- cerr << " Hostname " << rest(0,i) << " does not match.\n";
+ std::cerr << " Hostname " << rest(0,i) << " does not match.\n";
}
break;
log_time = datestring;
if (verbose)
{
- cout << " Log timestamp = " << log_date << " " << log_time << "\n";
+ std::cout << " Log timestamp = " << log_date << " " << log_time << "\n";
}
insertion += "'" + objectid + "',";
insertion += "'" + service + "',";
if (testmode)
{
- cout << insertion << "\n";
+ std::cout << insertion << "\n";
}
else
{
if (verbose)
{
- cout << "\n\n";
+ std::cout << "\n\n";
}
nr_lines++;
log_time = datestring;
if (verbose)
{
- cout << " Log timestamp = " << log_date << " " << log_time << "\n";
+ std::cout << " Log timestamp = " << log_date << " " << log_time << "\n";
}
insertion += "'" + objectid + "',";
insertion += "'" + service + "',";
if (testmode)
{
- cout << insertion << "\n";
+ std::cout << insertion << "\n";
}
else
{
if (verbose)
{
- cout << "\n\n";
+ std::cout << "\n\n";
}
nr_lines++;
}
else
{
- cerr << "gcm_input WARNING: Not a valid line: " << line << "\n";
+ std::cerr << "gcm_input WARNING: Not a valid line: " << line << "\n";
}
}
if (verbose)
{
- cout << nr_lines << " lines parsed from the log file.\n";
+ std::cout << nr_lines << " lines parsed from the log file.\n";
}
return nr_lines;
}