[svn-commits] r140 - branches/advisor/src/back/scf/scm
thial01 at ingres.com
thial01 at ingres.com
Thu Jul 3 08:22:02 PDT 2008
Author: thial01
Date: 2008-07-03 08:22:01 -0700 (Thu, 03 Jul 2008)
New Revision: 140
Added:
branches/advisor/src/back/scf/scm/scmonitor.sc
Modified:
branches/advisor/src/back/scf/scm/Jamfile
branches/advisor/src/back/scf/scm/scmmain.c
Log:
Starting work on the monitor daemon - see #174
Modified: branches/advisor/src/back/scf/scm/Jamfile
===================================================================
--- branches/advisor/src/back/scf/scm/Jamfile 2008-07-03 12:18:43 UTC (rev 139)
+++ branches/advisor/src/back/scf/scm/Jamfile 2008-07-03 15:22:01 UTC (rev 140)
@@ -6,6 +6,9 @@
IISUBSYS back scf scm ;
+IIBINEXE monitordb : scmonitor.sc ;
+IINEEDLIBS monitordb : SCFLIB SHEMBEDLIB SHCOMPATLIB SHFRAMELIB ;
+IINEEDLIBSW monitordb : SHCUFLIB SHADFLIB ;
IILIBRARY SCFLIB : scmima.c scmmain.c ;
Modified: branches/advisor/src/back/scf/scm/scmmain.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmmain.c 2008-07-03 12:18:43 UTC (rev 139)
+++ branches/advisor/src/back/scf/scm/scmmain.c 2008-07-03 15:22:01 UTC (rev 140)
@@ -67,7 +67,14 @@
** scm_get_cur_stmt - returns the current statement
** scm_log_stmt - log a statement
** scm_log_opf_time - log the time in OPF
-** scm_log_qef_time - log the time in QEF
+** scm_log_qef_time - log the time in QEF
+** scm_log_stm_cost - log several statement cost values
+** scm_log_reference - log a reference
+** scm_log_table - log a table
+** scm_log_table_cost - log table cost values
+** scm_log_attribute - log an attribute
+** scm_log_index - log an index
+** scm_log_index_used - log if the index was used in the QEP
**
** History:
**
Added: branches/advisor/src/back/scf/scm/scmonitor.sc
===================================================================
--- branches/advisor/src/back/scf/scm/scmonitor.sc (rev 0)
+++ branches/advisor/src/back/scf/scm/scmonitor.sc 2008-07-03 15:22:01 UTC (rev 140)
@@ -0,0 +1,270 @@
+/*
+** Copyright (c) 2008 Ingres Corporation
+**
+*/
+
+#include <compat.h>
+#include <gl.h>
+
+#include <cv.h>
+#include <er.h>
+#include <ex.h>
+#include <cs.h>
+#include <me.h>
+#include <sp.h>
+#include <mo.h>
+#include <pc.h>
+#include <tm.h>
+#include <tr.h>
+#include <st.h>
+
+#include <sl.h>
+#include <iicommon.h>
+#include <dbdbms.h>
+
+#include <adf.h>
+#include <dmf.h>
+#include <ulf.h>
+#include <ulm.h>
+#include <qsf.h>
+#include <scf.h>
+#include <gca.h>
+#include <duf.h>
+
+#include <ddb.h>
+#include <qefrcb.h>
+#include <psfparse.h>
+
+#include <dudbms.h>
+#include <dmccb.h>
+#include <dmrcb.h>
+#include <copy.h>
+#include <qefqeu.h>
+#include <qefcopy.h>
+
+#include <sc.h>
+#include <scserver.h>
+#include <scc.h>
+#include <scs.h>
+#include <scd.h>
+
+#include <sc0m.h>
+#include <sce.h>
+#include <scfcontrol.h>
+
+EXEC SQL include SQLCA;
+
+/**
+**
+** Name: SCMONITOR.SC - the monitor daemon for the design analyzer
+**
+** Description:
+** This file contains the daemon used to query IMA DB for monitoring
+** data from the core to put it into the workload database which is
+** then used by the design analyzer
+**
+** main() - the main entry point to this program.
+**
+** History:
+** 03-Jul-2008 (thial01)
+** Created
+**
+NEEDLIBS = SCFLIB SHEMBEDLIB COMPATLIB
+
+NEEDLIBSW = SHCUFLIB SHADFLIB
+
+OWNER = INGUSER
+
+PROGRAM = monitordb
+**/
+
+/*{
+** Name: scm_exit() - exit handler for monitordb.
+**
+** Description:
+** This is the exit handling routine for monitordb
+**
+** Inputs:
+** status the status with which we exit
+**
+** Outputs:
+** none
+** Returns:
+** none
+** Exceptions:
+** none
+**
+** Side Effects:
+** none
+**
+** History:
+** 03-Jul-2008 (thial01)
+** Created.
+*/
+VOID
+scm_exit( STATUS status )
+{
+
+ PCexit(status);
+
+}
+
+/*{
+** Name: scm_get_args() - parse the command line
+**
+** Description:
+** This routine parses the command line
+**
+** Inputs:
+** argc Command line argument count.
+** argv Command line argument vector.
+**
+** Outputs:
+** none
+**
+** Returns:
+** OK Completed successfully.
+** FAIL Error
+**
+** Exceptions:
+** none
+**
+** Side Effects:
+** none
+**
+** History:
+** 03-Jul-2008 (thial01)
+** Created.
+*/
+STATUS
+scm_get_args(
+ i4 argc,
+ char *argv[] )
+{
+ char *p;
+
+ while (--argc)
+ {
+ p = *(++argv);
+ switch (p[0])
+ {
+ case '-':
+ switch (p[1])
+ {
+ case 's':
+ break;
+ case 'e':
+ break;
+ }
+
+ default:
+ /* Must be a database name parameter */
+
+ break;
+ }
+
+ }
+
+ return(OK);
+}
+
+/*{
+**
+** Name: main() - main entry point to the tool.
+**
+** Description:
+** This program runs as a daemon and queries IMA DB to get monitoring
+** data for the design analyzer
+**
+** Usage:
+** monitordb dbname
+**
+** Positional Parameters:
+** dbname -- the name of the database to monitor.
+**
+** Diagnostics:
+** No database name specified.
+** You are not a valid INGRES user
+**
+** Inputs:
+** argc The command line argument count.
+** argv The command line argument vector.
+**
+** Outputs:
+** Returns:
+** not applicable
+** Exceptions:
+**
+** Side Effects:
+** Stores the captured data in the workload database
+**
+** History:
+** 03-Jul-2008 (thial01)
+** Created
+*/
+
+main(
+ i4 argc,
+ char *argv[] )
+{
+
+ (void)EXsetclient(EX_INGRES_TOOL);
+
+ MEadvise(ME_INGRES_ALLOC);
+
+ /* Process the command line to get all the necessary parameters */
+
+ if (scm_get_args(argc, argv) != OK)
+ {
+ scm_exit(FAIL);
+ }
+
+ /* Let's fork as a daemon */
+ i4 pid;
+ DB_STATUS status;
+ switch (pid = PCfork(&status))
+ {
+ case -1:
+ status = errno;
+ SIprintf("Fork failed\n");
+ scm_exit(FAIL);
+ case 0:
+ break;
+ default:
+ scm_exit(OK);
+ }
+
+ exec sql begin declare section;
+ char buf[1024];
+ exec sql end declare section;
+
+ exec sql whenever sqlerror stop;
+ exec sql connect imadb;
+
+ exec sql declare cur1 cursor for
+ select value from ima_mib_objects;
+
+ exec sql open cur1 for readonly;
+
+ for (;;)
+ {
+ exec sql fetch cur1 into :buf;
+ if (sqlca.sqlcode == 100)
+ {
+ break;
+ }
+ else if (sqlca.sqlcode != 0)
+ {
+ scm_exit(FAIL);
+ break;
+ }
+ SIprintf("%s\n", buf);
+ }
+
+ exec sql close cur1;
+
+
+
+ scm_exit(OK);
+}
+
More information about the svn-commits
mailing list