***********************
** FILE NAME : gcm_input.cpp
** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
-** VERSION NUMBER : $Revision: 1.3 $
+** VERSION NUMBER : $Revision: 1.4 $
**
** DESCRIPTION : Application to store client messages into the database
** The client message contains a log file from one of the
********************************
** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
** CREATION DATE : Aug 29, 2002
-** LAST UPDATE : Nov 04, 2002
+** LAST UPDATE : Mar 28, 2003
** MODIFICATIONS :
**************************************************************************/
/*****************************
$Log: gcm_input.cpp,v $
- Revision 1.3 2002-11-09 08:04:27 arjen
+ Revision 1.4 2003-03-29 08:42:00 arjen
+ Exit without reading any input if the database connection fails.
+
+ Revision 1.3 2002/11/09 08:04:27 arjen
Added a reference to the GPL
Revision 1.2 2002/11/04 10:13:36 arjen
*****************************/
-static const char *RCSID = "$Id: gcm_input.cpp,v 1.3 2002-11-09 08:04:27 arjen Exp $";
+static const char *RCSID = "$Id: gcm_input.cpp,v 1.4 2003-03-29 08:42:00 arjen Exp $";
#include <getopt.h>
** VARS CHANGED :
** FUNCTIONS USED :
** SEE ALSO :
-** LAST MODIFIED : Sep 30, 2002
+** LAST MODIFIED : Mar 28, 2003
**=========================================================================
*/
String hostname(""), service("");
int option;
-
+
while ((option = getopt(argc, argv, "c:h:d:s:TvV")) != -1)
{
switch (option)
exit(1);
}
}
-
if (verbose)
{
std::cout << "Hostname = " << hostname;
gnucomo_database db(&cfg);
- client_message msg(&std::cin, db);
+ if (db.is_connected())
+ {
+
+ client_message msg(&std::cin, db);
- if (msg.classify(hostname, arrival, service) > 0.9)
+ if (msg.classify(hostname, arrival, service) > 0.9)
+ {
+ msg.enter();
+ }
+ return 0;
+ }
+ else
{
- msg.enter();
+ std::cerr << "gcm_input: Can not connect to database.\n";
+ return 1;
}
-
- return 0;
}