Ejemplo n.º 1
0
int *iteliec_get_host_info (SoapCtx *request) {
	sg_host_info *general_stats;

	general_stats = sg_get_host_info ();

    soap_env_push_item (request->env, "urn:HostSoap", "host");

    soap_env_add_item  (request->env, "xsd:string", "os_name", general_stats->os_name);
    soap_env_add_item  (request->env, "xsd:string", "platform", general_stats->platform);
    soap_env_add_item  (request->env, "xsd:string", "hostname", general_stats->hostname);
    soap_env_add_itemf (request->env, "xsd:integer", "uptime", "%lu", general_stats->uptime);

    soap_env_pop_item (request->env);

    return 0;
}
Ejemplo n.º 2
0
int *iteliec_get_process_info (SoapCtx *request) {
	sg_process_count *process_stat;

    process_stat = sg_get_process_count ();

    soap_env_push_item (request->env, "urn:ProcessSoap", "process");

    soap_env_add_itemf (request->env, "xsd:integer", "running", "%d", process_stat->running);
    soap_env_add_itemf (request->env, "xsd:integer", "sleeping","%d", process_stat->sleeping);
    soap_env_add_itemf (request->env, "xsd:integer", "stopped", "%d", process_stat->stopped);
    soap_env_add_itemf (request->env, "xsd:integer", "zombie",  "%d", process_stat->zombie);
    soap_env_add_itemf (request->env, "xsd:integer", "total",   "%d", process_stat->total);

    soap_env_pop_item (request->env);

    return ITELIEC_OK;
}
Ejemplo n.º 3
0
int *iteliec_get_process_list (SoapCtx *request) {
    sg_process_stats *ps;
    int ps_size;
    int x;
    char *state = NULL;

    /* get process list */
    ps = sg_get_process_stats (&ps_size);    

    if (ps == NULL) {
        iteliec_log (ITELIEC_ERR, "Failed to get process snapshot");
        
        return;
    }

    soap_env_push_item (request->env, "urn:ProcessListSoapArray", "processlist");
    for (x = 0; x < ps_size; x++) {
        switch (ps->state) {
        case SG_PROCESS_STATE_RUNNING:
            state = "RUNNING";
            break;
        case SG_PROCESS_STATE_SLEEPING:
            state = "SLEEPING";
            break;
        case SG_PROCESS_STATE_STOPPED:
            state = "STOPPED";
            break;
        case SG_PROCESS_STATE_ZOMBIE:
            state = "ZOMBIE";
            break;
        case SG_PROCESS_STATE_UNKNOWN:
        default:
            state = "UNKNOWN";
            break;
        }

        soap_env_push_item (request->env, "urn:ProcessListSoap", "processlist");

        soap_env_add_itemf (request->env, "xsd:integer", "pid",     "%d", (int)ps->pid);
        soap_env_add_itemf (request->env, "xsd:integer", "parent",  "%d", (int)ps->parent);
        soap_env_add_itemf (request->env, "xsd:integer", "pgid",    "%d", (int)ps->pgid);
        soap_env_add_itemf (request->env, "xsd:integer", "uid",     "%d", (int)ps->uid);
        soap_env_add_itemf (request->env, "xsd:integer", "euid",    "%d", (int)ps->euid);
        soap_env_add_itemf (request->env, "xsd:integer", "gid",     "%d", (int)ps->gid);
        soap_env_add_itemf (request->env, "xsd:integer", "egid",    "%d", (int)ps->egid);
        soap_env_add_itemf (request->env, "xsd:integer", "nice",    "%d", (int)ps->nice);
        
        soap_env_add_itemf (request->env, "xsd:integer", "proc_size",    "%d", (int)ps->proc_size);
        soap_env_add_itemf (request->env, "xsd:integer", "proc_resident","%d", (int)ps->proc_resident);
        soap_env_add_itemf (request->env, "xsd:float",   "cpu_percent",  "%F", ps->cpu_percent);
        
        soap_env_add_item  (request->env, "xsd:string", "state", state);
        soap_env_add_item  (request->env, "xsd:string", "process_name", ps->process_name);
        soap_env_add_item  (request->env, "xsd:string", "proctitle", ps->proctitle);

        soap_env_pop_item (request->env);

        ps++;
    }
    soap_env_pop_item (request->env);

    return ITELIEC_OK;
}
Ejemplo n.º 4
0
int main( int argc, char** argv ) {

	SoapCtx* request;
	SoapCtx* response;
	herror_t error;
	int ii;

	/* The array of parameter values to be fetched from argv. */
	char* parameters[Parameter_Num_Pos];

	xmlChar* buildID;

	if ( argc != Parameter_Num_Pos + 1 ) {
		printf( "Regresstor: Invalid Number of arguments! Num given: %d\n", argc );
		printUsage();
		return EXIT_FAILURE;
	}

	initParametersArray( parameters );
	fetchParametersFromArgv( parameters, argc, argv );

	if ( ! checkParameters( parameters ) ) {
		printUsage();
		return EXIT_FAILURE;
	}

	printf( "Regresstor: calling web service %s(), %s at %s.\n",
		Regresstor_SubmitCheckMethod,
		Regresstor_URN,
		parameters[URL_Pos]);

	/* SOAP CALL */
	error = soap_client_init_args( argc, argv );
	if ( error != H_OK ) {
		log_error4( "%s():%s [%d]", herror_func(error), herror_message(error), herror_code(error) );
		herror_release(error);
		return EXIT_FAILURE;
	}
	
	error = soap_ctx_new_with_method( Regresstor_URN, Regresstor_SubmitCheckMethod, &request );
	if ( error != H_OK ) {
		log_error4( "%s():%s [%d]", herror_func(error), herror_message(error), herror_code(error) );
		herror_release(error);
		return EXIT_FAILURE;
	}

	/* Add parameters into envelope except for the URL */
	soap_env_push_item( request->env, NULL, "parameters" );

	for ( ii = 0; ii < URL_Pos; ++ii ) {
		if ( ii == OutputLocation_Pos ) {
			/* Attach file */
			char* contents;
			char* paramName = NULL;
			int sendDummyFile = 1;

			paramName = "Output";

			if ( strcmp( parameters[ii], "none" ) != 0 ) {
				contents = getFileContents( parameters[ii] );
				if ( contents != NULL ) {
					soap_env_add_item( request->env, "xsd:string", paramName, contents );
					free( contents );
					sendDummyFile = 0;
				}
			}
			if ( sendDummyFile ) {
				soap_env_add_item( request->env, "xsd:string", paramName, "No output file" );
			}
		}
		else
		{
			soap_env_add_item( request->env, "xsd:string", parameterNames[ii], parameters[ii] );
		}
	}

	/* Check commandline to see if diff passed. If fail, add a "Diff Failed" sub test */
	if ( strcmp( parameters[Passed_Pos], "0" ) == 0 ) {
		/* Add the sub test */
		soap_env_add_item( request->env, "xsd:string", "FailedSubTests", "Error failure" );
	}
	
	soap_env_pop_item( request->env );
	
	error = soap_client_invoke( request, &response, parameters[URL_Pos], "");
                                                                                                                                    
	if ( error != H_OK ) {
		log_error4( "[%d] %s(): %s ", herror_code(error), herror_func(error), herror_message(error) );
		herror_release( error );
		soap_ctx_free( request );
		return EXIT_FAILURE;
	}

	interpretResponse( response, &buildID );

	soap_ctx_free( request );
	soap_ctx_free( response );

	soap_client_destroy();


	return EXIT_SUCCESS;
}