Hi,
I want to extract RDRs using Entity Path. I tried to do this by calling method 
saHpiGetIdByEntityPath to get Rpt resourceId and then use this resource Id in 
method saHpiRdrGet to get RDRs. My sample program is calling 
saHpiGetIdByEntityPath though it is failing with error INVALID_PARAMS . Sample 
program and shell script (I used to compile this client in client directory of 
openhpi source code) is attached with this mail. Please let me know what 
correction is required in this program or any other way if I am not calling 
right method.

Regards,
Preeti


#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>

#include <SaHpi.h>
#include <oh_utils.h>
#include <oh_clients.h>

#define OH_SVN_REV "$Revision: 7189 $"

#include <unistd.h>

#define HPI_NSEC_PER_SEC 1000000000LL

#define ENTITY_SIZE 2
SaHpiEntityPathT element_entity_path;
#if 0
element_entity_path.Entry[16] = {
                                  {SAHPI_ENT_SYSTEM_CHASSIS, 9},
                                  {SAHPI_ENT_FAN, 1}
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0},
                                  //{0, 0}
                                }; 
#endif
int fdebug = 1;
SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID;

int main(int argc, char **argv)
{
        int do_discover_after_subscribe = 0;
        SaErrorT rv;
        SaHpiSessionIdT sessionid;
        SaHpiDomainInfoT domainInfo;
        SaHpiRptEntryT rptentry;
        SaHpiEntryIdT rptentryid;

        memset(&rptentry, 0, sizeof(rptentry));

element_entity_path.Entry[0].EntityType = SAHPI_ENT_SYSTEM_CHASSIS; 
element_entity_path.Entry[0].EntityLocation = 9;
element_entity_path.Entry[1].EntityType = SAHPI_ENT_FAN;
element_entity_path.Entry[1].EntityLocation = 1;

        oh_prog_version(argv[0], OH_SVN_REV);

        rv = saHpiSessionOpen(domainid, &sessionid, NULL);
        if (rv != SA_OK) {
                if (rv == SA_ERR_HPI_ERROR) 
                        printf("saHpiSessionOpen: error %d, SpiLibd not 
running\n", rv);
                else
                        printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv));
                exit(-1);
        }
 
        if (!do_discover_after_subscribe) {
                if (fdebug) printf("saHpiDiscover\n");
                rv = saHpiDiscover(sessionid);
                if (rv != SA_OK) {
                        printf("saHpiDiscover: %s\n", oh_lookup_error(rv));
                        exit(-1);
                }
        }
        
        if (fdebug) printf( "Subscribe to events\n");
        rv = saHpiSubscribe( sessionid );
        if (rv != SA_OK) {
                printf("saHpiSubscribe: %s\n", oh_lookup_error(rv));
                exit(-1);
        }

        if (do_discover_after_subscribe) {
                if (fdebug) printf("saHpiDiscover after saHpiSubscribe\n");
                rv = saHpiDiscover(sessionid);
                if (rv != SA_OK) {
                        printf("saHpiDiscover after saHpiSubscribe: %s\n", 
oh_lookup_error(rv));
                        exit(-1);
                }
        }

        rv = saHpiDomainInfoGet(sessionid, &domainInfo);

        if (fdebug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv));
        printf("DomainInfo: UpdateCount = %u, UpdateTime = %lx\n",
                domainInfo.RptUpdateCount, (unsigned 
long)domainInfo.RptUpdateTimestamp);

        /* walk the RPT list */
        rptentryid = SAHPI_FIRST_ENTRY;
        SaHpiResourceIdT  resourceId;
        SaHpiInstrumentIdT intrumentId; 
        SaHpiUint32T       rptUpdateCount; 
        while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) {       
                printf("**********************************************\n");

                rv = saHpiGetIdByEntityPath(sessionid, element_entity_path, 
SAHPI_NO_RECORD, SAHPI_FIRST_ENTRY, resourceId, intrumentId, rptUpdateCount);
                if (fdebug) printf("saHpiRptEntryGet %s\n", 
oh_lookup_error(rv));

                if (rv == SA_OK) {
                        printf("RPT %x \n", resourceId);

                        }

        }

        rv = saHpiSessionClose(sessionid);
        
        return(0);
}
 
/* end hpigetevents.c */

Attachment: rmComp.sh
Description: rmComp.sh

------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk 
Collect, index and harness all the fast moving IT data generated by your 
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights. 
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Openhpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openhpi-devel

Reply via email to