00001 #include "drms.h"
00002 #include <printk.h>
00003 #ifdef __linux__
00004 #include <sched.h>
00005 #endif
00006
00007 ModuleArgs_t module_args[] =
00008 {
00009 {ARG_INT, "sunum", NULL , "SU number", ""},
00010 {ARG_STRING, "seriesname", NULL, "SU series name", ""},
00011 {ARG_STRING, "sudir", NULL, "SU number directory", ""},
00012 {ARG_INT, "retention", "3", "retention time", ""},
00013 {ARG_END}
00014 };
00015
00016 ModuleArgs_t *gModArgs = module_args;
00017 CmdParams_t cmdparams;
00018
00019 int main(int argc, char *argv[])
00020 {
00021 long long sunum = 0;
00022 int retention = 60;
00023 char *sudir = (char *) NULL;
00024 char *seriesname = (char *) NULL;
00025 SUM_t *sum = NULL;
00026 int status = 0;
00027
00028 if ((status = cmdparams_parse(&cmdparams, argc, argv)) < CMDPARAMS_SUCCESS)
00029 {
00030 fprintf(stderr,"Error: Command line parsing failed. Aborting. [%d]\n", status);
00031 return -1;
00032 }
00033
00034 sunum = cmdparams_get_int64(&cmdparams, "sunum", NULL);
00035 sudir = strdup(cmdparams_get_str(&cmdparams, "sudir", NULL));
00036 seriesname = strdup(cmdparams_get_str(&cmdparams, "seriesname", NULL));
00037 retention = cmdparams_get_int(&cmdparams, "retention", NULL);
00038
00039 fprintf(stdout,"sudir=%s\n",sudir);
00040 fprintf(stdout,"seriesname=%s\n",seriesname);
00041
00042 if ((sum = SUM_open(NULL, NULL, printkerr)) == NULL)
00043 {
00044 fprintf(stderr,"ERROR: drms_open: Failed to connect to SUMS.\n");
00045 fflush(stdout);
00046 return -2;
00047 }
00048
00049 sum->dsname = seriesname;
00050 sum->group = 0;
00051 sum->mode = TEMP + TOUCH;
00052 sum->tdays = retention;
00053 sum->reqcnt = 1;
00054 sum->history_comment = "";
00055
00056 sum->dsix_ptr[0] = sunum;
00057 sum->wd[0] = sudir;
00058
00059
00060 if ((status = SUM_put(sum, printkerr)))
00061 {
00062 fprintf(stderr,"ERROR: SUM_put RPC call failed with "
00063 "error code %d\n", status);
00064
00065 if (sum)
00066 {
00067 SUM_close(sum, printkerr);
00068 }
00069
00070 return -3;
00071 }
00072 else
00073 {
00074 fprintf(stdout,"DRMS_SUMPUT:%d OK\n", sunum);
00075 fflush(stderr);
00076 fflush(stdout);
00077 }
00078
00079 if (seriesname)
00080 {
00081 free(seriesname);
00082 }
00083
00084 if (sudir)
00085 {
00086 free(sudir);
00087 }
00088
00089 SUM_close(sum, printkerr);
00090
00091 return 0;
00092 }
00093