1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
38
#include "uti/sge_stdio.h"
39
#include "sge_all_listsL.h"
40
#include "schedd_monitor.h"
42
#include "cull_parse_util.h"
44
#include "sge_answer.h"
45
#include "uti/sge_string.h"
47
#include "msg_common.h"
50
static bool monitor_next_run = false;
51
static char log_string[2048 + 1] = "invalid log_string";
52
static char schedd_log_file[SGE_PATH_MAX + 1] = "";
54
/* if set we do not log into schedd log file but we fill up this answer list */
55
static lList **monitor_alpp = NULL;
57
void schedd_set_schedd_log_file(sge_gdi_ctx_class_t *ctx)
59
const char *cell_root = ctx->get_cell_root(ctx);
61
DENTER(TOP_LAYER, "schedd_set_schedd_log_file");
63
if (!*schedd_log_file) {
64
snprintf(schedd_log_file, sizeof(schedd_log_file), "%s/%s/%s", cell_root, "common", SCHED_LOG_NAME);
65
DPRINTF(("schedd log file >>%s<<\n", schedd_log_file));
71
bool schedd_is_monitor_next_run(void)
73
return monitor_next_run;
76
void schedd_set_monitor_next_run(bool set)
78
monitor_next_run = set;
81
char* schedd_get_log_string(void)
86
void clean_monitor_alp()
88
lFreeList(monitor_alpp);
91
void set_monitor_alpp(lList **alpp) {
93
monitor_next_run = (alpp!=NULL)?true:false;
96
int schedd_log(const char *logstr)
98
DENTER(TOP_LAYER, "schedd_log");
100
if (!monitor_next_run) {
106
char logloglog[2048];
107
/* DPRINTF(("schedd_log: %s\n", logstr)); */
108
sprintf(logloglog, "%s", logstr);
109
answer_list_add(monitor_alpp, logloglog, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
114
char *time_str = NULL;
117
now = (time_t)sge_get_gmt();
118
time_str = ctime_r(&now, str);
119
if (time_str[strlen(time_str) - 1] == '\n') {
120
time_str[strlen(time_str) - 1] = '|';
123
fp = fopen(schedd_log_file, "a");
125
DPRINTF(("could not open schedd_log_file "SFQ"\n", schedd_log_file));
130
fprintf(fp, "%s", time_str);
131
fprintf(fp, "%s\n", logstr);
138
DPRINTF((MSG_FILE_ERRORCLOSEINGXY_SS, schedd_log_file, strerror(errno)));
144
#define NUM_ITEMS_ON_LINE 10
146
int schedd_log_list(const char *logstr, lList *lp, int nm) {
147
int fields[] = { 0, 0 };
148
const char *delis[] = {NULL, " ", NULL};
149
lList *lp_part = NULL;
150
lListElem *ep = NULL;
152
DENTER(TOP_LAYER, "schedd_log_list");
156
if (!monitor_next_run) {
165
lp_part = lCreateList("partial list", lGetListDescr(lp));
167
lAppendElem(lp_part, lCopyElem(ep));
168
if ((lGetNumberOfElem(lp_part) == NUM_ITEMS_ON_LINE) || !lNext(ep)) {
169
strcpy(log_string, logstr);
172
log_string + strlen(log_string),
173
sizeof(log_string) - strlen(log_string) - 1,
177
schedd_log(log_string);
183
DPRINTF(("schedd_log_list does nothing for QMonNT !!!\n"));
191
const char *job_descr(
194
static char descr[20];
197
sprintf(descr, "Job "sge_u32, jobid);