Print this page
4740 kstat(1M) prints wrong snaptime


 640                  */
 641                 ksi = (ks_instance_t *)malloc(sizeof (ks_instance_t));
 642                 if (ksi == NULL) {
 643                         perror("malloc");
 644                         exit(3);
 645                 }
 646 
 647                 list_link_init(&ksi->ks_next);
 648 
 649                 (void) strlcpy(ksi->ks_module, kp->ks_module, KSTAT_STRLEN);
 650                 (void) strlcpy(ksi->ks_name, kp->ks_name, KSTAT_STRLEN);
 651                 (void) strlcpy(ksi->ks_class, kp->ks_class, KSTAT_STRLEN);
 652 
 653                 ksi->ks_instance = kp->ks_instance;
 654                 ksi->ks_snaptime = kp->ks_snaptime;
 655                 ksi->ks_type = kp->ks_type;
 656 
 657                 list_create(&ksi->ks_nvlist, sizeof (ks_nvpair_t),
 658                     offsetof(ks_nvpair_t, nv_next));
 659 
 660                 SAVE_HRTIME_X(ksi, "crtime", kp->ks_crtime);
 661                 SAVE_HRTIME_X(ksi, "snaptime", kp->ks_snaptime);
 662                 if (g_pflg) {
 663                         SAVE_STRING_X(ksi, "class", kp->ks_class);
 664                 }
 665 
 666                 /* Insert this instance into a sorted list */
 667                 tmp = list_head(&instances_list);
 668                 while (tmp != NULL && compare_instances(ksi, tmp) > 0)
 669                         tmp = list_next(&instances_list, tmp);
 670 
 671                 list_insert_before(&instances_list, tmp, ksi);
 672 
 673                 /* Read the actual statistics */
 674                 id = kstat_read(kc, kp, NULL);
 675                 if (id == -1) {
 676 #ifdef REPORT_UNKNOWN
 677                         perror("kstat_read");
 678 #endif
 679                         continue;
 680                 }
 681 






 682                 switch (kp->ks_type) {
 683                 case KSTAT_TYPE_RAW:
 684                         save_raw(kp, ksi);
 685                         break;
 686                 case KSTAT_TYPE_NAMED:
 687                         save_named(kp, ksi);
 688                         break;
 689                 case KSTAT_TYPE_INTR:
 690                         save_intr(kp, ksi);
 691                         break;
 692                 case KSTAT_TYPE_IO:
 693                         save_io(kp, ksi);
 694                         break;
 695                 case KSTAT_TYPE_TIMER:
 696                         save_timer(kp, ksi);
 697                         break;
 698                 default:
 699                         assert(B_FALSE); /* Invalid type */
 700                         break;
 701                 }




 640                  */
 641                 ksi = (ks_instance_t *)malloc(sizeof (ks_instance_t));
 642                 if (ksi == NULL) {
 643                         perror("malloc");
 644                         exit(3);
 645                 }
 646 
 647                 list_link_init(&ksi->ks_next);
 648 
 649                 (void) strlcpy(ksi->ks_module, kp->ks_module, KSTAT_STRLEN);
 650                 (void) strlcpy(ksi->ks_name, kp->ks_name, KSTAT_STRLEN);
 651                 (void) strlcpy(ksi->ks_class, kp->ks_class, KSTAT_STRLEN);
 652 
 653                 ksi->ks_instance = kp->ks_instance;
 654                 ksi->ks_snaptime = kp->ks_snaptime;
 655                 ksi->ks_type = kp->ks_type;
 656 
 657                 list_create(&ksi->ks_nvlist, sizeof (ks_nvpair_t),
 658                     offsetof(ks_nvpair_t, nv_next));
 659 






 660                 /* Insert this instance into a sorted list */
 661                 tmp = list_head(&instances_list);
 662                 while (tmp != NULL && compare_instances(ksi, tmp) > 0)
 663                         tmp = list_next(&instances_list, tmp);
 664 
 665                 list_insert_before(&instances_list, tmp, ksi);
 666 
 667                 /* Read the actual statistics */
 668                 id = kstat_read(kc, kp, NULL);
 669                 if (id == -1) {
 670 #ifdef REPORT_UNKNOWN
 671                         perror("kstat_read");
 672 #endif
 673                         continue;
 674                 }
 675 
 676                 SAVE_HRTIME_X(ksi, "crtime", kp->ks_crtime);
 677                 SAVE_HRTIME_X(ksi, "snaptime", kp->ks_snaptime);
 678                 if (g_pflg) {
 679                         SAVE_STRING_X(ksi, "class", kp->ks_class);
 680                 }
 681 
 682                 switch (kp->ks_type) {
 683                 case KSTAT_TYPE_RAW:
 684                         save_raw(kp, ksi);
 685                         break;
 686                 case KSTAT_TYPE_NAMED:
 687                         save_named(kp, ksi);
 688                         break;
 689                 case KSTAT_TYPE_INTR:
 690                         save_intr(kp, ksi);
 691                         break;
 692                 case KSTAT_TYPE_IO:
 693                         save_io(kp, ksi);
 694                         break;
 695                 case KSTAT_TYPE_TIMER:
 696                         save_timer(kp, ksi);
 697                         break;
 698                 default:
 699                         assert(B_FALSE); /* Invalid type */
 700                         break;
 701                 }