コード例 #1
0
ファイル: cpqNicIfLogMapTable.c プロジェクト: marker55/hp-ams
void
cpqNicIfLogMapTable_cache_reload(int index)
{
    netsnmp_cache  *cpqNicIfLogMapTable_cache = NULL;
    netsnmp_container *iflogmap_container;
    netsnmp_iterator  *it;
    cpqNicIfLogMapTable_entry* entry = NULL;

    DEBUGMSGTL(("internal:cpqNicIfLogMapTable:_cache_reload", "triggered\n"));

    cpqNicIfLogMapTable_cache = netsnmp_cache_find_by_oid(cpqNicIfLogMapTable_oid,
                                            cpqNicIfLogMapTable_oid_len);

    if (cpqNicIfLogMapTable_cache != NULL) {
        iflogmap_container = cpqNicIfLogMapTable_cache->magic;
        it = CONTAINER_ITERATOR(iflogmap_container);

        entry = ITERATOR_FIRST( it );
        while (entry != NULL ) {
            if (entry->cpqNicIfLogMapIndex == index)
                break;
            entry = ITERATOR_NEXT( it );
        }
        ITERATOR_RELEASE( it );
        if (entry != NULL)
            cpqNicIfLogMap_reload_entry(entry);
    }
}
コード例 #2
0
ファイル: cpqSasPhyDrvTable.c プロジェクト: marker55/hp-ams
void
cpqSasPhyDrvTable_cache_reload()
{
    netsnmp_cache  *cpqSasPhyDrvTable_cache = NULL;

    cpqSasPhyDrvTable_cache = netsnmp_cache_find_by_oid(cpqSasPhyDrvTable_oid,
                                            cpqSasPhyDrvTable_oid_len);

    DEBUGMSGTL(("internal:cpqSasPhyDrvTable:_cache_reload", "triggered\n"));
    if (NULL != cpqSasPhyDrvTable_cache) {
       cpqSasPhyDrvTable_cache->valid = 0;
       netsnmp_cache_check_and_reload(cpqSasPhyDrvTable_cache);
    }
}
コード例 #3
0
ファイル: ifXTable_interface.c プロジェクト: DYFeng/infinidb
/**
 * @internal
 * initialize the iterator container with functions or wrappers
 */
void
_ifXTable_container_init(ifXTable_interface_ctx * if_ctx)
{
    DEBUGMSGTL(("internal:ifXTable:_ifXTable_container_init", "called\n"));

    /*
     * set up the cache
     *
     * special case: sharing a cache
     */
    if_ctx->cache =
        netsnmp_cache_find_by_oid(ifTable_oid, ifTable_oid_size);
    if (NULL != if_ctx->cache) {
        if_ctx->container = (netsnmp_container *) if_ctx->cache->magic;
        return;
    } else {
        snmp_log(LOG_ERR, "error finding ifTable cache\n");
    }
}
コード例 #4
0
ファイル: interface.cpp プロジェクト: duniansampa/SigLog
/**
 * Setup an iterator for scanning the interfaces using the cached entry
 * from if-mib/ifTable.
 */
