- using prefix instead of full path to statistics file
authorJiří Filipovič <fila@ics.muni.cz>
Fri, 17 Feb 2012 11:48:43 +0000 (11:48 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Fri, 17 Feb 2012 11:48:43 +0000 (11:48 +0000)
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/server_stats.c
org.glite.lb.server/src/server_stats.h

index 8740840..df30841 100644 (file)
@@ -146,7 +146,7 @@ static int                          strict_locking = 0;
 static int                             greyjobs = 0;
 static int                             count_statistics = 1;
 static int                             count_server_stats = 1;
-static char                            *server_stats_file = NULL;
+static char                            *stats_file_prefix = NULL;
 static int                             hardJobsLimit = 0;
 static int                             hardEventsLimit = 0;
 static int                             hardRespSizeLimit = 0;
@@ -219,7 +219,7 @@ static struct option opts[] = {
        {"notif-il-fprefix",    1, NULL,        'Y'},
        {"count-statistics",    1, NULL,        'T'},
        {"count-server-stats",  1, NULL,        'e'},
-        {"server-stats-file",   1, NULL,        'f'},
+        {"statistics-prefix",   1, NULL,        'f'},
        {"request-timeout",     1, NULL,        't'},
 #ifdef LB_PERF
        {"perf-sink",           1, NULL,        'K'},
@@ -285,7 +285,7 @@ static void usage(char *me)
                "\t--count-server-stats=0\t do not count server statistics\n"
                 "\t                    =1\t count server statistics (default)\n"
                 "\t                    =2\t count server statistics, restrict access only to superusers\n"
-                "\t--server-stats-file path to file where server statistics are persistently stored\n"
+                "\t--statistics-prefix statistics persistency files full-path prefix\n"
                "\t-t, --request-timeout\t request timeout for one client\n"
 #ifdef LB_PERF
                "\t-K, --perf-sink\t where to sink events\n"
@@ -488,7 +488,7 @@ int main(int argc, char *argv[])
                          break;
                case 'e': count_server_stats = atoi(optarg);
                           break;
-                case 'f': server_stats_file = strdup(optarg);
+                case 'f': stats_file_prefix = strdup(optarg);
                           break;
                case 't': request_timeout = atoi(optarg);
                          break;
@@ -809,7 +809,7 @@ int main(int argc, char *argv[])
 
        if (count_statistics) edg_wll_InitStatistics(ctx);
 
-       if (count_server_stats) edg_wll_InitServerStatistics(ctx, server_stats_file);
+       if (count_server_stats) edg_wll_InitServerStatistics(ctx, stats_file_prefix);
 
        edg_wll_FreeContext(ctx);
 
index 79fa7be..fdb0612 100644 (file)
@@ -16,29 +16,27 @@ static int serverStatisticsFD;
 static int stats_in_tmp = 0;
 static int msync_counter = 0;
 
-int edg_wll_InitServerStatistics(edg_wll_Context ctx, char *file)
+int edg_wll_InitServerStatistics(edg_wll_Context ctx, char *prefix)
 {
        //TODO get file name from command line
         char *fname;
-       char *lblocenv = NULL;
-       if (file)
-               asprintf(&fname, "%s", file);
-       else{
-               
-               if (! (lblocenv = getenv("GLITE_LB_LOCATION_VAR"))) {
+/*     if (prefix)
+               asprintf(&fname, "%s/lb_server_stats", file);
+       else{*/
+       if (! prefix){
+               if (! (prefix = getenv("GLITE_LB_LOCATION_VAR"))) {
                        struct stat info;
                        if (stat("/var/glite", &info) == 0 && S_ISDIR(info.st_mode))
-                               asprintf(&fname, "/var/glite/lb_server_stats");
+                               asprintf(&prefix, "/var/glite/");
                        else {
-                               asprintf(&fname, "/tmp/lb_server_stats");
+                               asprintf(&prefix, "/tmp/");
                                stats_in_tmp = 1;
                        }
                        glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_INFO,
-                        "server stats file not configured, using default %s", fname);
+                        "server stats file not configured, using default %s/lb_server_stats", prefix);
                }
-               else
-                       asprintf(&fname, "%s/lb_server_stats", lblocenv);
        }
+       asprintf(&fname, "%s/lb_server_stats", prefix);
        serverStatisticsFD = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
        if (serverStatisticsFD < 0){
                serverStatisticsFD = open("/tmp/lb_server_stats", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
index b0a2359..d05c4f6 100644 (file)
@@ -33,7 +33,7 @@ enum edg_wll_server_statistics_type{
        SERVER_STATS_LBPROTO
 };
 
-int edg_wll_InitServerStatistics(edg_wll_Context ctx, char *file);
+int edg_wll_InitServerStatistics(edg_wll_Context ctx, char *prefix);
 
 int edg_wll_ServerStatisticsIncrement(edg_wll_Context ctx, enum edg_wll_server_statistics_type type);
 int edg_wll_ServerStatisticsGetValue(edg_wll_Context ctx, enum edg_wll_server_statistics_type type);