static int rtems_shell_main_cpuuse( int argc, char *argv[] ) { /* * When invoked with no arguments, print the report. */ if ( argc == 1 ) { rtems_cpu_usage_report_with_plugin(stdout, (rtems_printk_plugin_t)fprintf); return 0; } /* * When invoked with the single argument -r, reset the statistics. */ if ( argc == 2 && !strcmp( argv[1], "-r" ) ) { printf( "Resetting CPU Usage information\n" ); rtems_cpu_usage_reset(); return 0; } /* * OK. The user did something wrong. */ fprintf( stderr, "%s: [-r]\n", argv[0] ); return -1; }
void example_shttpd_callback(struct shttpd_arg *arg) { const char *query; query = shttpd_get_env(arg, "QUERY_STRING" ); if ( !query ) query = ""; /* fprintf( stderr, "RTEMS Request -%s-\n", query ); */ if ( !strcmp( query, "cpuuse_report" ) ) { shttpd_printf( arg, "<pre>" ); rtems_cpu_usage_report_with_plugin( arg, (rtems_printk_plugin_t) shttpd_printf ); shttpd_printf( arg, "</pre>" ); } else if ( !strcmp( query, "cpuuse_reset" ) ) { rtems_cpu_usage_reset(); shttpd_printf( arg, START_HTML_BODY " <p><big>CPU Usage data reset -- return to the previous page</big></p>" END_HTML_BODY ); } else if ( !strcmp( query, "stackuse_report" ) ) { shttpd_printf( arg, "<pre>" ); rtems_stack_checker_report_usage_with_plugin( arg, (rtems_printk_plugin_t) shttpd_printf ); shttpd_printf( arg, "</pre>" ); } else { shttpd_printf( arg, START_HTML_BODY " <h2>Unknown Request</h2>" " <h3>URI: %s</br>" " Arguments: %s</h3>" END_HTML_BODY, shttpd_get_env(arg, "REQUEST_URI"), query ); } arg->flags |= SHTTPD_END_OF_OUTPUT; }
void rtems_cpu_usage_report( void ) { rtems_cpu_usage_report_with_plugin( NULL, printk_plugin ); }