void
Interface_Scan_Init(void)
{
    netsnmp_container *cont = NULL;
    netsnmp_cache *cache    = NULL; 
    
    cache = netsnmp_cache_find_by_oid(ifTable_oid, ifTable_oid_size);
    if (NULL != cache) {
        netsnmp_cache_check_and_reload(cache);
        cont = (netsnmp_container*) cache->magic;
    }
    
    if (NULL != cont) {
        if (NULL != it)
            ITERATOR_RELEASE(it);
    
        it = CONTAINER_ITERATOR(cont);
    }
   
    if (NULL != it)
        row = (ifTable_rowreq_ctx*)ITERATOR_FIRST(it);
}
コード例 #5
0
ファイル: pkg_linux.c プロジェクト: vejta66/hp-ams
int getPackage()
{
    int timelen;
    netsnmp_container *pkg_container = NULL;
    netsnmp_cache *pkg_cache = NULL;
    netsnmp_iterator  *it;
    cpqHoSwVerTable_entry *entry;
    int i;
    int pkgcount = 0;

    pkg_cache = netsnmp_cache_find_by_oid(cpqHoSwVerTable_oid, 
					  cpqHoSwVerTable_oid_len);
    if (pkg_cache == NULL)
        return  0;

    pkg_container = pkg_cache->magic;
    if (pkg_container == NULL)
        return 0;

    pkgcount = (oid)CONTAINER_SIZE(pkg_container);

    if ((packages = (pkg_entry**)malloc(pkgcount * sizeof(pkg_entry *)))
                    == NULL) {
        return 0;
    }

    it = CONTAINER_ITERATOR( pkg_container );
    entry = ITERATOR_FIRST( it );
    i = 0;
    while (entry != NULL) {

        if ((packages[i] = (pkg_entry*)malloc(sizeof(pkg_entry))) == NULL) {
            continue;
        }
        memset(packages[i], 0, sizeof(pkg_entry));

        if (entry->cpqHoSwVerName_len != 0 ) {
            packages[i]->sname = malloc(entry->cpqHoSwVerName_len + 1);
            memset(packages[i]->sname, 0, entry->cpqHoSwVerName_len + 1);
            strcpy(packages[i]->sname, entry->cpqHoSwVerName);

            packages[i]->name = malloc(entry->cpqHoSwVerName_len + 1);
            memset(packages[i]->name, 0, entry->cpqHoSwVerName_len + 1);
	    strcpy(packages[i]->name,  entry->cpqHoSwVerName);
        } else {
            packages[i]->sname = NULL;
            packages[i]->name = NULL;
        }

        if (entry->cpqHoSwVerVersion_len != 0 ) {
            packages[i]->version = malloc(entry->cpqHoSwVerVersion_len + 1);
            memset(packages[i]->version, 0, entry->cpqHoSwVerVersion_len + 1);
	    strcpy(packages[i]->version, entry->cpqHoSwVerVersion);
        } else
            packages[i]->version = NULL;

        if (entry->vendor_len != 0 ) {
            packages[i]->vendor = malloc(entry->vendor_len + 1);
            memset(packages[i]->vendor, 0, entry->vendor_len + 1);
	    strcpy(packages[i]->vendor, entry->vendor);
        } else
            packages[i]->vendor = NULL;

        if (entry->timestamp != 0) {
            packages[i]->timestamp = malloc(80);
            memset(packages[i]->timestamp, 0, 80);
            timelen = strftime(packages[i]->timestamp, 80,
                               "%Y-%m-%d %H:%M:%S %z",
                               gmtime(&entry->timestamp));
        } else
            packages[i]->timestamp = NULL;
                                 
        i++;
        entry = ITERATOR_NEXT( it );
    }
    ITERATOR_RELEASE( it );

    return pkgcount;
}
コード例 #6
0
ファイル: ide_linux.c プロジェクト: vejta66/hp-ams
int netsnmp_arch_idedisk_container_load(netsnmp_container* container)
{
    cpqIdeControllerTable_entry *cntlr;
    cpqIdeAtaDiskTable_entry *disk;
    cpqIdeAtaDiskTable_entry *old;
    netsnmp_container *cntlr_container;
    netsnmp_iterator  *it;
    netsnmp_cache *cntlr_cache;
    netsnmp_container *fw_container = NULL;
    netsnmp_cache *fw_cache = NULL;

    char buffer[256];
    char attribute[256];
    char *value;
    long long size;
    char *scsi;
    char *generic;

    int Cntlr, Bus, Index, Target;
    char * OS_name;
    char *serialnum = NULL;
    int j;
    long  rc = 0;
    int disk_fd;
    int Health = 0, Temp = -1, Mcot = -1, Wear = -1;
    unsigned char *Temperature;

    netsnmp_index tmp;
    oid oid_index[2];

    DEBUGMSGTL(("idedisk:container:load", "loading\n"));
    /*
     * find  the HBa container.
     */
    SataDiskCondition = CPQ_REG_OK;

    cntlr_cache = netsnmp_cache_find_by_oid(cpqIdeControllerTable_oid, 
                                            cpqIdeControllerTable_oid_len);
    if (cntlr_cache == NULL) {
        return -1;
    }
    cntlr_container = cntlr_cache->magic;
    DEBUGMSGTL(("idedisk:container:load", "Container=%p\n",cntlr_container));
    DEBUGMSGTL(("idedisk:container:load", 
                "ContainerSize=%ld\n", CONTAINER_SIZE(cntlr_container)));
    it = CONTAINER_ITERATOR( cntlr_container );
    cntlr = ITERATOR_FIRST( it );
    DEBUGMSGTL(("idedisk:container:load", "cntlr=%p\n",cntlr));
    while ( cntlr != NULL ) {
        current_Cntlr = cntlr->host;
        DEBUGMSGTL(("idedisk:container:load", 
                    "Starting Loop %s\n", current_Cntlr));
        cntlr->cpqIdeControllerOverallCondition =
                  MAKE_CONDITION(cntlr->cpqIdeControllerOverallCondition,
                                 cntlr->cpqIdeControllerCondition);
        /* Now chack for those HBA's in  the SCSI diskss */
        if ((NumScsiDisk = scandir(ScsiDiskDir, &ScsiDisklist, 
                                   disk_select, alphasort)) <= 0) {
            free(ScsiDisklist);
            cntlr = ITERATOR_NEXT( it );
            continue;
        }	

        for (j= 0; j< NumScsiDisk; j++) {
            memset(&buffer, 0, sizeof(buffer));
            strncpy(buffer, ScsiDiskDir, sizeof(buffer) - 1);
            strncat(buffer, ScsiDisklist[j]->d_name, 
                    sizeof(buffer) - strlen(buffer) - 1);
            DEBUGMSGTL(("idedisk:container:load", "Working on disk %s\n", 
                        ScsiDisklist[j]->d_name));

            sscanf(ScsiDisklist[j]->d_name,"%d:%d:%d:%d",
                        &Cntlr, &Bus, &Index, &Target);

            DEBUGMSGTL(("idedisk:container:load",
                        "looking for cntlr=%ld, Disk = %d\n", 
                        cntlr->cpqIdeControllerIndex, Index));
            oid_index[0] = cntlr->cpqIdeControllerIndex;
            oid_index[1] = Index;
            tmp.len = 2;
            tmp.oids = &oid_index[0];

            old = CONTAINER_FIND(container, &tmp);
            DEBUGMSGTL(("idedisk:container:load", "Old disk=%p\n",old));
            if (old != NULL ) {
                DEBUGMSGTL(("idedisk:container:load", "Re-Use old entry\n"));
                old->OldStatus = old->cpqIdeAtaDiskStatus;
                disk = old;
            } else {
                disk = cpqIdeAtaDiskTable_createEntry(container,
                            (oid)cntlr->cpqIdeControllerIndex, 
                            Index);
                if (disk == NULL) 
                    continue;

                DEBUGMSGTL(("idedisk:container:load", "Entry created\n"));

		scsi = ScsiDisklist[j]->d_name;

                if ((value = get_DiskModel(scsi)) != NULL) {
                    strncpy(disk->cpqIdeAtaDiskModel, value,
                            sizeof(disk->cpqIdeAtaDiskModel) - 1);
                    disk->cpqIdeAtaDiskModel_len = 
                                               strlen(disk->cpqIdeAtaDiskModel);
                    free(value);
                }

                if ((value = get_DiskState(scsi)) != NULL) {
                    if (strcmp(value, "running") == 0)
                        disk->cpqIdeAtaDiskStatus = SAS_PHYS_STATUS_OK;
                    free(value);
                }

                disk->cpqIdeAtaDiskCapacity = get_BlockSize(scsi) >> 11;

                generic = get_ScsiGeneric(scsi);
                if (generic != NULL) {
                    memset(disk->cpqIdeAtaDiskOsName, 0, 256);
                    disk->cpqIdeAtaDiskOsName_len =
                                        sprintf(disk->cpqIdeAtaDiskOsName,
                                                "/dev/%s",
                                                generic);
                    free(generic);
                }
                DEBUGMSGTL(("idedisk:container:load", "generic dev is %s\n",
                                disk->cpqIdeAtaDiskOsName));

            }
            if ((disk_fd = open(disk->cpqIdeAtaDiskOsName, 
                                O_RDWR | O_NONBLOCK)) >= 0) {
                if ((serialnum = get_unit_sn(disk_fd)) != NULL  ) {
                    strncpy(disk->cpqIdeAtaDiskSerialNumber, serialnum, 40);
                    disk->cpqIdeAtaDiskSerialNumber_len = strlen(serialnum);
                    free(serialnum);
                }

                if ((value = get_sata_DiskRev(disk_fd)) != NULL) {
                    strncpy(disk->cpqIdeAtaDiskFwRev, value,
                            sizeof(disk->cpqIdeAtaDiskFwRev) - 1);
                    disk->cpqIdeAtaDiskFwRev_len = 
                                               strlen(disk->cpqIdeAtaDiskFwRev);
                    free(value);
                }

                disk->cpqIdeAtaDiskPowerOnHours = get_sata_pwron(disk_fd);

                disk->cpqIdeAtaDiskSSDEstTimeRemainingHours = -1;

                if ((Temperature = get_sata_temp(disk_fd)) != NULL ) {
                    Temp = sata_parse_current(Temperature);
                    Mcot = sata_parse_mcot(Temperature);
                    disk->cpqIdeAtaDiskCurrTemperature = Temp;
                    disk->cpqIdeAtaDiskTemperatureThreshold = Mcot;
                    free(Temperature);
                }

                if (is_unit_ssd(disk_fd)) {
                    disk->cpqIdeAtaDiskMediaType = PHYS_DRV_SOLID_STATE;
                    Wear = get_sata_ssd_wear(disk_fd);
                    disk->cpqIdeAtaDiskSSDPercntEndrnceUsed = Wear;
                    disk->cpqIdeAtaDiskSSDWearStatus = SSD_WEAR_OK;
                    if (disk->cpqIdeAtaDiskSSDPercntEndrnceUsed >= 95)
                        disk->cpqIdeAtaDiskSSDWearStatus = 
                                                        SSD_WEAR_5PERCENT_LEFT;
                    if (disk->cpqIdeAtaDiskSSDPercntEndrnceUsed >= 98)
                        disk->cpqIdeAtaDiskSSDWearStatus = 
                                                        SSD_WEAR_2PERCENT_LEFT;
                    if (disk->cpqIdeAtaDiskSSDPercntEndrnceUsed >= 100)
                        disk->cpqIdeAtaDiskSSDWearStatus = SSD_WEAR_OUT;
                } else {
                    disk->cpqIdeAtaDiskMediaType = PHYS_DRV_ROTATING_PLATTERS;
                    disk->cpqIdeAtaDiskSSDPercntEndrnceUsed = 
                                                    get_sata_ssd_wear(disk_fd);
                    disk->cpqIdeAtaDiskSSDWearStatus = SSD_WEAR_OTHER;
                } 

                if ((Health = get_sata_health(disk_fd)) >= 0) {
                    disk->cpqIdeAtaDiskSmartEnabled = 2;
                    if (Health == 0) {
                        disk->cpqIdeAtaDiskStatus = 2; /* OK */
                        disk->cpqIdeAtaDiskCondition = 2; /* OK */
                    } else {
                        disk->cpqIdeAtaDiskStatus = 3; /* predictive failure */
                        disk->cpqIdeAtaDiskCondition = 3; /*  Degraded*/
                    }
                } else {
                    disk->cpqIdeAtaDiskSmartEnabled = 1;
                    disk->cpqIdeAtaDiskStatus = 1; /* Other */
                    disk->cpqIdeAtaDiskCondition = 1; /* Other */
                }
                close(disk_fd);
            }
            disk->cpqIdeAtaDiskChannel = 4; /* Serial */
            disk->cpqIdeAtaDiskTransferMode = 1;
            disk->cpqIdeAtaDiskLogicalDriveMember = 1;
            disk->cpqIdeAtaDiskIsSpare = 1;
            disk->cpqIdeAtaDiskType = 3;  /* Only SATA drives */
            disk->cpqIdeAtaDiskSataVersion = 3; /*assume version 2 */
            disk->cpqIdeAtaDiskNumber = 4 + Index;

            disk->cpqIdeAtaDiskCondition = 
                            MAKE_CONDITION(disk->cpqIdeAtaDiskCondition, 
                                           disk->cpqIdeAtaDiskStatus);
            cntlr->cpqIdeControllerOverallCondition =
                MAKE_CONDITION(cntlr->cpqIdeControllerOverallCondition,
                               disk->cpqIdeAtaDiskStatus);
            if (old == NULL) {
                rc = CONTAINER_INSERT(container, disk);
                DEBUGMSGTL(("idedisk:container:load", "entry inserted\n"));
            }
            if (((old == NULL) || (disk->OldStatus == 2)) &&
                    (disk->cpqIdeAtaDiskStatus == 3)){
                SendIdeTrap(IDE_TRAP_DISK_STATUS_CHANGE, disk);
                DEBUGMSGTL(("idedisk:container:load", "Sending Trap\n"));
            }
            free(ScsiDisklist[j]);
            SataDiskCondition |=  (1 < (disk->cpqIdeAtaDiskCondition -1));
        }
        free(ScsiDisklist);
        cntlr = ITERATOR_NEXT( it );
    }
    ITERATOR_RELEASE( it );

    if ((SataDiskCondition & (1 < (CPQ_REG_DEGRADED -1))) != 0)
        cpqHoMibHealthStatusArray[CPQMIBHEALTHINDEX] = CPQ_REG_DEGRADED;

    DEBUGMSGTL(("idedisk:container", "init\n"));
    return 1;
}