orcm/mca/sensor/nodepower/sensor_nodepower.c
/*
 nodepower to be picked up by heartbeat
 */
nodepower to be picked up by heartbeat
nodepower to be picked up by heartbeat
static void nodepower_log(opal_buffer_t *sample)
{
    char *hostname=NULL;
    char *sampletime;
    int rc;
    int32_t n;
    opal_list_t *vals;
    opal_value_t *kv;
    int sensor_not_avail=0;
    float node_power_cur;
    if (!log_enabled) {
        return;
    }
    n=1;
    if (OPAL_SUCCESS != (rc = opal_dss.unpack(sample, &hostname, &n, OPAL_STRING))) {
        ORTE_ERROR_LOG(rc);
        return;
    }
    n=1;
    if (OPAL_SUCCESS != (rc = opal_dss.unpack(sample, &sampletime, &n, OPAL_STRING))) {
        ORTE_ERROR_LOG(rc);
        return;
    }
    opal_output_verbose(3, orcm_sensor_base_framework.framework_output,
                        "%s Received freq log from host %s",
                        ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                        (NULL == hostname) ? "NULL" : hostname);
    vals = OBJ_NEW(opal_list_t);
    kv = OBJ_NEW(opal_value_t);
    kv->key = strdup("ctime");
    kv->type = OPAL_STRING;
    kv->data.string = strdup(sampletime);
    free(sampletime);
    opal_list_append(vals, &kv->super);
    kv = OBJ_NEW(opal_value_t);
    kv->key = strdup("hostname");
    kv->type = OPAL_STRING;
    if (hostname==NULL){
      kv->data.string = strdup("NULL");
    } else {
      kv->data.string = strdup(hostname);
    }
    opal_list_append(vals, &kv->super);
    kv = OBJ_NEW(opal_value_t);
    kv->key=strdup("nodepower:W");
    kv->type=OPAL_FLOAT;
    n=1;
    if (OPAL_SUCCESS != (rc = opal_dss.unpack(sample, &node_power_cur, &n, OPAL_FLOAT))) {
        ORTE_ERROR_LOG(rc);
        return;
    }
    kv->data.fval=node_power_cur;
    if ((node_power_cur==(float)(-1.0)) || (node_power_cur==(float)(0.0))){
        sensor_not_avail=1;
    } else {
        opal_list_append(vals, &kv->super);
    }
    if (0 <= orcm_sensor_base.dbhandle) {
        if (!sensor_not_avail){
            orcm_db.store(orcm_sensor_base.dbhandle, "nodepower", vals, mycleanup, NULL);
        }
    } else {
        OPAL_LIST_RELEASE(vals);
    }
    if (NULL != hostname) {
        free(hostname);
    }
}
static void nodepower_log ( opal_buffer_t * sample ) { char * hostname = NULL ; char * sampletime ; int rc ; int32_t n ; opal_list_t * vals ; opal_value_t * kv ; int sensor_not_avail = 0 ; float node_power_cur ; if ( ! log_enabled ) { return ; } n = 1 ; if ( OPAL_SUCCESS != ( rc = opal_dss . unpack ( sample , & hostname , & n , OPAL_STRING ) ) ) { ORTE_ERROR_LOG ( rc ) ; return ; } n = 1 ; if ( OPAL_SUCCESS != ( rc = opal_dss . unpack ( sample , & sampletime , & n , OPAL_STRING ) ) ) { ORTE_ERROR_LOG ( rc ) ; return ; } opal_output_verbose ( 3 , orcm_sensor_base_framework . framework_output , " " , ORTE_NAME_PRINT ( ORTE_PROC_MY_NAME ) , ( NULL == hostname ) ? " " : hostname ) ; vals = OBJ_NEW ( opal_list_t ) ; kv = OBJ_NEW ( opal_value_t ) ; kv -> key = strdup ( " " ) ; kv -> type = OPAL_STRING ; kv -> data . string = strdup ( sampletime ) ; free ( sampletime ) ; opal_list_append ( vals , & kv -> super ) ; kv = OBJ_NEW ( opal_value_t ) ; kv -> key = strdup ( " " ) ; kv -> type = OPAL_STRING ; if ( hostname == NULL ) { kv -> data . string = strdup ( " " ) ; } else { kv -> data . string = strdup ( hostname ) ; } opal_list_append ( vals , & kv -> super ) ; kv = OBJ_NEW ( opal_value_t ) ; kv -> key = strdup ( " " ) ; kv -> type = OPAL_FLOAT ; n = 1 ; if ( OPAL_SUCCESS != ( rc = opal_dss . unpack ( sample , & node_power_cur , & n , OPAL_FLOAT ) ) ) { ORTE_ERROR_LOG ( rc ) ; return ; } kv -> data . fval = node_power_cur ; if ( ( node_power_cur == ( float ) ( -1.0 ) ) || ( node_power_cur == ( float ) ( 0.0 ) ) ) { sensor_not_avail = 1 ; } else { opal_list_append ( vals , & kv -> super ) ; } if ( 0 <= orcm_sensor_base . dbhandle ) { if ( ! sensor_not_avail ) { orcm_db . store ( orcm_sensor_base . dbhandle , " " , vals , mycleanup , NULL ) ; } } else { OPAL_LIST_RELEASE ( vals ) ; } if ( NULL != hostname ) { free ( hostname ) ; } }
nodepower to be picked up by heartbeat
nodepower to be picked up by heartbeat
/* unpack the host this came from */ /* sample time */ /* xfr to storage */ /* load the sample time at the start */ /* load the hostname */ /* store it */