lb_xml_parse_V21.o lb_text.o \
openserver.o query.o userjobs.o db_store.o request.o store.o \
stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \
- notification.o il_notification.o notif_match.o stats.o db_calls.o db_supp.o lb_rss.o pretty_print_wrapper.o \
+ notification.o il_notification.o notif_match.o stats.o server_stats.o db_calls.o db_supp.o lb_rss.o pretty_print_wrapper.o \
policy_gram.o policy_lex.o authz_policy.o crypto.o
gsoap_version ?= ${gsoap_default_version}
INDEX_OBJS:= index.o index_parse.o jobstat_supp.o openserver.o \
jobstat.o query.o get_events.o write2rgma.o index_lex.o \
- lb_authz.o store.o bkindex.o stats.o\
+ lb_authz.o store.o bkindex.o stats.o server_stats.o\
request.o db_store.o srv_purge.o notif_match.o il_lbproxy.o dump.o lb_xml_parse.o il_notification.o lb_proto.o lb_text.o server_state.o lb_xml_parse_V21.o lb_html.o cond_dump.o notification.o seqcode.o userjobs.o load.o db_calls.o db_supp.o lb_rss.o pretty_print_wrapper.o authz_policy.o crypto.o
INDEX_LIBS:= ${SRVBONES_LIB} ${COMMON_LIBS} ${LB_MACHINE_LIB} ${EXT_LIBS} ${LB_UTILS_DB_LIB}
lb_xml_parse_V21.o lb_text.o \
openserver.o query.o userjobs.o db_store.o request.o store.o \
stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \
- notification.o il_notification.o notif_match.o stats.o write2rgma.o \
+ notification.o il_notification.o notif_match.o stats.o server_stats.o write2rgma.o \
db_calls.o db_supp.o lb_rss.o pretty_print_wrapper.o authz_policy.o \
crypto.o
#include "lb_authz.h"
#include "il_notification.h"
#include "stats.h"
+#include "server_stats.h"
#include "db_calls.h"
#include "db_supp.h"
#include "openserver.h"
static int noAuth = 0;
static int noIndex = 0;
static int strict_locking = 0;
-static int greyjobs = 0;
-static int count_statistics = 1;
+static int greyjobs = 0;
+static int count_statistics = 1;
+static int count_server_stats = 1;
+static char *server_stats_file = NULL;
static int hardJobsLimit = 0;
static int hardEventsLimit = 0;
static int hardRespSizeLimit = 0;
{"notif-il-sock", 1, NULL, 'X'},
{"notif-il-fprefix", 1, NULL, 'Y'},
{"count-statistics", 1, NULL, 'T'},
+ {"count-server-stats", 1, NULL, 'e'},
+ {"server-stats-file", 1, NULL, 'f'},
{"request-timeout", 1, NULL, 't'},
#ifdef LB_PERF
{"perf-sink", 1, NULL, 'K'},
{NULL,0,NULL,0}
};
-static const char *get_opt_string = "Ac:k:C:V:p:a:drm:ns:i:S:D:J:jR:F:xOL:N:X:Y:T:t:zb:gPBo:q:W:Z:GI:l:E"
+static const char *get_opt_string = "Ac:k:C:V:p:a:drm:ns:i:S:D:J:jR:F:xOL:N:X:Y:T:t:e:f:zb:gPBo:q:W:Z:GI:l:E"
#ifdef GLITE_LB_SERVER_WITH_WS
"w:"
#endif
"\t--notif-il-fprefix\t file prefix for notifications\n"
"\t--count-statistics=1\t count certain statistics on jobs\n"
"\t =2\t ... and allow anonymous access\n"
+ "\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-t, --request-timeout\t request timeout for one client\n"
#ifdef LB_PERF
"\t-K, --perf-sink\t where to sink events\n"
break;
case 'T': count_statistics = atoi(optarg);
break;
+ case 'e': count_server_stats = atoi(optarg);
+ break;
+ case 'f': server_stats_file = strdup(optarg);
+ break;
case 't': request_timeout = atoi(optarg);
break;
#ifdef LB_PERF
use_dbcaps = ctx->dbcaps;
if (count_statistics) edg_wll_InitStatistics(ctx);
+
+ if (count_server_stats) edg_wll_InitServerStatistics(ctx, server_stats_file);
+
edg_wll_FreeContext(ctx);
if ( !debug ) {
ctx->processRequest_cb = NULL;
}
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_WS_QUERIES);
+
return ENOTCONN;
}
#endif /* GLITE_LB_SERVER_WITH_WS */
#include "db_supp.h"
#include "db_calls.h"
#include "authz_policy.h"
+#include "server_stats.h"
#define DAG_ENABLE 1
if ((!maxts.tv_sec && !maxts.tv_usec)
|| (ts.tv_sec > maxts.tv_sec)
|| (ts.tv_sec == maxts.tv_sec && ts.tv_usec > maxts.tv_usec)) maxts = ts;
+ // event has been processed by state machine, refresh statistics
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_JOB_EVENTS);
+ // check if this is job registration (counted only here)
+ if (events[i].type == EDG_WLL_EVENT_REGJOB){
+ switch (intstat->pub.jobtype) {
+ case EDG_WLL_STAT_SIMPLE:
+ case EDG_WLL_STAT_DAG:
+ case EDG_WLL_STAT_COLLECTION:
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_GLITEJOB_REGS);
+ break;
+ case EDG_WLL_STAT_PBS:
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_PBSJOB_REGS);
+ break;
+ case EDG_WLL_STAT_CONDOR:
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_CONDOR_REGS);
+ break;
+ case EDG_WLL_STAT_CREAM:
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_CREAM_REGS);
+ break;
+ case EDG_WLL_STAT_FILE_TRANSFER:
+ case EDG_WLL_STAT_FILE_TRANSFER_COLLECTION:
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_SANDBOX_REGS);
+ break;
+ default:
+ glite_common_log(LOG_CATEGORY_LB_SERVER_REQUEST, LOG_PRIORITY_DEBUG, "Unknown job type, registration will not be counted in statistics.");
+ break;
+ }
+ }
}
/* no events or status computation error */
if (intJobStat_to_JobStat(intstat)->state == EDG_WLL_JOB_UNDEF) {
edg_wll_UpdateStatistics(ctx, oldstat, e, intJobStat_to_JobStat(ijsp));
+ // event has been processed by state machine, refresh statistics
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_JOB_EVENTS);
+
if (ctx->rgma_export) write2rgma_chgstatus(ijsp, oldstat_rgmaline);
if (stat_out) {
edg_wll_UpdateStatistics(ctx, oldstat, e, intJobStat_to_JobStat(ijsp));
+ // event has been processed by state machine, refresh statistics
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_JOB_EVENTS);
+
/* check whether subjob state change does not change parent state */
if ((intJobStat_to_JobStat(ijsp)->parent_job)
&& (oldstat->state != intJobStat_to_JobStat(ijsp)->state)) {
#include "lb_proto.h"
#include "cond_dump.h"
#include "pretty_print_wrapper.h"
+#include "server_stats.h"
+#include "authz_policy.h"
#include "glite/lb/context-int.h"
#include "glite/lb/xml_conversions.h"
return 0;
}
+int edg_wll_StatisticsToHTML(edg_wll_Context ctx, char **message) {
+ char *out;
+
+ struct _edg_wll_GssPrincipal_data princ;
+ memset(&princ, 0, sizeof princ);
+ princ.name = ctx->peerName;
+ princ.fqans = ctx->fqans;
+ if (ctx->count_server_stats == 2 && !ctx->noAuth && !check_authz_policy(&ctx->authz_policy, &princ, ADMIN_ACCESS))
+ {
+ asprintf(&out,"<h2>LB Server Usage Statistics</h2>\n"
+ "Only superusers can view server usage statistics on this particular server.\n");
+ }
+ else
+ {
+ char* times[SERVER_STATISTICS_COUNT];
+ int i;
+ for (i = 0; i < SERVER_STATISTICS_COUNT; i++)
+ if (edg_wll_ServerStatisticsGetStart(ctx, i))
+ times[i] = strdup((const char*)ctime(edg_wll_ServerStatisticsGetStart(ctx, i)));
+ else
+ times[i] = 0;
+
+ asprintf(&out,
+ "<h2>LB Server Usage Statistics</h2>\n"
+ "<table halign=\"left\">\n"
+ "<tr><td>Variable</td><td>Value</td><td>Measured from</td></tr>\n"
+ "<tr><td>gLite job regs</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>PBS job regs</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Condor job regs</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>CREAM job regs</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Sandbox regs</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Notification regs (legacy interface)</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Notification regs (msg interface)</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Job events</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Notifications sent (legacy)</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Notifications sent (msg)</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>L&B protocol accesses</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>WS queries</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>HTML accesses</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>Plain text accesses</td><td>%i</td><td>%s</td></tr>\n"
+ "<tr><td>RSS accesses</td><td>%i</td><td>%s</td></tr>\n"
+ "</table>\n",
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_GLITEJOB_REGS),
+ times[SERVER_STATS_GLITEJOB_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_PBSJOB_REGS),
+ times[SERVER_STATS_PBSJOB_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_CONDOR_REGS),
+ times[SERVER_STATS_CONDOR_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_CREAM_REGS),
+ times[SERVER_STATS_CREAM_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_SANDBOX_REGS),
+ times[SERVER_STATS_SANDBOX_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_NOTIF_LEGACY_REGS),
+ times[SERVER_STATS_NOTIF_LEGACY_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_NOTIF_MSG_REGS),
+ times[SERVER_STATS_NOTIF_MSG_REGS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_JOB_EVENTS),
+ times[SERVER_STATS_JOB_EVENTS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_NOTIF_LEGACY_SENT),
+ times[SERVER_STATS_NOTIF_LEGACY_SENT],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_NOTIF_MSG_SENT),
+ times[SERVER_STATS_NOTIF_MSG_SENT],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_LBPROTO),
+ times[SERVER_STATS_LBPROTO],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_WS_QUERIES),
+ times[SERVER_STATS_WS_QUERIES],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_HTML_VIEWS),
+ times[SERVER_STATS_HTML_VIEWS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_TEXT_VIEWS),
+ times[SERVER_STATS_TEXT_VIEWS],
+ edg_wll_ServerStatisticsGetValue(ctx, SERVER_STATS_RSS_VIEWS),
+ times[SERVER_STATS_RSS_VIEWS]
+ );
+
+ for (i = 0; i < SERVER_STATISTICS_COUNT; i++)
+ free(times[i]);
+ }
+
+ *message = out;
+}
+
char *edg_wll_ErrorToHTML(edg_wll_Context ctx,int code)
{
char *out,*et,*ed;
int edg_wll_NotificationToHTML(edg_wll_Context ctx, notifInfo *ni, char **message);
char *edg_wll_ErrorToHTML(edg_wll_Context,int);
int edg_wll_FileTransferStatusToHTML(edg_wll_Context ctx, edg_wll_JobStat stat, char **message);
+int edg_wll_StatisticsToHTML(edg_wll_Context ctx, char **message);
#endif /* GLITE_LB_HTML_H */
#include "lb_html.h"
#include "lb_rss.h"
#include "stats.h"
+#include "server_stats.h"
#include "jobstat.h"
#include "get_events.h"
#include "purge.h"
flags = (requestPTR[1]=='?') ? edg_wll_string_to_stat_flags(requestPTR + 2) : 0;
switch (edg_wll_UserJobsServer(ctx, EDG_WLL_STAT_CHILDREN, &jobsOut, &statesOut)) {
- case 0: if (text)
+ case 0: if (text){
edg_wll_UserInfoToText(ctx, jobsOut, &message);
- else if (html)
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
+ }
+ else if (html){
edg_wll_UserInfoToHTML(ctx, jobsOut, statesOut, &message);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_HTML_VIEWS);
+ }
else ret = HTTP_OK;
break;
case ENOENT: ret = HTTP_NOTFOUND; break;
ret = HTTP_BADREQ;
}
else switch (edg_wll_JobStatusServer(ctx,jobId,EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN,&stat)) {
- case 0: if (text)
+ case 0: if (text) {
edg_wll_JobStatusToText(ctx,stat,&message);
- else if (html)
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
+ }
+ else if (html) {
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_HTML_VIEWS);
switch(stat.jobtype){
case EDG_WLL_STAT_CREAM:
edg_wll_CreamJobStatusToHTML(ctx,stat,&message);
edg_wll_GeneralJobStatusToHTML(ctx,stat,&message);
break;
}
+ }
else ret = HTTP_OK;
break;
char *userid = strmd5(can_peername, NULL);
getUserNotifications(ctx, userid, ¬ifids);
free(can_peername);
- if (text)
+ if (text) {
edg_wll_UserNotifsToText(ctx, notifids, &message);
- else if (html)
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
+ }
+ else if (html) {
edg_wll_UserNotifsToHTML(ctx, notifids, &message);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_HTML_VIEWS);
+ }
else ret = HTTP_OK;
/*GET /NOTIF:[notifId]: Notification info*/
}
free(pomCopy);
- if (text)
+ if (text) {
edg_wll_NotificationToText(ctx, &ni, &message);
- else
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
+ }
+ else {
edg_wll_NotificationToHTML(ctx, &ni, &message);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_HTML_VIEWS);
+ }
freeNotifInfo(&ni);
ret = HTTP_NOTFOUND;
edg_wll_SetError(ctx, ENOENT, "current index configuration does not support RSS feeds");
}
- else
+ else {
edg_wll_RSSFeed(ctx, states, requestPTR, &message);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_RSS_VIEWS);
+ }
/*GET /?wsdl */
#define WSDL_LB "LB.wsdl"
#define WSDL_LBTYPES "LBTypes.wsdl"
#define WSDL_LB4AGU "lb4agu.wsdl"
} else if (strncmp(requestPTR, "/?wsdl", strlen("/?wsdl")) == 0) {
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
char *filename;
asprintf(&filename, "%s/" WSDL_PATH "/%s", glite_location(), WSDL_LB);
if (edg_wll_WSDLOutput(ctx, &message, filename))
free(filename);
/* GET /?types */
} else if (strncmp(requestPTR, "/?types", strlen("/?types")) == 0) {
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
char *filename;
asprintf(&filename, "%s/" WSDL_PATH "/%s", glite_location(), WSDL_LBTYPES);
if (edg_wll_WSDLOutput(ctx, &message, filename))
free(filename);
/* GET /?agu */
} else if (strncmp(requestPTR, "/?agu", strlen("/?agu")) == 0) {
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
char *filename;
asprintf(&filename, "%s/" WSDL_PATH "/%s", glite_location(), WSDL_LB4AGU);
if (edg_wll_WSDLOutput(ctx, &message, filename))
free(filename);
/* GET /?version */
} else if (strncmp(requestPTR, "/?version", strlen("/?version")) == 0) {
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
asprintf(&message, "%s", VERSION);
/* GET /?configuration*/
} else if (strncmp(requestPTR, "/?configuration", strlen("/?configuration")) == 0) {
// also browser-readable HTML version here?
edg_wll_ConfigurationToText(ctx, &message);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_TEXT_VIEWS);
+ /* GET /?stats*/
+ } else if (strncmp(requestPTR, "/?stats", strlen("/?stats")) == 0) {
+ edg_wll_StatisticsToHTML(ctx, &message);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_HTML_VIEWS);
/* GET [something else]: not understood */
} else ret = HTTP_BADREQ;
free(requestPTR); requestPTR = NULL;
/* POST [something else]: not understood */
else ret = HTTP_BADREQ;
+ if (ret != HTTP_BADREQ)
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_LBPROTO);
+
free(requestPTR); requestPTR = NULL;
/* other HTTP methods */
#include "index.h"
#include "authz_policy.h"
#include "get_events.h"
+#include "server_stats.h"
static int notif_match_conditions(edg_wll_Context,const edg_wll_JobStat *,const edg_wll_JobStat *,const char *, int flags);
static edg_wll_Event* fetch_history(edg_wll_Context ctx, edg_wll_JobStat *stat);
goto err;
}
}
+
+ if (! strncmp(jobc[1], "x-msg", 5))
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_NOTIF_MSG_SENT);
+ else
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_NOTIF_LEGACY_SENT);
for (i=0; i<sizeof(jobc)/sizeof(jobc[0]); i++) free(jobc[i]);
}
#include "index.h"
#include "lb_xml_parse.h"
#include "get_events.h"
+#include "server_stats.h"
typedef struct {
free(prefmsg);
goto cleanup;
}
+
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_NOTIF_MSG_REGS);
}
+ else
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_NOTIF_LEGACY_REGS);
if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ||
!strncmp(address_override, "[::]", aux-address_override) ||
#include "glite/lbu/log.h"
#include "store.h"
+#include "server_stats.h"
#ifdef LB_PERF
#include "srv_perf.h"
{
glite_common_log_msg(LOG_CATEGORY_LB_SERVER_REQUEST, LOG_PRIORITY_DEBUG, buf);
handle_il_message(ctx, buf);
+ edg_wll_ServerStatisticsIncrement(ctx, SERVER_STATS_LBPROTO);
}
free(buf);