FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 01-05-2012, 04:25 AM
Lon Hohberger
 
Default rgmanager: Add extra service status call (RHEL5)

Pass the flags and last transition time back to caller
if the caller requests it with an additional parameter.

Resolves: rhbz#743214

Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/daemons/slang_event.c | 105 +++++++++++++++++++++++++++++++++--
1 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index 468706f..c9cca7a 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -30,6 +30,7 @@

#include <stdio.h>
#include <string.h>
+#define HAVE_LONG_LONG 1
#include <slang.h>
#include <sys/syslog.h>
#include <malloc.h>
@@ -229,14 +230,68 @@ get_service_state_internal(char *svcName, rg_state_t *svcStatus)


/*
- (restarts, last_owner, owner, state) = get_service_status(servicename)
+ (rte, restarts, last_owner, owner, state) =
+ service_status(servicename)
+
+For extra information (flags, transition time)
+ (transition_time, flags, rte, restarts, owner, state) =
+ service_status(servicename, 1);
*/
-void
-sl_service_status(char *svcName)
+static void
+sl_service_status(void)
{
+ char *svcName = NULL;
+ char *state_str;
rg_state_t svcStatus;
int restarts_exceeded = 0;
- char *state_str;
+ int nargs = 0, t = 0, extra = 0, flags = 0;
+ unsigned long long mtime;
+
+ nargs = SLang_Num_Function_Args;
+
+ /* Takes one or two args */
+ if (nargs <= 0 || nargs > 2) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Wrong # of args (%d), must be 1 or 2
",
+ __FUNCTION__,
+ nargs);
+ return;
+ }
+
+ if (nargs == 2) {
+ t = SLang_peek_at_stack();
+ if (t != SLANG_INT_TYPE) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: expected type %d got %d
",
+ __FUNCTION__, SLANG_INT_TYPE, t);
+ return;
+ }
+
+ if (SLang_pop_integer(&extra) < 0) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Failed to pop integer from stack!
",
+ __FUNCTION__);
+ return;
+ }
+ }
+
+ t = SLang_peek_at_stack();
+ if (t != SLANG_STRING_TYPE) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: expected type %d got %d
",
+ __FUNCTION__,
+ SLANG_STRING_TYPE, t);
+ return;
+ }
+
+ if (SLpop_string(&svcName) < 0) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Failed to pop string from stack!
",
+ __FUNCTION__);
+ return;
+ }
+
+ /* Ok, got our parameters */

