1 Index: src/dird/ua_update.c
2 ===================================================================
3 --- src/dird/ua_update.c (révision 7144)
4 +++ src/dird/ua_update.c (copie de travail)
6 static int update_volume(UAContext *ua);
7 static bool update_pool(UAContext *ua);
8 static bool update_job(UAContext *ua);
9 +static bool update_stats(UAContext *ua);
12 * Update a Pool Record in the database.
14 * changes pool info for volume
15 * update slots [scan=...]
16 * updates autochanger slots
17 + * update stats [days=...]
18 + * updates long term statistics
20 int update_cmd(UAContext *ua, const char *cmd)
26 + NT_("stats"), /* 5 */
29 if (!open_client_db(ua)) {
41 add_prompt(ua, _("Volume parameters"));
42 add_prompt(ua, _("Pool from resource"));
43 add_prompt(ua, _("Slots from autochanger"));
44 + add_prompt(ua, _("Long term statistics"));
45 switch (do_prompt(ua, _("item"), _("Choose catalog item to update"), NULL, 0)) {
62 + * Update long term statistics
64 +static bool update_stats(UAContext *ua)
66 + int i = find_arg_with_value(ua, NT_("days"));
70 + since = atoi(ua->argv[i]) * 24*60*60;
73 + int nb = db_update_stats(ua->jcr, ua->db, since);
74 + ua->info_msg(_("Updating %i job(s).\n"), nb);
80 * Update pool record -- pull info from current POOL resource
82 static bool update_pool(UAContext *ua)
83 Index: src/cats/sql_update.c
84 ===================================================================
85 --- src/cats/sql_update.c (révision 7144)
86 +++ src/cats/sql_update.c (copie de travail)
91 + * Update Long term statistics with all jobs that were run before
95 +db_update_stats(JCR *jcr, B_DB *mdb, time_t age)
98 + utime_t now = (utime_t)time(NULL);
99 + edit_uint64(now - age, ed1);
102 + "INSERT INTO JobStat "
105 + "WHERE JobStatus IN ('T', 'f', 'A', 'E') "
106 + "AND JobId NOT IN (SELECT JobId FROM JobStat) "
107 + "AND JobTDate < %s ", ed1);
108 + QUERY_DB(jcr, mdb, mdb->cmd); /* TODO: get a message ? */
109 + return sql_affected_rows(mdb);
113 * Given an incoming integer, set the string buffer to either NULL or the value
117 bsnprintf(s, n, id ? "%s" : "NULL", edit_int64(id, ed1));
122 * Update the Job record at end of Job
130 Mmsg(mdb->cmd, "UPDATE Storage SET AutoChanger=%d WHERE StorageId=%s",
131 sr->AutoChanger, edit_int64(sr->StorageId, ed1));
132 Index: src/cats/protos.h
133 ===================================================================
134 --- src/cats/protos.h (révision 7144)
135 +++ src/cats/protos.h (copie de travail)
137 int db_add_digest_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *digest, int type);
138 int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
139 void db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
140 +int db_update_stats(JCR *jcr, B_DB *mdb, time_t age);
142 #endif /* __SQL_PROTOS_H */