Mercurial > illumos > illumos-gate
comparison usr/src/cmd/fm/fmadm/common/faulty.c @ 10928:eb060666c73f
6885689 syseventd: [daemon.error] Fatal:attempting to dump core on snv_124
6874078 fminject should always add __injected payload
6874080 fmd_case_add_ereport() should add any __injected payload from ereports into the suspect list
6796601 fmadm faulty doesn't show the year when events happen
6820523 fmdump -V should display the complete time for all files, not just errlog files
6881060 Subdirectories in /var/fm/fmd/ have overly restrictive permissions
6890955 oodles of FMA messages upon fmd start-up
author | Stephen Hanson <Stephen.Hanson@Sun.COM> |
---|---|
date | Mon, 02 Nov 2009 09:11:35 -0800 |
parents | 217544b3cf73 |
children | be69f645ce17 |
comparison
equal
deleted
inserted
replaced
10927:ac35db8a7412 | 10928:eb060666c73f |
---|---|
213 name_list_t *resource; | 213 name_list_t *resource; |
214 name_list_t *asru; | 214 name_list_t *asru; |
215 name_list_t *fru; | 215 name_list_t *fru; |
216 name_list_t *serial; | 216 name_list_t *serial; |
217 uint8_t not_suppressed; | 217 uint8_t not_suppressed; |
218 uint8_t injected; | |
218 } status_record_t; | 219 } status_record_t; |
219 | 220 |
220 typedef struct sr_list { | 221 typedef struct sr_list { |
221 struct sr_list *next; | 222 struct sr_list *next; |
222 struct sr_list *prev; | 223 struct sr_list *prev; |
227 struct resource_list *next; | 228 struct resource_list *next; |
228 struct resource_list *prev; | 229 struct resource_list *prev; |
229 sr_list_t *status_rec_list; | 230 sr_list_t *status_rec_list; |
230 char *resource; | 231 char *resource; |
231 uint8_t not_suppressed; | 232 uint8_t not_suppressed; |
233 uint8_t injected; | |
232 uint8_t max_pct; | 234 uint8_t max_pct; |
233 } resource_list_t; | 235 } resource_list_t; |
234 | 236 |
235 typedef struct tgetlabel_data { | 237 typedef struct tgetlabel_data { |
236 char *label; | 238 char *label; |
257 (void) fprintf(stderr, | 259 (void) fprintf(stderr, |
258 "record time is too large for 32-bit utility\n"); | 260 "record time is too large for 32-bit utility\n"); |
259 (void) snprintf(buf, len, "0x%llx", sec); | 261 (void) snprintf(buf, len, "0x%llx", sec); |
260 } else { | 262 } else { |
261 time_t tod = (time_t)sec; | 263 time_t tod = (time_t)sec; |
262 (void) strftime(buf, len, "%b %d %T", localtime(&tod)); | 264 time_t now = time(NULL); |
265 if (tod > now+60 || | |
266 tod < now - 6L*30L*24L*60L*60L) { /* 6 months ago */ | |
267 (void) strftime(buf, len, "%b %d %Y ", | |
268 localtime(&tod)); | |
269 } else { | |
270 (void) strftime(buf, len, "%b %d %T", localtime(&tod)); | |
271 } | |
263 } | 272 } |
264 | 273 |
265 return (buf); | 274 return (buf); |
266 } | 275 } |
267 | 276 |
610 | 619 |
611 static status_record_t * | 620 static status_record_t * |
612 new_record_init(uurec_t *uurec_p, char *msgid, name_list_t *class, | 621 new_record_init(uurec_t *uurec_p, char *msgid, name_list_t *class, |
613 name_list_t *fru, name_list_t *asru, name_list_t *resource, | 622 name_list_t *fru, name_list_t *asru, name_list_t *resource, |
614 name_list_t *serial, boolean_t not_suppressed, | 623 name_list_t *serial, boolean_t not_suppressed, |
615 hostid_t *hostid) | 624 hostid_t *hostid, boolean_t injected) |
616 { | 625 { |
617 status_record_t *status_rec_p; | 626 status_record_t *status_rec_p; |
618 | 627 |
619 status_rec_p = (status_record_t *)malloc(sizeof (status_record_t)); | 628 status_rec_p = (status_record_t *)malloc(sizeof (status_record_t)); |
620 status_rec_p->nrecs = 1; | 629 status_rec_p->nrecs = 1; |
631 status_rec_p->asru = asru; | 640 status_rec_p->asru = asru; |
632 status_rec_p->resource = resource; | 641 status_rec_p->resource = resource; |
633 status_rec_p->serial = serial; | 642 status_rec_p->serial = serial; |
634 status_rec_p->msgid = strdup(msgid); | 643 status_rec_p->msgid = strdup(msgid); |
635 status_rec_p->not_suppressed = not_suppressed; | 644 status_rec_p->not_suppressed = not_suppressed; |
645 status_rec_p->injected = injected; | |
636 return (status_rec_p); | 646 return (status_rec_p); |
637 } | 647 } |
638 | 648 |
639 /* | 649 /* |
640 * add record to given list maintaining order higher priority first. | 650 * add record to given list maintaining order higher priority first. |
730 np = *rpp; | 740 np = *rpp; |
731 end = np; | 741 end = np; |
732 while (np) { | 742 while (np) { |
733 if (strcmp(fp->name, np->resource) == 0) { | 743 if (strcmp(fp->name, np->resource) == 0) { |
734 np->not_suppressed |= status_rec_p->not_suppressed; | 744 np->not_suppressed |= status_rec_p->not_suppressed; |
745 np->injected |= status_rec_p->injected; | |
735 srp = np->status_rec_list->status_record; | 746 srp = np->status_rec_list->status_record; |
736 order = cmp_priority(status_rec_p->severity, | 747 order = cmp_priority(status_rec_p->severity, |
737 srp->severity, status_rec_p->uurec->sec, | 748 srp->severity, status_rec_p->uurec->sec, |
738 srp->uurec->sec, fp->max_pct, np->max_pct); | 749 srp->uurec->sec, fp->max_pct, np->max_pct); |
739 if (order > 0 && np != end) { | 750 if (order > 0 && np != end) { |
759 } | 770 } |
760 if (np == NULL) { | 771 if (np == NULL) { |
761 np = malloc(sizeof (resource_list_t)); | 772 np = malloc(sizeof (resource_list_t)); |
762 np->resource = fp->name; | 773 np->resource = fp->name; |
763 np->not_suppressed = status_rec_p->not_suppressed; | 774 np->not_suppressed = status_rec_p->not_suppressed; |
775 np->injected = status_rec_p->injected; | |
764 np->status_rec_list = NULL; | 776 np->status_rec_list = NULL; |
765 np->max_pct = fp->max_pct; | 777 np->max_pct = fp->max_pct; |
766 add_resource(status_rec_p, rpp, np); | 778 add_resource(status_rec_p, rpp, np); |
767 } | 779 } |
768 } | 780 } |
788 */ | 800 */ |
789 static void | 801 static void |
790 catalog_new_record(uurec_t *uurec_p, char *msgid, name_list_t *class, | 802 catalog_new_record(uurec_t *uurec_p, char *msgid, name_list_t *class, |
791 name_list_t *fru, name_list_t *asru, name_list_t *resource, | 803 name_list_t *fru, name_list_t *asru, name_list_t *resource, |
792 name_list_t *serial, boolean_t not_suppressed, | 804 name_list_t *serial, boolean_t not_suppressed, |
793 hostid_t *hostid) | 805 hostid_t *hostid, boolean_t injected) |
794 { | 806 { |
795 status_record_t *status_rec_p; | 807 status_record_t *status_rec_p; |
796 | 808 |
797 status_rec_p = new_record_init(uurec_p, msgid, class, fru, asru, | 809 status_rec_p = new_record_init(uurec_p, msgid, class, fru, asru, |
798 resource, serial, not_suppressed, hostid); | 810 resource, serial, not_suppressed, hostid, injected); |
799 add_rec_list(status_rec_p, &status_rec_list); | 811 add_rec_list(status_rec_p, &status_rec_list); |
800 if (status_rec_p->fru) | 812 if (status_rec_p->fru) |
801 add_list(status_rec_p, status_rec_p->fru, &status_fru_list); | 813 add_list(status_rec_p, status_rec_p->fru, &status_fru_list); |
802 if (status_rec_p->asru) | 814 if (status_rec_p->asru) |
803 add_list(status_rec_p, status_rec_p->asru, &status_asru_list); | 815 add_list(status_rec_p, status_rec_p->asru, &status_asru_list); |
922 uint8_t *ba; | 934 uint8_t *ba; |
923 uurec_t *uurec_p; | 935 uurec_t *uurec_p; |
924 hostid_t *host; | 936 hostid_t *host; |
925 boolean_t not_suppressed = 1; | 937 boolean_t not_suppressed = 1; |
926 boolean_t any_present = 0; | 938 boolean_t any_present = 0; |
939 boolean_t injected = 0; | |
927 | 940 |
928 (void) nvlist_lookup_string(nvl, FM_SUSPECT_DIAG_CODE, &msgid); | 941 (void) nvlist_lookup_string(nvl, FM_SUSPECT_DIAG_CODE, &msgid); |
929 (void) nvlist_lookup_uint32(nvl, FM_SUSPECT_FAULT_SZ, &size); | 942 (void) nvlist_lookup_uint32(nvl, FM_SUSPECT_FAULT_SZ, &size); |
930 (void) nvlist_lookup_boolean_value(nvl, FM_SUSPECT_MESSAGE, | 943 (void) nvlist_lookup_boolean_value(nvl, FM_SUSPECT_MESSAGE, |
931 ¬_suppressed); | 944 ¬_suppressed); |
945 (void) nvlist_lookup_boolean_value(nvl, FM_SUSPECT_INJECTED, &injected); | |
932 | 946 |
933 if (size != 0) { | 947 if (size != 0) { |
934 (void) nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, | 948 (void) nvlist_lookup_nvlist_array(nvl, FM_SUSPECT_FAULT_LIST, |
935 &nva, &size); | 949 &nva, &size); |
936 (void) nvlist_lookup_uint8_array(nvl, FM_SUSPECT_FAULT_STATUS, | 950 (void) nvlist_lookup_uint8_array(nvl, FM_SUSPECT_FAULT_STATUS, |
955 uurec_p->ari_uuid_list = NULL; | 969 uurec_p->ari_uuid_list = NULL; |
956 uurec_p->event = NULL; | 970 uurec_p->event = NULL; |
957 (void) nvlist_dup(nvl, &uurec_p->event, 0); | 971 (void) nvlist_dup(nvl, &uurec_p->event, 0); |
958 host = find_hostid(nvl); | 972 host = find_hostid(nvl); |
959 catalog_new_record(uurec_p, msgid, class, fru, asru, | 973 catalog_new_record(uurec_p, msgid, class, fru, asru, |
960 resource, serial, not_suppressed, host); | 974 resource, serial, not_suppressed, host, injected); |
961 } | 975 } |
962 | 976 |
963 static void | 977 static void |
964 update_asru_state_in_catalog(const char *uuid, const char *ari_uuid) | 978 update_asru_state_in_catalog(const char *uuid, const char *ari_uuid) |
965 { | 979 { |
1421 header = 1; | 1435 header = 1; |
1422 } | 1436 } |
1423 if (opt_i) { | 1437 if (opt_i) { |
1424 ari_list = uurp->ari_uuid_list; | 1438 ari_list = uurp->ari_uuid_list; |
1425 while (ari_list) { | 1439 while (ari_list) { |
1426 (void) printf("%-15s %-37s %-14s %-9s\n", | 1440 (void) printf("%-15s %-37s %-14s %-9s %s\n", |
1427 format_date(buf, sizeof (buf), uurp->sec), | 1441 format_date(buf, sizeof (buf), uurp->sec), |
1428 ari_list->ari_uuid, srp->msgid, srp->severity); | 1442 ari_list->ari_uuid, srp->msgid, srp->severity, |
1443 srp->injected ? dgettext("FMD", "injected") : ""); | |
1429 ari_list = ari_list->next; | 1444 ari_list = ari_list->next; |
1430 } | 1445 } |
1431 } else { | 1446 } else { |
1432 (void) printf("%-15s %-37s %-14s %-9s\n", | 1447 (void) printf("%-15s %-37s %-14s %-9s %s\n", |
1433 format_date(buf, sizeof (buf), uurp->sec), | 1448 format_date(buf, sizeof (buf), uurp->sec), |
1434 uurp->uuid, srp->msgid, srp->severity); | 1449 uurp->uuid, srp->msgid, srp->severity, |
1450 srp->injected ? dgettext("FMD", "injected") : ""); | |
1435 } | 1451 } |
1436 | 1452 |
1437 if (!summary) | 1453 if (!summary) |
1438 print_sup_record(srp, opt_i, full); | 1454 print_sup_record(srp, opt_i, full); |
1439 } | 1455 } |
1549 break; | 1565 break; |
1550 } | 1566 } |
1551 slp = slp->next; | 1567 slp = slp->next; |
1552 } while (slp != end); | 1568 } while (slp != end); |
1553 if (status & FM_SUSPECT_NOT_PRESENT) | 1569 if (status & FM_SUSPECT_NOT_PRESENT) |
1554 (void) printf(dgettext("FMD", "not present\n")); | 1570 (void) printf(dgettext("FMD", "not present")); |
1555 else if (status & FM_SUSPECT_FAULTY) | 1571 else if (status & FM_SUSPECT_FAULTY) |
1556 (void) printf(dgettext("FMD", "faulty\n")); | 1572 (void) printf(dgettext("FMD", "faulty")); |
1557 else if (status & FM_SUSPECT_REPLACED) | 1573 else if (status & FM_SUSPECT_REPLACED) |
1558 (void) printf(dgettext("FMD", "replaced\n")); | 1574 (void) printf(dgettext("FMD", "replaced")); |
1559 else if (status & FM_SUSPECT_REPAIRED) | 1575 else if (status & FM_SUSPECT_REPAIRED) |
1560 (void) printf(dgettext("FMD", | 1576 (void) printf(dgettext("FMD", |
1561 "repair attempted\n")); | 1577 "repair attempted")); |
1562 else if (status & FM_SUSPECT_ACQUITTED) | 1578 else if (status & FM_SUSPECT_ACQUITTED) |
1563 (void) printf(dgettext("FMD", "acquitted\n")); | 1579 (void) printf(dgettext("FMD", "acquitted")); |
1564 else | 1580 else |
1565 (void) printf(dgettext("FMD", "removed\n")); | 1581 (void) printf(dgettext("FMD", "removed")); |
1582 | |
1583 if (tp->injected) | |
1584 (void) printf(dgettext("FMD", " injected\n")); | |
1585 else | |
1586 (void) printf(dgettext("FMD", "\n")); | |
1566 | 1587 |
1567 slp = tp->status_rec_list; | 1588 slp = tp->status_rec_list; |
1568 end = slp; | 1589 end = slp; |
1569 do { | 1590 do { |
1570 srp = slp->status_record; | 1591 srp = slp->status_record; |
1661 break; | 1682 break; |
1662 default: | 1683 default: |
1663 msg = ""; | 1684 msg = ""; |
1664 break; | 1685 break; |
1665 } | 1686 } |
1666 (void) printf("%-69s %s\n", tp->resource, msg); | 1687 (void) printf("%-69s %s", tp->resource, msg); |
1688 if (tp->injected) | |
1689 (void) printf(dgettext("FMD", " injected\n")); | |
1690 else | |
1691 (void) printf(dgettext("FMD", "\n")); | |
1667 } | 1692 } |
1668 tp = tp->next; | 1693 tp = tp->next; |
1669 if (tp == status_asru_list) | 1694 if (tp == status_asru_list) |
1670 break; | 1695 break; |
1671 } | 1696 } |