]>
Commit | Line | Data |
---|---|---|
c441a31a | 1 | /* $Id$ |
44d40e72 | 2 | * |
7ac48069 | 3 | * DCM-related functions for Moira client |
4 | * | |
5 | * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology. | |
44d40e72 | 6 | * For copying and distribution information, please see the file |
7 | * <mit-copyright.h>. | |
cc5b487a | 8 | */ |
9 | ||
7ac48069 | 10 | #include <mit-copyright.h> |
8defc06b | 11 | #include <moira.h> |
12 | #include <moira_site.h> | |
cc5b487a | 13 | #include "defs.h" |
14 | #include "f_defs.h" | |
15 | #include "globals.h" | |
cc5b487a | 16 | |
7ac48069 | 17 | #include <stdio.h> |
18 | #include <string.h> | |
19 | #include <stdlib.h> | |
20 | ||
21 | RCSID("$Header$"); | |
22 | ||
3ed06d63 | 23 | extern char *whoami; |
cc5b487a | 24 | static char buf[BUFSIZ]; |
7ac48069 | 25 | |
26 | int genable(int argc, char **argv, void *info); | |
27 | int shserv(int argc, char **argv, void *hint); | |
28 | char *unparse_interval(int i); | |
29 | char **askserv(char **info); | |
30 | int gserv(int argc, char **argv, void *hint); | |
31 | void initserv(char *name, char **argv); | |
32 | int shhost(int argc, char **argv, void *hint); | |
33 | int ghost(int argc, char **argv, void *hint); | |
34 | void inithost(char **info); | |
35 | char **askhost(char **info); | |
36 | int pserv(int argc, char **argv, void *count); | |
37 | int phost(int argc, char **argv, void *count); | |
cc5b487a | 38 | |
39 | #define DCM_ENABLE_FLAG 0 | |
40 | ||
7ac48069 | 41 | int genable(int argc, char **argv, void *info) |
cc5b487a | 42 | { |
7ac48069 | 43 | ((char **)info)[1] = strdup(argv[0]); |
5eaef520 | 44 | return MR_CONT; |
cc5b487a | 45 | } |
46 | ||
5eaef520 | 47 | int EnableDcm(int argc, char **argv) |
cc5b487a | 48 | { |
5eaef520 | 49 | int status; |
50 | char *info[3]; | |
51 | ||
52 | info[0] = "dcm_enable"; | |
53 | if ((status = do_mr_query("get_value", 1, info, genable, info))) | |
54 | com_err(whoami, status, " while getting value of dcm_enable"); | |
55 | if (GetValueFromUser("Enable value", &info[1]) == SUB_ERROR) | |
56 | return DM_NORMAL; | |
7ac48069 | 57 | if ((status = do_mr_query("update_value", 2, info, NULL, NULL))) |
5eaef520 | 58 | com_err(whoami, status, " while updating value of dcm_enable"); |
59 | FreeAndClear(&info[0], FALSE); | |
60 | FreeAndClear(&info[1], TRUE); | |
61 | return DM_NORMAL; | |
cc5b487a | 62 | } |
63 | ||
64 | ||
7ac48069 | 65 | int shserv(int argc, char **argv, void *hint) |
cc5b487a | 66 | { |
5eaef520 | 67 | char tmp[64], *dfgen; |
68 | ||
69 | Put_message("Name Type Owner Modified"); | |
70 | sprintf(tmp, "%s:%s", argv[SVC_ACE_TYPE], argv[SVC_ACE_NAME]); | |
71 | sprintf(buf, "%-10s %-8s %-11s by %s on %s with %s", argv[SVC_SERVICE], | |
72 | argv[SVC_TYPE], tmp, argv[SVC_MODBY], argv[SVC_MODTIME], | |
73 | argv[SVC_MODWITH]); | |
74 | Put_message(buf); | |
75 | sprintf(buf, " Interval %s, Target:%s, Script:%s", | |
76 | unparse_interval(atoi(argv[SVC_INTERVAL])), argv[SVC_TARGET], | |
77 | argv[SVC_SCRIPT]); | |
78 | Put_message(buf); | |
79 | if (atoi(argv[SVC_HARDERROR])) | |
80 | sprintf(tmp, "Error %d: %s", atoi(argv[SVC_HARDERROR]), argv[SVC_ERRMSG]); | |
81 | else | |
82 | strcpy(tmp, "No error"); | |
7ac48069 | 83 | dfgen = strdup(atot(argv[SVC_DFGEN])); |
5eaef520 | 84 | sprintf(buf, " Generated %s; Last Checked %s", dfgen, |
85 | atot(argv[SVC_DFCHECK])); | |
86 | free(dfgen); | |
87 | Put_message(buf); | |
88 | sprintf(buf, " %s/%s/%s", atoi(argv[SVC_ENABLE]) ? "Enabled" : "Disabled", | |
89 | atoi(argv[SVC_INPROGRESS]) ? "InProgress" : "Idle", tmp); | |
90 | Put_message(buf); | |
91 | Put_message(""); | |
92 | return MR_CONT; | |
cc5b487a | 93 | } |
94 | ||
95 | ||
5eaef520 | 96 | int showserv(int argc, char **argv) |
cc5b487a | 97 | { |
5eaef520 | 98 | char *qargv[1]; |
99 | int status; | |
100 | ||
101 | qargv[0] = argv[1]; | |
102 | if ((status = do_mr_query("get_server_info", 1, qargv, shserv, NULL))) | |
103 | com_err(whoami, status, " while getting server info"); | |
104 | return DM_NORMAL; | |
cc5b487a | 105 | } |
106 | ||
107 | ||
5eaef520 | 108 | char *unparse_interval(int i) |
cc5b487a | 109 | { |
5eaef520 | 110 | static char uibuf[10]; |
cc5b487a | 111 | |
5eaef520 | 112 | sprintf(uibuf, "%02d:%02d:00", i / 60, i % 60); |
113 | return uibuf; | |
cc5b487a | 114 | } |
115 | ||
5eaef520 | 116 | int addserv(int argc, char **argv) |
cc5b487a | 117 | { |
5eaef520 | 118 | int status; |
7ac48069 | 119 | char *info[SC_END + 1]; |
5eaef520 | 120 | |
121 | initserv(argv[1], info); | |
122 | if (!askserv(info)) | |
123 | { | |
124 | Put_message("Aborted."); | |
125 | return DM_NORMAL; | |
aca0c2c2 | 126 | } |
7ac48069 | 127 | if ((status = do_mr_query("add_server_info", SC_END, info, NULL, NULL))) |
5eaef520 | 128 | com_err(whoami, status, " while updating server info"); |
129 | FreeInfo(info); | |
130 | return DM_NORMAL; | |
cc5b487a | 131 | } |
132 | ||
5eaef520 | 133 | char **askserv(char **info) |
44d40e72 | 134 | { |
5eaef520 | 135 | if (GetValueFromUser("Interval", &info[SC_INTERVAL]) == SUB_ERROR) |
136 | return NULL; | |
137 | if (GetValueFromUser("Target", &info[SC_TARGET]) == SUB_ERROR) | |
138 | return NULL; | |
139 | if (GetValueFromUser("Script", &info[SC_SCRIPT]) == SUB_ERROR) | |
140 | return NULL; | |
141 | if (GetTypeFromUser("Service type", "service", &info[SC_TYPE]) == SUB_ERROR) | |
142 | return NULL; | |
143 | if (GetValueFromUser("Enable", &info[SC_ENABLE]) == SUB_ERROR) | |
144 | return NULL; | |
145 | if (GetTypeFromUser("ACE type", "ace_type", &info[SC_ACE_TYPE]) == SUB_ERROR) | |
146 | return NULL; | |
147 | if (strcasecmp("none", info[SC_ACE_TYPE])) | |
148 | { | |
aca0c2c2 | 149 | if (GetValueFromUser("Ace name", &info[SC_ACE_NAME]) == SUB_ERROR) |
5eaef520 | 150 | return NULL; |
151 | } | |
152 | return info; | |
44d40e72 | 153 | } |
154 | ||
cc5b487a | 155 | |
7ac48069 | 156 | int gserv(int argc, char **argv, void *hint) |
cc5b487a | 157 | { |
7ac48069 | 158 | char **cargv = hint; |
159 | ||
160 | cargv[SC_SERVICE] = strdup(argv[SVC_SERVICE]); | |
161 | cargv[SC_INTERVAL] = strdup(argv[SVC_INTERVAL]); | |
162 | cargv[SC_TARGET] = strdup(argv[SVC_TARGET]); | |
163 | cargv[SC_SCRIPT] = strdup(argv[SVC_SCRIPT]); | |
164 | cargv[SC_TYPE] = strdup(argv[SVC_TYPE]); | |
165 | cargv[SC_ENABLE] = strdup(argv[SVC_ENABLE]); | |
166 | cargv[SC_ACE_TYPE] = strdup(argv[SVC_ACE_TYPE]); | |
167 | cargv[SC_ACE_NAME] = strdup(argv[SVC_ACE_NAME]); | |
5eaef520 | 168 | cargv[SC_END] = NULL; |
169 | return MR_CONT; | |
cc5b487a | 170 | } |
171 | ||
7ac48069 | 172 | void initserv(char *name, char **argv) |
cc5b487a | 173 | { |
5eaef520 | 174 | char tmp[BUFSIZ]; |
175 | ||
7ac48069 | 176 | argv[SC_SERVICE] = strdup(name); |
177 | argv[SC_INTERVAL] = strdup("1440"); | |
5eaef520 | 178 | sprintf(tmp, "/tmp/%s.out", name); |
7ac48069 | 179 | argv[SC_TARGET] = strdup(tmp); |
5eaef520 | 180 | sprintf(tmp, "%s/%s.sh", BIN_DIR, name); |
7ac48069 | 181 | argv[SC_SCRIPT] = strdup(tmp); |
182 | argv[SC_TYPE] = strdup("UNIQUE"); | |
183 | argv[SC_ENABLE] = strdup("1"); | |
184 | argv[SC_ACE_TYPE] = strdup("LIST"); | |
185 | argv[SC_ACE_NAME] = strdup("dbadmin"); | |
5eaef520 | 186 | argv[SC_END] = NULL; |
cc5b487a | 187 | } |
188 | ||
189 | ||
5eaef520 | 190 | int updateserv(int argc, char **argv) |
cc5b487a | 191 | { |
5eaef520 | 192 | char *qargv[SC_END + 1]; |
193 | int status; | |
194 | ||
195 | qargv[0] = (char *)argv[1]; | |
7ac48069 | 196 | if ((status = do_mr_query("get_server_info", 1, qargv, gserv, qargv))) |
5eaef520 | 197 | { |
198 | com_err(whoami, status, " while getting server info"); | |
199 | return DM_NORMAL; | |
cc5b487a | 200 | } |
5eaef520 | 201 | if (!askserv(qargv)) |
202 | { | |
203 | Put_message("Aborted."); | |
204 | return DM_NORMAL; | |
aca0c2c2 | 205 | } |
7ac48069 | 206 | if ((status = do_mr_query("update_server_info", SC_END, qargv, NULL, NULL))) |
5eaef520 | 207 | com_err(whoami, status, " while updating server info"); |
208 | return DM_NORMAL; | |
cc5b487a | 209 | } |
210 | ||
211 | ||
7ac48069 | 212 | int shhost(int argc, char **argv, void *hint) |
cc5b487a | 213 | { |
5eaef520 | 214 | char tmp[64], *ltt; |
215 | ||
216 | sprintf(buf, "%s:%s mod by %s on %s with %s", argv[SH_MACHINE], | |
217 | argv[SH_SERVICE], argv[SH_MODBY], argv[SH_MODTIME], | |
218 | argv[SH_MODWITH]); | |
219 | Put_message(buf); | |
220 | if (atoi(argv[SH_HOSTERROR])) | |
221 | sprintf(tmp, "Error %d: %s", atoi(argv[SH_HOSTERROR]), argv[SH_ERRMSG]); | |
222 | else | |
223 | strcpy(tmp, "No error"); | |
224 | sprintf(buf, " %s/%s/%s/%s/%s", | |
225 | atoi(argv[SH_ENABLE]) ? "Enabled" : "Disabled", | |
226 | atoi(argv[SH_SUCCESS]) ? "Success" : "Failure", | |
227 | atoi(argv[SH_INPROGRESS]) ? "InProgress" : "Idle", | |
228 | atoi(argv[SH_OVERRIDE]) ? "Override" : "Normal", tmp); | |
229 | Put_message(buf); | |
230 | Put_message(" Last Try Last Success Value1 Value2 Value3"); | |
7ac48069 | 231 | ltt = strdup(atot(argv[SH_LASTTRY])); |
5eaef520 | 232 | sprintf(buf, " %-20s %-20s %-9d %-9d %s", ltt, atot(argv[SH_LASTSUCCESS]), |
233 | atoi(argv[SH_VALUE1]), atoi(argv[SH_VALUE2]), argv[SH_VALUE3]); | |
234 | free(ltt); | |
235 | Put_message(buf); | |
236 | Put_message(""); | |
237 | return MR_CONT; | |
cc5b487a | 238 | } |
239 | ||
240 | ||
5eaef520 | 241 | int showhost(int argc, char **argv) |
cc5b487a | 242 | { |
5eaef520 | 243 | char *qargv[2]; |
244 | int status; | |
245 | ||
246 | qargv[SHI_SERVICE] = argv[1]; | |
7ac48069 | 247 | qargv[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2])); |
5eaef520 | 248 | if ((status = do_mr_query("get_server_host_info", 2, qargv, shhost, NULL))) |
249 | com_err(whoami, status, " getting server/host info"); | |
250 | return DM_NORMAL; | |
cc5b487a | 251 | } |
252 | ||
253 | ||
5eaef520 | 254 | int resetsrverr(int argc, char **argv) |
cc5b487a | 255 | { |
5eaef520 | 256 | int status; |
7ac48069 | 257 | if ((status = do_mr_query("reset_server_error", 1, &argv[1], NULL, NULL))) |
5eaef520 | 258 | com_err(whoami, status, " while resetting server error"); |
259 | return DM_NORMAL; | |
cc5b487a | 260 | } |
261 | ||
262 | ||
5eaef520 | 263 | int resetsrvc(int argc, char **argv) |
cc5b487a | 264 | { |
5eaef520 | 265 | int status; |
266 | char *qargv[6], buf[BUFSIZ]; | |
267 | ||
268 | sprintf(buf, "Reset state for service %s (Y/N)", argv[1]); | |
269 | if (!Confirm(buf)) | |
270 | return DM_NORMAL; | |
271 | qargv[0] = argv[1]; | |
272 | qargv[1] = "0"; | |
273 | qargv[2] = "0"; | |
274 | qargv[3] = "0"; | |
275 | qargv[4] = "0"; | |
276 | qargv[5] = ""; | |
277 | if ((status = do_mr_query("set_server_internal_flags", 6, qargv, | |
7ac48069 | 278 | NULL, NULL))) |
5eaef520 | 279 | com_err(whoami, status, " while resetting server error"); |
280 | return DM_NORMAL; | |
cc5b487a | 281 | } |
282 | ||
283 | ||
5eaef520 | 284 | int resethosterr(int argc, char **argv) |
cc5b487a | 285 | { |
5eaef520 | 286 | int status; |
cc5b487a | 287 | |
7ac48069 | 288 | argv[2] = canonicalize_hostname(strdup(argv[2])); |
5eaef520 | 289 | if ((status = do_mr_query("reset_server_host_error", 2, &argv[1], |
7ac48069 | 290 | NULL, NULL))) |
5eaef520 | 291 | com_err(whoami, status, " while resetting server/host error"); |
292 | return DM_NORMAL; | |
cc5b487a | 293 | } |
294 | ||
295 | ||
5eaef520 | 296 | int resethost(int argc, char **argv) |
cc5b487a | 297 | { |
5eaef520 | 298 | int status; |
299 | char *qargv[9], buf[BUFSIZ]; | |
300 | ||
301 | sprintf(buf, "Reset state for service %s on host %s (Y/N)", argv[1], | |
7ac48069 | 302 | canonicalize_hostname(strdup(argv[2]))); |
5eaef520 | 303 | if (!Confirm(buf)) |
304 | return DM_NORMAL; | |
305 | qargv[0] = argv[1]; | |
7ac48069 | 306 | qargv[1] = canonicalize_hostname(strdup(argv[2])); |
5eaef520 | 307 | qargv[2] = "0"; |
308 | qargv[3] = "0"; | |
309 | qargv[4] = "0"; | |
310 | qargv[5] = "0"; | |
311 | qargv[6] = ""; | |
312 | qargv[7] = "0"; | |
313 | qargv[8] = "0"; | |
314 | if ((status = do_mr_query("set_server_host_internal", 9, qargv, | |
7ac48069 | 315 | NULL, NULL))) |
5eaef520 | 316 | com_err(whoami, status, " while resetting server/host error"); |
317 | return DM_NORMAL; | |
cc5b487a | 318 | } |
319 | ||
320 | ||
5eaef520 | 321 | int sethostor(int argc, char **argv) |
cc5b487a | 322 | { |
5eaef520 | 323 | int status; |
cc5b487a | 324 | |
7ac48069 | 325 | argv[2] = canonicalize_hostname(strdup(argv[2])); |
5eaef520 | 326 | if ((status = do_mr_query("set_server_host_override", 2, &argv[1], |
7ac48069 | 327 | NULL, NULL))) |
5eaef520 | 328 | com_err(whoami, status, " while setting server/host override"); |
329 | return DM_NORMAL; | |
cc5b487a | 330 | } |
331 | ||
332 | ||
7ac48069 | 333 | int ghost(int argc, char **argv, void *hint) |
cc5b487a | 334 | { |
7ac48069 | 335 | char **cargv = hint; |
336 | ||
337 | cargv[SHI_SERVICE] = strdup(argv[SH_SERVICE]); | |
338 | cargv[SHI_MACHINE] = strdup(argv[SH_MACHINE]); | |
339 | cargv[SHI_ENABLE] = strdup(argv[SH_ENABLE]); | |
340 | cargv[SHI_VALUE1] = strdup(argv[SH_VALUE1]); | |
341 | cargv[SHI_VALUE2] = strdup(argv[SH_VALUE2]); | |
342 | cargv[SHI_VALUE3] = strdup(argv[SH_VALUE3]); | |
5eaef520 | 343 | cargv[SHI_END] = NULL; |
344 | return MR_CONT; | |
cc5b487a | 345 | } |
346 | ||
347 | ||
7ac48069 | 348 | void inithost(char **info) |
44d40e72 | 349 | { |
7ac48069 | 350 | info[SHI_MACHINE] = canonicalize_hostname(strdup(info[SH_MACHINE])); |
351 | info[SHI_ENABLE] = strdup("1"); | |
352 | info[SHI_VALUE1] = strdup("0"); | |
353 | info[SHI_VALUE2] = strdup("0"); | |
354 | info[SHI_VALUE3] = strdup(""); | |
5eaef520 | 355 | info[SHI_END] = NULL; |
44d40e72 | 356 | } |
357 | ||
358 | ||
5eaef520 | 359 | char **askhost(char **info) |
44d40e72 | 360 | { |
5eaef520 | 361 | if (GetValueFromUser("Enable", &info[SHI_ENABLE]) == SUB_ERROR) |
362 | return NULL; | |
363 | if (GetValueFromUser("Value 1", &info[SHI_VALUE1]) == SUB_ERROR) | |
364 | return NULL; | |
365 | if (GetValueFromUser("Value 2", &info[SHI_VALUE2]) == SUB_ERROR) | |
366 | return NULL; | |
367 | if (GetValueFromUser("Value 3", &info[SHI_VALUE3]) == SUB_ERROR) | |
368 | return NULL; | |
369 | return info; | |
44d40e72 | 370 | } |
371 | ||
372 | ||
5eaef520 | 373 | int updatehost(int argc, char **argv) |
cc5b487a | 374 | { |
5eaef520 | 375 | char *info[SHI_END + 1]; |
376 | int status; | |
377 | ||
7ac48069 | 378 | info[SHI_SERVICE] = strdup(argv[1]); |
379 | info[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2])); | |
380 | if ((status = do_mr_query("get_server_host_info", 2, info, ghost, info))) | |
5eaef520 | 381 | { |
382 | com_err(whoami, status, " while getting server/host info"); | |
383 | return DM_NORMAL; | |
cc5b487a | 384 | } |
5eaef520 | 385 | if (!askhost(info)) |
386 | { | |
387 | Put_message("Aborted."); | |
388 | return DM_NORMAL; | |
aca0c2c2 | 389 | } |
5eaef520 | 390 | if ((status = do_mr_query("update_server_host_info", SHI_END, info, |
7ac48069 | 391 | NULL, NULL))) |
5eaef520 | 392 | com_err(whoami, status, " while updating server/host info"); |
393 | FreeInfo(info); | |
394 | return DM_NORMAL; | |
cc5b487a | 395 | } |
396 | ||
397 | ||
5eaef520 | 398 | int addhost(int argc, char **argv) |
cc5b487a | 399 | { |
5eaef520 | 400 | char *info[SHI_END + 1]; |
401 | int status; | |
402 | ||
7ac48069 | 403 | info[SHI_SERVICE] = strdup(argv[1]); |
404 | info[SHI_MACHINE] = canonicalize_hostname(strdup(argv[2])); | |
5eaef520 | 405 | inithost(info); |
406 | if (!askhost(info)) | |
407 | { | |
408 | Put_message("Aborted."); | |
409 | return DM_NORMAL; | |
aca0c2c2 | 410 | } |
5eaef520 | 411 | if ((status = do_mr_query("add_server_host_info", SHI_END, info, |
7ac48069 | 412 | NULL, NULL))) |
5eaef520 | 413 | com_err(whoami, status, " while adding server/host info"); |
414 | FreeInfo(info); | |
415 | return DM_NORMAL; | |
cc5b487a | 416 | } |
417 | ||
418 | ||
5eaef520 | 419 | int delserv(int argc, char **argv) |
cc5b487a | 420 | { |
5eaef520 | 421 | int status; |
cc5b487a | 422 | |
7ac48069 | 423 | if ((status = do_mr_query("delete_server_info", 1, &argv[1], NULL, NULL))) |
5eaef520 | 424 | com_err(whoami, status, " while deleting server info"); |
425 | return DM_NORMAL; | |
cc5b487a | 426 | } |
427 | ||
428 | ||
5eaef520 | 429 | int delhost(int argc, char **argv) |
cc5b487a | 430 | { |
5eaef520 | 431 | int status; |
cc5b487a | 432 | |
7ac48069 | 433 | argv[2] = canonicalize_hostname(strdup(argv[2])); |
5eaef520 | 434 | if ((status = do_mr_query("delete_server_host_info", 2, &argv[1], |
7ac48069 | 435 | NULL, NULL))) |
5eaef520 | 436 | com_err(whoami, status, " while deleting server/host info"); |
437 | return DM_NORMAL; | |
cc5b487a | 438 | } |
439 | ||
440 | ||
7ac48069 | 441 | int pserv(int argc, char **argv, void *count) |
cc5b487a | 442 | { |
5eaef520 | 443 | sprintf(buf, "Service %s", argv[0]); |
444 | Put_message(buf); | |
7ac48069 | 445 | (*(int *)count)++; |
5eaef520 | 446 | return MR_CONT; |
cc5b487a | 447 | } |
448 | ||
7ac48069 | 449 | int phost(int argc, char **argv, void *count) |
cc5b487a | 450 | { |
5eaef520 | 451 | sprintf(buf, "Host %s:%s", argv[0], argv[1]); |
452 | Put_message(buf); | |
7ac48069 | 453 | (*(int *)count)++; |
5eaef520 | 454 | return MR_CONT; |
cc5b487a | 455 | } |
456 | ||
457 | ||
7ac48069 | 458 | int InProgress(int argc, char **oargv) |
cc5b487a | 459 | { |
5eaef520 | 460 | char *argv[6]; |
461 | int status, count = 0; | |
462 | ||
463 | argv[0] = argv[2] = "DONTCARE"; | |
464 | argv[1] = "TRUE"; | |
465 | if ((status = do_mr_query("qualified_get_server", 3, argv, pserv, | |
7ac48069 | 466 | &count)) && status != MR_NO_MATCH) |
5eaef520 | 467 | com_err(whoami, status, " while getting servers"); |
468 | argv[0] = "*"; | |
469 | argv[1] = argv[2] = argv[3] = argv[5] = "DONTCARE"; | |
470 | argv[4] = "TRUE"; | |
471 | if ((status = do_mr_query("qualified_get_server_host", 6, argv, phost, | |
7ac48069 | 472 | &count)) && status != MR_NO_MATCH) |
5eaef520 | 473 | com_err(whoami, status, " while getting server/hosts"); |
474 | if (!count) | |
475 | strcpy(buf, "Nothing is in progress at this time"); | |
476 | else | |
477 | sprintf(buf, "%d update%s in progress at this time", count, | |
478 | count == 1 ? "" : "s"); | |
479 | Put_message(buf); | |
480 | return DM_NORMAL; | |
cc5b487a | 481 | } |
482 | ||
7ac48069 | 483 | int DcmFailed(int argc, char **oargv) |
cc5b487a | 484 | { |
5eaef520 | 485 | char *argv[6]; |
486 | int status, count = 0; | |
487 | ||
488 | argv[0] = argv[1] = "DONTCARE"; | |
489 | argv[2] = "TRUE"; | |
490 | if ((status = do_mr_query("qualified_get_server", 3, argv, pserv, | |
7ac48069 | 491 | &count)) && status != MR_NO_MATCH) |
5eaef520 | 492 | com_err(whoami, status, " while getting servers"); |
493 | argv[0] = "*"; | |
494 | argv[1] = argv[2] = argv[3] = argv[4] = "DONTCARE"; | |
495 | argv[5] = "TRUE"; | |
496 | if ((status = do_mr_query("qualified_get_server_host", 6, argv, phost, | |
7ac48069 | 497 | &count)) && status != MR_NO_MATCH) |
5eaef520 | 498 | com_err(whoami, status, " while getting server/hosts"); |
499 | if (!count) | |
500 | strcpy(buf, "Nothing has failed at this time"); | |
501 | else | |
502 | sprintf(buf, "%d thing%s ha%s failed at this time", count, | |
503 | count == 1 ? "" : "s", count == 1 ? "s" : "ve"); | |
504 | Put_message(buf); | |
505 | return DM_NORMAL; | |
cc5b487a | 506 | } |
507 | ||
508 | ||
7ac48069 | 509 | int Dcm(int argc, char **argv) |
cc5b487a | 510 | { |
5eaef520 | 511 | int status; |
512 | if (Confirm("Are you sure you want to start a DCM now")) | |
513 | { | |
514 | if ((status = mr_do_update())) | |
2e140f82 | 515 | com_err(whoami, status, " while triggering update"); |
5eaef520 | 516 | } |
517 | return DM_NORMAL; | |
cc5b487a | 518 | } |