if (get_service_state_internal(svcName, &svcStatus) < 0) {
SLang_verror(SL_RunTime_Error,
@@ -246,6 +301,28 @@ sl_service_status(char *svcName)
return;
}

+ if (extra) {
+ /* push transition time and flags on to the stack */
+
+ mtime = (unsigned long long)svcStatus.rs_transition;
+ if (SLang_push_ulong_long(mtime) < 0) {
+ SLang_verror(SL_RunTime_Error,
+ (char *)"%s: Failed to push mtime %s",
+ __FUNCTION__,
+ svcName);
+ return;
+ }
+
+ flags = (int)svcStatus.rs_flags;
+ if (SLang_push_integer(flags) < 0) {
+ SLang_verror(SL_RunTime_Error,
+ (char *)"%s: Failed to push flags %s",
+ __FUNCTION__,
+ svcName);
+ return;
+ }
+ }
+
restarts_exceeded = check_restart(svcName);
if (SLang_push_integer(restarts_exceeded) < 0) {
SLang_verror(SL_RunTime_Error,
@@ -928,6 +1005,8 @@ array_to_string(char *buf, int buflen, int *array, int arraylen)
void
sl_clulog(int level)
{
+ unsigned long long s_ullval;
+ unsigned long s_ulval;
int t, nargs, len;
//int level;
int s_intval;
@@ -937,6 +1016,7 @@ sl_clulog(int level)
char tmp[256];
int need_free;
int remain = sizeof(logbuf)-2;
+ SLang_Any_Type *stuff = NULL;

nargs = SLang_Num_Function_Args;
if (nargs < 1)
@@ -960,6 +1040,16 @@ sl_clulog(int level)
}
free(nodes);
break;
+ case SLANG_ULONG_TYPE:
+ if (SLang_pop_ulong(&s_ulval) < 0)
+ return;
+ len=snprintf(tmp, sizeof(tmp) - 1, "%lu", s_ulval);
+ break;
+ case SLANG_ULLONG_TYPE:
+ if (SLang_pop_ulong_long(&s_ullval) < 0)
+ return;
+ len=snprintf(tmp, sizeof(tmp) - 1, "%llu", s_ullval);
+ break;
case SLANG_INT_TYPE:
if (SLang_pop_integer(&s_intval) < 0)
return;
@@ -976,6 +1066,11 @@ sl_clulog(int level)
need_free = 0;
len=snprintf(tmp, sizeof(tmp) - 1,
"{UnknownType %d}", t);
+ SLang_pop_anytype(&stuff);
+ if (stuff) {
+ SLang_free_anytype(stuff);
+ stuff = NULL;
+ }
break;
}

@@ -1075,7 +1170,7 @@ SLang_Intrin_Fun_Type rgmanager_slang[] =
MAKE_INTRINSIC_0("service_start", sl_start_service, SLANG_INT_TYPE),
MAKE_INTRINSIC_0((char *)"service_migrate", sl_migrate_service,
SLANG_INT_TYPE),
- MAKE_INTRINSIC_S("service_status", sl_service_status,
+ MAKE_INTRINSIC_0((char *)"service_status", sl_service_status,
SLANG_VOID_TYPE),
MAKE_INTRINSIC_S("service_freeze", sl_service_freeze,
SLANG_INT_TYPE),
--
1.7.3.4
 
Old 01-05-2012, 02:57 PM
Lon Hohberger
 
Default rgmanager: Add extra service status call (RHEL5)

Pass the flags and last transition time back to caller
if the caller requests it with an additional parameter.

Resolves: rhbz#743214

Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
rgmanager/src/daemons/slang_event.c | 105 +++++++++++++++++++++++++++++++++--
1 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index 468706f..c9cca7a 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -30,6 +30,7 @@

#include <stdio.h>
#include <string.h>
+#define HAVE_LONG_LONG 1
#include <slang.h>
#include <sys/syslog.h>
#include <malloc.h>
@@ -229,14 +230,68 @@ get_service_state_internal(char *svcName, rg_state_t *svcStatus)


/*
- (restarts, last_owner, owner, state) = get_service_status(servicename)
+ (rte, restarts, last_owner, owner, state) =
+ service_status(servicename)
+
+For extra information (flags, transition time)
+ (transition_time, flags, rte, restarts, owner, state) =
+ service_status(servicename, 1);
*/
-void
-sl_service_status(char *svcName)
+static void
+sl_service_status(void)
{
+ char *svcName = NULL;
+ char *state_str;
rg_state_t svcStatus;
int restarts_exceeded = 0;
- char *state_str;
+ int nargs = 0, t = 0, extra = 0, flags = 0;
+ unsigned long long mtime;
+
+ nargs = SLang_Num_Function_Args;
+
+ /* Takes one or two args */
+ if (nargs <= 0 || nargs > 2) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Wrong # of args (%d), must be 1 or 2
",
+ __FUNCTION__,
+ nargs);
+ return;
+ }
+
+ if (nargs == 2) {
+ t = SLang_peek_at_stack();
+ if (t != SLANG_INT_TYPE) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: expected type %d got %d
",
+ __FUNCTION__, SLANG_INT_TYPE, t);
+ return;
+ }
+
+ if (SLang_pop_integer(&extra) < 0) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Failed to pop integer from stack!
",
+ __FUNCTION__);
+ return;
+ }
+ }
+
+ t = SLang_peek_at_stack();
+ if (t != SLANG_STRING_TYPE) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: expected type %d got %d
",
+ __FUNCTION__,
+ SLANG_STRING_TYPE, t);
+ return;
+ }
+
+ if (SLpop_string(&svcName) < 0) {
+ SLang_verror(SL_Syntax_Error,
+ (char *)"%s: Failed to pop string from stack!
",
+ __FUNCTION__);
+ return;
+ }
+
+ /* Ok, got our parameters */

