00001
00002 #include "nml.hh"
00003 #include "nmldiag.hh"
00004 #include "rcs_prnt.hh"
00005 #include <time.h>
00006
00007
00008 static char access_name[9][40] = {
00009 "ZERO",
00010 "READ",
00011 "CHECK_IF_READ",
00012 "PEEK",
00013 "WRITE",
00014 "WRITE_IF_READ",
00015 "CLEAR",
00016 "GET_MSG_COUNT",
00017 "GET_DIAG_INFO"
00018 };
00019
00020
00021
00022 void
00023 NML_DIAGNOSTICS_INFO::print ()
00024 {
00025 if (NULL != last_writer_dpi)
00026 {
00027 rcs_print ("Last writer = %d (%s)\n", last_writer,
00028 last_writer_dpi->name);
00029 }
00030 if (NULL != last_reader_dpi)
00031 {
00032 rcs_print ("Last reader = %d (%s)\n", last_reader,
00033 last_reader_dpi->name);
00034 }
00035 if (NULL == dpis)
00036 {
00037 return;
00038 }
00039 CMS_DIAG_PROC_INFO *dpi = (CMS_DIAG_PROC_INFO *) dpis->get_head ();
00040 while (NULL != dpi)
00041 {
00042 rcs_print ("\n");
00043 rcs_print ("Info for process %s:\n", dpi->name);
00044 rcs_print ("\t Host and system info: %s\n", dpi->host_sysinfo);
00045 rcs_print ("\t Process Id: %d\n", dpi->pid);
00046 rcs_print ("\t RCS Library Version: %f\n", dpi->rcslib_ver);
00047 if (dpi->access_type >= 0 && dpi->access_type <= 9)
00048 {
00049 rcs_print ("\t Last operation: %d (%s)\n", dpi->access_type,
00050 access_name[dpi->access_type]);
00051 }
00052 rcs_print ("\t msg_id: %d\n", dpi->msg_id);
00053 rcs_print ("\t msg_size: %d\n", dpi->msg_size);
00054 rcs_print ("\t msg_type: %d\n", dpi->msg_type);
00055 rcs_print ("\t number_of_accesses: %d\n", dpi->number_of_accesses);
00056 rcs_print ("\t number_of_new_messages: %d\n",
00057 dpi->number_of_new_messages);
00058 rcs_print ("\t bytes_moved: %f\n", dpi->bytes_moved);
00059 time_t t = 0;
00060 #ifndef VXWORKS
00061 char *ctime_ret = "";
00062 if (dpi->first_access_time > 0.0)
00063 {
00064 t = (time_t) dpi->first_access_time;
00065 ctime_ret = ctime (&t);
00066 if (NULL == ctime_ret)
00067 {
00068 ctime_ret = "";
00069 }
00070 }
00071 rcs_print ("\t first_access_time: %f : %s\n", dpi->first_access_time,
00072 ctime_ret);
00073 ctime_ret = "";
00074 if (dpi->last_access_time > 0.0)
00075 {
00076 t = (time_t) dpi->last_access_time;
00077 ctime_ret = ctime (&t);
00078 if (NULL == ctime_ret)
00079 {
00080 ctime_ret = "";
00081 }
00082 }
00083 rcs_print ("\t last_access_time: %f : %s\n", dpi->last_access_time,
00084 ctime_ret);
00085 #else
00086 rcs_print ("\t first_access_time: %f\n", dpi->first_access_time);
00087 rcs_print ("\t last_access_time: %f\n", dpi->last_access_time);
00088 #endif
00089
00090 if (dpi->max_difference >= dpi->min_difference)
00091 {
00092 rcs_print ("\t Maximum time between accesses: %f\n",
00093 dpi->max_difference);
00094 rcs_print ("\t Minumum time between accesses: %f\n",
00095 dpi->min_difference);
00096 }
00097 double total_time = dpi->last_access_time - dpi->first_access_time;
00098 if (total_time > 0)
00099 {
00100 int h, m, s;
00101 h = ((int) total_time) / 3600;
00102 m = ((int) total_time - h * 60) / 60;
00103 s = ((int) total_time - h * 3600 - m * 60);
00104 rcs_print
00105 ("\t Time between first and last access: %f -- %02.2d:%02.2d:%02.2d\n",
00106 total_time, h, m, s);
00107 if (dpi->number_of_accesses > 0)
00108 {
00109 rcs_print ("\t Average time between accesses: %f\n",
00110 (total_time) / dpi->number_of_accesses);
00111 }
00112 if (dpi->number_of_new_messages > 0)
00113 {
00114 rcs_print ("\t Average time between new messages: %f\n",
00115 (total_time) / dpi->number_of_new_messages);
00116 }
00117 if (dpi->bytes_moved > 0)
00118 {
00119 rcs_print ("\t Average bytes moved per second: %f\n",
00120 dpi->bytes_moved / (total_time));
00121 }
00122 }
00123 if (dpi->bytes_moved > 0 && dpi->number_of_new_messages > 0)
00124 {
00125 rcs_print ("\t Average bytes moved per message: %f\n",
00126 dpi->bytes_moved / (dpi->number_of_new_messages));
00127 }
00128 dpi = (CMS_DIAG_PROC_INFO *) dpis->get_next ();
00129 }
00130 }
00131
00132 int
00133 nml_print_diag_list ()
00134 {
00135 if (NULL != NML_Main_Channel_List)
00136 {
00137 NML *nml = (NML *) NML_Main_Channel_List->get_head ();
00138 while (NULL != nml)
00139 {
00140 if (NULL != nml->cms)
00141 {
00142 if (!nml->cms->enable_diagnostics)
00143 {
00144 nml = (NML *) NML_Main_Channel_List->get_next ();
00145 continue;
00146 }
00147 rcs_print ("\n*********************************************\n");
00148 if (NULL != nml->cms->BufferName)
00149 {
00150 rcs_print ("* Buffer Name: %s\n", nml->cms->BufferName);
00151 }
00152 NML_DIAGNOSTICS_INFO *ndi = nml->get_diagnostics_info ();
00153 if (NULL != ndi)
00154 {
00155 ndi->print ();
00156 }
00157 rcs_print ("*********************************************\n\n");
00158 }
00159 nml = (NML *) NML_Main_Channel_List->get_next ();
00160 }
00161 }
00162 return (0);
00163 }