10 tplarson 1.2 int status=0;
11 int len;
12 long long hold;
13 TIME tnow, UNIX_epoch = -220924792.000; /* 1970.01.01_00:00:00_UTC */
14 char path[DRMS_MAXPATHLEN+1];
15 DRMS_Record_t *histrec = drms_create_record(drms_env,
16 histlink->info->target_series,
17 DRMS_PERMANENT,
18 &status);
|
20 tplarson 1.2 if (status != DRMS_SUCCESS)
21 {
22 fprintf(stderr,"ERROR: could not open a record in history dataseries %s, status = %d\n", histlink->info->target_series, status);
23 return -1;
24 }
|
26 tplarson 1.2 if ((len=readlink("/proc/self/exe", path, DRMS_MAXPATHLEN)) == -1)
27 {
28 fprintf(stderr, "ERROR: cannot locate binary\n");
29 drms_close_record(histrec, DRMS_FREE_RECORD);
30 return -1;
31 }
32 else
33 path[len]='\0';
34
35 status = drms_setkey_string(histrec, "MODPATH", path);
36 if (status != DRMS_SUCCESS)
37 {
38 fprintf(stderr,"ERROR: problem writing keyword MODPATH in history dataseries, status = %d\n", status);
39 drms_close_record(histrec, DRMS_FREE_RECORD);
40 return -1;
41 }
42 status = drms_setkey_string(histrec, "MODNAME", cmdparams.argv[0]);
43 if (status != DRMS_SUCCESS)
44 {
45 fprintf(stderr,"ERROR: problem writing keyword MODNAME in history dataseries, status = %d\n", status);
46 drms_close_record(histrec, DRMS_FREE_RECORD);
47 tplarson 1.2 return -1;
48 }
49 status = drms_setkey_string(histrec, "ARGSUSED", savestr);
50 if (status != DRMS_SUCCESS)
51 {
52 fprintf(stderr,"ERROR: problem writing keyword ARGSUSED in history dataseries, status = %d\n", status);
53 drms_close_record(histrec, DRMS_FREE_RECORD);
54 return -1;
55 }
|
60 tplarson 1.2 drms_close_record(histrec, DRMS_FREE_RECORD);
61 return -1;
62 }
63 tnow = (double)time(NULL);
64 tnow += UNIX_epoch;
65 status = drms_setkey_time(histrec, "DATE", tnow);
66 if (status != DRMS_SUCCESS)
67 {
68 fprintf(stderr,"ERROR: problem writing keyword DATE in history dataseries, status = %d\n", status);
69 drms_close_record(histrec, DRMS_FREE_RECORD);
70 return -1;
71 }
72
73 hold=histrec->recnum;
74 drms_close_record(histrec, DRMS_INSERT_RECORD);
75 return hold;
|