if (get_service_state_internal(svcName, &svcStatus) < 0) {
SLang_verror(SL_RunTime_Error,
@@ -246,6 +301,28 @@ sl_service_status(char *svcName)
return;
}

+ if (extra) {
+ /* push transition time and flags on to the stack */
+
+ mtime = (unsigned long long)svcStatus.rs_transition;
+ if (SLang_push_ulong_long(mtime) < 0) {
+ SLang_verror(SL_RunTime_Error,
+ (char *)"%s: Failed to push mtime %s",
+ __FUNCTION__,
+ svcName);
+ return;
+ }
+
+ flags = (int)svcStatus.rs_flags;
+ if (SLang_push_integer(flags) < 0) {
+ SLang_verror(SL_RunTime_Error,
+ (char *)"%s: Failed to push flags %s",
+ __FUNCTION__,
+ svcName);
+ return;
+ }
+ }
+
restarts_exceeded = check_restart(svcName);
if (SLang_push_integer(restarts_exceeded) < 0) {
SLang_verror(SL_RunTime_Error,
@@ -928,6 +1005,8 @@ array_to_string(char *buf, int buflen, int *array, int arraylen)
void
sl_clulog(int level)
{
+ unsigned long long s_ullval;
+ unsigned long s_ulval;
int t, nargs, len;
//int level;
int s_intval;
@@ -937,6 +1016,7 @@ sl_clulog(int level)
char tmp[256];
int need_free;
int remain = sizeof(logbuf)-2;
+ SLang_Any_Type *stuff = NULL;

nargs = SLang_Num_Function_Args;
if (nargs < 1)
@@ -960,6 +1040,16 @@ sl_clulog(int level)
}
free(nodes);
break;
+ case SLANG_ULONG_TYPE:
+ if (SLang_pop_ulong(&s_ulval) < 0)
+ return;
+ len=snprintf(tmp, sizeof(tmp) - 1, "%lu", s_ulval);
+ break;
+ case SLANG_ULLONG_TYPE:
+ if (SLang_pop_ulong_long(&s_ullval) < 0)
+ return;
+ len=snprintf(tmp, sizeof(tmp) - 1, "%llu", s_ullval);
+ break;
case SLANG_INT_TYPE:
if (SLang_pop_integer(&s_intval) < 0)
return;
@@ -976,6 +1066,11 @@ sl_clulog(int level)
need_free = 0;
len=snprintf(tmp, sizeof(tmp) - 1,
"{UnknownType %d}", t);
+ SLang_pop_anytype(&stuff);
+ if (stuff) {
+ SLang_free_anytype(stuff);
+ stuff = NULL;
+ }
break;
}

@@ -1075,7 +1170,7 @@ SLang_Intrin_Fun_Type rgmanager_slang[] =
MAKE_INTRINSIC_0("service_start", sl_start_service, SLANG_INT_TYPE),
MAKE_INTRINSIC_0((char *)"service_migrate", sl_migrate_service,
SLANG_INT_TYPE),
- MAKE_INTRINSIC_S("service_status", sl_service_status,
+ MAKE_INTRINSIC_0((char *)"service_status", sl_service_status,
SLANG_VOID_TYPE),
MAKE_INTRINSIC_S("service_freeze", sl_service_freeze,
SLANG_INT_TYPE),
--
1.7.3.4
 

Thread Tools




All times are GMT. The time now is 08:02 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org