mco_perfmon_get_db_name

Retrieves the name of the database currently attached to the Performance Monitor.

Prototype

    const char *mco_perfmon_get_db_name(void);

Arguments

void
No arguments.

Description

This function returns the name of the database that is currently being monitored by the Performance Monitor. If no database is attached, the function returns NULL.

The returned string is owned by the perfmon subsystem and must not be modified or freed by the application.

Return Value

const char *
Name of the currently attached database, or NULL if no database is attached.

Example

    #define PERF_DATABASE_SEGMENT_SIZE (64 << 20)  /* 64 MB */
    const char* dbName = "SimpleDb";

    int main(int argc, char* argv[])
    {
        mco_db_h db;
        MCO_RET rc;
        void *perf_memory;

        perf_memory = malloc(PERF_DATABASE_SEGMENT_SIZE);
        if (!perf_memory) {
            /* handle allocation error */
        }

        rc = mco_perfmon_init(perf_memory, PERF_DATABASE_SEGMENT_SIZE);
        if (rc != MCO_S_OK) { /* handle error */ }

        rc = mco_perfmon_attach(dbName);
        if (rc != MCO_S_OK) { /* handle error */ }

        rc = mco_db_connect(dbName, &db);
        if (rc != MCO_S_OK) { /* handle error */ }

        /* Retrieve the name of the monitored database */
        const char *monitored_db = mco_perfmon_get_db_name();
        if (monitored_db) {
            printf("Currently monitoring: %s\n", monitored_db);
        }

        rc = mco_db_disconnect(db);
        rc = mco_perfmon_detach(dbName);
        rc = mco_perfmon_close();
        free(perf_memory);
        return 0;
    }

Files

Header file:
mcoperfmon.h
Source file:
mcoperf.c
Library:
libmcoperf.a