home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / server / perf-update.sm < prev    next >
Text File  |  2008-02-11  |  2KB  |  122 lines

  1. /* 
  2.  * (C) 2001 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <unistd.h>
  11. #include <fcntl.h>
  12. #include <sys/time.h>
  13.  
  14. #include "pvfs2-server.h"
  15. #include "pint-perf-counter.h"
  16. #include "server-config.h"
  17.  
  18. %%
  19.  
  20. machine pvfs2_perf_update_sm
  21. {
  22.     state do_work 
  23.     {
  24.         run perf_update_do_work;
  25.         success => do_work;
  26.         default => error;
  27.     }
  28.  
  29.     state error 
  30.     {
  31.         run perf_update_error;
  32.         default => terminate;
  33.     }
  34. }
  35.  
  36. %%
  37.  
  38. /* perf_update_error()
  39.  *
  40.  * cleans up any resources consumed by this state machine and ends
  41.  * execution of the machine
  42.  */
  43. static PINT_sm_action perf_update_error(
  44.         struct PINT_smcb *smcb, job_status_s *js_p)
  45. {
  46.     gossip_err("Error: stopping server performance monitoring.\n");
  47.  
  48.     PINT_perf_finalize(PINT_server_pc);
  49.  
  50.     return(server_state_machine_complete(smcb));
  51. }
  52.  
  53. /* perf_update_do_work()
  54.  *
  55.  * resets counters, updates metrices, etc- this is intended to be called
  56.  * repeatedly on a regular interval
  57.  */
  58. static PINT_sm_action perf_update_do_work(
  59.         struct PINT_smcb *smcb, job_status_s *js_p)
  60. {
  61.     job_id_t tmp_id;
  62.     uint64_t current_mask = 0;
  63.     int current_debug_on = 0;
  64.     char* tmp_text;
  65.     char* ptr;
  66.     char* token;
  67.     char delim[] = "\n";
  68.     struct server_configuration_s *user_opts = get_server_config_struct();
  69.  
  70. #if 0
  71.     PINT_STATE_DEBUG("do_work");
  72. #endif
  73.     
  74.     /* log current statistics if the gossip mask permits */
  75.     gossip_get_debug_mask(¤t_debug_on, ¤t_mask);
  76.     if(current_mask & GOSSIP_PERFCOUNTER_DEBUG)
  77.     {
  78.         tmp_text = PINT_perf_generate_text(PINT_server_pc, 4096);
  79.         if(tmp_text)
  80.         {
  81.             token = strtok_r(tmp_text, delim, &ptr);
  82.             while(token)
  83.             {
  84.                 gossip_perf_log("%s\n", token);
  85.                 token = strtok_r(NULL, delim, &ptr);
  86.             }
  87.             free(tmp_text);
  88.         }
  89.     }
  90.     
  91.     /* roll over to next set of statistics */
  92.     PINT_perf_rollover(PINT_server_pc);
  93.     
  94.     /* post another timer */
  95.     return(job_req_sched_post_timer(user_opts->perf_update_interval,
  96.     smcb,
  97.     0,
  98.     js_p,
  99.     &tmp_id,
  100.     server_job_context));
  101. }
  102.  
  103. struct PINT_server_req_params pvfs2_perf_update_params =
  104. {
  105.     .string_name = "perf_update",
  106.     .state_machine = &pvfs2_perf_update_sm
  107. };
  108.  
  109.  
  110.  
  111.  
  112. /*
  113.  * Local variables:
  114.  *  mode: c
  115.  *  c-indent-level: 4
  116.  *  c-basic-offset: 4
  117.  * End:
  118.  *
  119.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  120.  */
  121.  
  122.