00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 char *module_name = "CookbookRecipe:03";
00017 char *version_id = "1.0";
00018
00019 #include <jsoc_main.h>
00020 #include <regex.h>
00021
00022 ModuleArgs_t module_args[] = {
00023 {ARG_INT, "nmax", "100", "maximum number of series to be listed"},
00024 {ARG_END}
00025 };
00026
00027 int DoIt (void) {
00028 CmdParams_t *params = &cmdparams;
00029 DB_Text_Result_t *qres, *sqres;
00030 int series, seriesct;
00031 char query[DRMS_MAXQUERYLEN];
00032
00033 int nmax = params_get_int (params, "nmax");
00034
00035 sprintf (query, "select seriesname from %s()", DRMS_MASTER_SERIES_TABLE);
00036 if ((qres = drms_query_txt (drms_env->session, query)) == NULL) {
00037 fprintf (stderr, "Cant find DRMS\n");
00038 return 1;
00039 }
00040 seriesct = qres->num_rows;
00041 printf ("%d series found", seriesct);
00042 if (seriesct > nmax) {
00043 seriesct = nmax;
00044 printf (" (only the first %d will be listed)", seriesct);
00045 }
00046 printf ("\n");
00047
00048 for (series = 0; series < seriesct; series++) {
00049 char *seriesname = qres->field[series][0];
00050 printf ("%s\t", seriesname);
00051 sprintf (query, "select count (recnum) from %s", seriesname);
00052
00053
00054 if (sqres = drms_query_txt (drms_env->session, query)) {
00055 printf ("%s", sqres->field[0][0]);
00056 db_free_text_result (sqres);
00057 } else printf ("?");
00058 printf ("\n");
00059 }
00060
00061 db_free_text_result (qres);
00062 return 0;
00063 }
00064
00065
00066
00067
00068
00069