public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: teigland@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.06-46-g599cc32 Date: Tue, 22 Jul 2008 20:24:00 -0000 [thread overview] Message-ID: <20080722202451.13331.qmail@sourceware.org> (raw) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=599cc3275d45e4f69d2cc8d47cc02196ca3dd8bf The branch, master has been updated via 599cc3275d45e4f69d2cc8d47cc02196ca3dd8bf (commit) from a4abbf1dbfd3287ae70f3177d7d878919d80373b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 599cc3275d45e4f69d2cc8d47cc02196ca3dd8bf Author: David Teigland <teigland@redhat.com> Date: Tue Jul 22 15:16:56 2008 -0500 groupd: use logsys Add logsys usage and configuration, following fenced pattern. Signed-off-by: David Teigland <teigland@redhat.com> ----------------------------------------------------------------------- Summary of changes: group/daemon/Makefile | 5 +- group/daemon/gd_internal.h | 29 +++++++++-- {fence/fenced => group/daemon}/logging.c | 9 ++-- group/daemon/main.c | 81 ++++++++++++++++++++++++++++- 4 files changed, 110 insertions(+), 14 deletions(-) copy {fence/fenced => group/daemon}/logging.c (96%) diff --git a/group/daemon/Makefile b/group/daemon/Makefile index df75bc6..eea0b93 100644 --- a/group/daemon/Makefile +++ b/group/daemon/Makefile @@ -14,13 +14,14 @@ OBJS= app.o \ cpg.o \ cman.o \ joinleave.o \ - main.o + main.o \ + logging.o CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${openaisincdir} CFLAGS += -I$(S) -I$(S)/../include/ -I$(S)/../lib/ CFLAGS += -I${incdir} -LDFLAGS += -L${ccslibdir} -lccs +LDFLAGS += -L${ccslibdir} -lccs -llogsys LDFLAGS += -L${cmanlibdir} -L${openaislibdir} -L${libdir} -lcman -lcpg diff --git a/group/daemon/gd_internal.h b/group/daemon/gd_internal.h index 3c8bddf..59f765b 100644 --- a/group/daemon/gd_internal.h +++ b/group/daemon/gd_internal.h @@ -22,6 +22,7 @@ #include <sys/stat.h> #include <sys/wait.h> #include <openais/cpg.h> +#include <openais/service/logsys.h> #include "list.h" #include "linux_endian.h" @@ -46,33 +47,44 @@ extern struct list_head gd_groups; extern struct list_head gd_levels[MAX_LEVELS]; extern uint32_t gd_event_nr; +#define DEFAULT_DEBUG_LOGSYS 0 + +extern int optd_debug_logsys; +extern int cfgd_debug_logsys; + void daemon_dump_save(void); #define log_debug(fmt, args...) \ do { \ snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \ - if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \ daemon_dump_save(); \ + if (daemon_debug_opt) \ + fprintf(stderr, "%s", daemon_debug_buf); \ + if (cfgd_debug_logsys) \ + log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \ } while (0) #define log_group(g, fmt, args...) \ do { \ snprintf(daemon_debug_buf, 255, "%ld %d:%s " fmt "\n", time(NULL), \ (g)->level, (g)->name, ##args); \ - if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \ daemon_dump_save(); \ + if (daemon_debug_opt) \ + fprintf(stderr, "%s", daemon_debug_buf); \ + if (cfgd_debug_logsys) \ + log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \ } while (0) #define log_print(fmt, args...) \ do { \ log_debug(fmt, ##args); \ - syslog(LOG_ERR, fmt, ##args); \ + log_printf(LOG_ERR, fmt, ##args); \ } while (0) #define log_error(g, fmt, args...) \ do { \ log_group(g, fmt, ##args); \ - syslog(LOG_ERR, fmt, ##args); \ + log_printf(LOG_ERR, fmt, ##args); \ } while (0) #define ASSERT(x) \ @@ -247,6 +259,9 @@ int is_our_join(event_t *ev); void purge_node_messages(group_t *g, int nodeid); /* main.c */ +void read_ccs_name(char *path, char *name); +void read_ccs_yesno(char *path, int *yes, int *no); +void read_ccs_int(char *path, int *config_val); void app_stop(app_t *a); void app_setid(app_t *a); void app_start(app_t *a); @@ -280,5 +295,11 @@ int do_leave(char *name, int level); node_t *new_node(int nodeid); group_t *find_group_level(char *name, int level); +/* logging.c */ + +void init_logging(void); +void setup_logging(); +void close_logging(void); + #endif /* __GD_INTERNAL_DOT_H__ */ diff --git a/fence/fenced/logging.c b/group/daemon/logging.c similarity index 96% copy from fence/fenced/logging.c copy to group/daemon/logging.c index fc5f11c..7b3e349 100644 --- a/fence/fenced/logging.c +++ b/group/daemon/logging.c @@ -1,7 +1,6 @@ -#include "fd.h" -#include "config.h" +#include "gd_internal.h" -#define DAEMON_NAME "fenced" +#define DAEMON_NAME "groupd" /* default: errors go to syslog (/var/log/messages) and <daemon>.log logging/debug=on: errors continue going to syslog (/var/log/messages) @@ -15,8 +14,8 @@ #define DEFAULT_PRIORITY SYSLOGLEVEL /* cluster config setting */ #define DEFAULT_FILE LOGDIR "/" DAEMON_NAME ".log" -#define DAEMON_LEVEL_PATH "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@syslog_level" -#define DAEMON_DEBUG_PATH "/cluster/logging/logger_subsys[@subsys=\"FENCED\"]/@debug" +#define DAEMON_LEVEL_PATH "/cluster/logging/logger_subsys[@subsys=\"GROUPD\"]/@syslog_level" +#define DAEMON_DEBUG_PATH "/cluster/logging/logger_subsys[@subsys=\"GROUPD\"]/@debug" /* Read cluster.conf settings and convert them into logsys values. If no cluster.conf setting exists, the default that was used in diff --git a/group/daemon/main.c b/group/daemon/main.c index 11a7ed8..1f0cf08 100644 --- a/group/daemon/main.c +++ b/group/daemon/main.c @@ -3,6 +3,7 @@ #include "gd_internal.h" #include "ccs.h" +#include "copyright.cf" #define LOCKFILE_NAME "/var/run/groupd.pid" #define CLIENT_NALLOC 32 @@ -62,6 +63,63 @@ static int do_write(int fd, void *buf, size_t count) return 0; } +void read_ccs_name(char *path, char *name) +{ + char *str; + int error; + + error = ccs_get(ccs_handle, path, &str); + if (error || !str) + return; + + strcpy(name, str); + + free(str); +} + +void read_ccs_yesno(char *path, int *yes, int *no) +{ + char *str; + int error; + + *yes = 0; + *no = 0; + + error = ccs_get(ccs_handle, path, &str); + if (error || !str) + return; + + if (!strcmp(str, "yes")) + *yes = 1; + + else if (!strcmp(str, "no")) + *no = 1; + + free(str); +} + +void read_ccs_int(char *path, int *config_val) +{ + char *str; + int val; + int error; + + error = ccs_get(ccs_handle, path, &str); + if (error || !str) + return; + + val = atoi(str); + + if (val < 0) { + log_print("ignore invalid value %d for %s", val, path); + return; + } + + *config_val = val; + log_debug("%s is %u", path, val); + free(str); +} + int setup_ccs(void) { int i = 0, cd; @@ -749,6 +807,8 @@ static void loop(void) if (rv < 0) goto out; + setup_logging(); + rv = check_uncontrolled_groups(); if (rv < 0) goto out; @@ -853,11 +913,12 @@ static void print_usage(void) printf("Options:\n"); printf("\n"); printf(" -D Enable debugging code and don't fork\n"); + printf(" -L <num> Enable (1) or disable (0) debugging to logsys (default %d)\n", DEFAULT_DEBUG_LOGSYS); printf(" -h Print this help, then exit\n"); printf(" -V Print program version information, then exit\n"); } -#define OPTION_STRING "DhVv" +#define OPTION_STRING "L:DhVv" static void read_arguments(int argc, char **argv) { @@ -873,6 +934,11 @@ static void read_arguments(int argc, char **argv) daemon_debug_opt = 1; break; + case 'L': + optd_debug_logsys = 1; + cfgd_debug_logsys = atoi(optarg); + break; + case 'h': print_usage(); exit(EXIT_SUCCESS); @@ -885,7 +951,7 @@ static void read_arguments(int argc, char **argv) case 'V': printf("groupd %s (built %s %s)\n", RELEASE_VERSION, __DATE__, __TIME__); - /* printf("%s\n", REDHAT_COPYRIGHT); */ + printf("%s\n", REDHAT_COPYRIGHT); exit(EXIT_SUCCESS); break; @@ -905,6 +971,11 @@ static void read_arguments(int argc, char **argv) break; }; } + + if (!optd_debug_logsys && getenv("GROUPD_DEBUG")) { + optd_debug_logsys = 1; + cfgd_debug_logsys = atoi(getenv("GROUPD_DEBUG")); + } } static void set_oom_adj(int val) @@ -946,6 +1017,8 @@ int main(int argc, char *argv[]) for (i = 0; i < MAX_LEVELS; i++) INIT_LIST_HEAD(&gd_levels[i]); + init_logging(); + read_arguments(argc, argv); lockfile(); @@ -956,7 +1029,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } } - openlog("groupd", LOG_PID, LOG_DAEMON); signal(SIGTERM, sigterm_handler); set_scheduler(); @@ -997,3 +1069,6 @@ struct list_head gd_groups; struct list_head gd_levels[MAX_LEVELS]; uint32_t gd_event_nr; +int optd_debug_logsys; +int cfgd_debug_logsys = DEFAULT_DEBUG_LOGSYS; + hooks/post-receive -- Cluster Project
reply other threads:[~2008-07-22 20:24 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080722202451.13331.qmail@sourceware.org \ --to=teigland@sourceware.org \ --cc=cluster-cvs@sources.redhat.com \ --cc=cluster-devel@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).