Esempio n. 1
0
void
snmp_dump_oid2str(struct snmp_oid2str *entry)
{
	char buf[ASN_OIDSTRLEN];

	if (entry != NULL) {
		memset(buf, 0, sizeof(buf));
		asn_oid2str_r(&(entry->var), buf);
		DEBUG(stderr, "%s - %s - %d - %d - %d", buf, entry->string,
		    entry->syntax, entry->access, entry->strlen);
		snmp_dump_enumpairs(entry->snmp_enum);
		DEBUG(stderr,"%s \n", (entry->table_idx == NULL)?"No table":
		    entry->table_idx->string);
	}
}
Esempio n. 2
0
static void
field_response (int request, int code, struct snmp_value *value, void *arg)
{
	rb_item *item = arg;
	mstime when;
	char asnbuf[ASN_OIDSTRLEN];

	ASSERT (request == item->field_request);

	/* Note when the response for this item arrived */
	when = server_get_time ();
	item->last_polled = when;

	/* Mark this item as done */
	item->field_request = 0;

	/* Errors result in us writing U */
	if (code != SNMP_ERR_NOERROR) {
		item->vtype = VALUE_UNSET;

	/* Parse the value from server */
	} else {
		switch(value->syntax)
		{
		case SNMP_SYNTAX_NULL:
			item->vtype = VALUE_UNSET;
			break;
		case SNMP_SYNTAX_INTEGER:
			item->v.i_value = value->v.integer;
			item->vtype = VALUE_REAL;
			break;
		case SNMP_SYNTAX_COUNTER:       /* FALLTHROUGH */
		case SNMP_SYNTAX_GAUGE:         /* FALLTHROUGH */
		case SNMP_SYNTAX_TIMETICKS:
			item->v.i_value = value->v.uint32;
			item->vtype = VALUE_REAL;
			break;
		case SNMP_SYNTAX_COUNTER64:
			item->v.i_value = value->v.counter64;
			item->vtype = VALUE_REAL;
			break;
		case SNMP_SYNTAX_OCTETSTRING:
			if (parse_string_value(value, item))
				break;
			/* FALLTHROUGH */
		case SNMP_SYNTAX_OID: 		/* FALLTHROUGH */
		case SNMP_SYNTAX_IPADDRESS:	/* FALLTHROUGH */
		case SNMP_SYNTAX_NOSUCHOBJECT:	/* FALLTHROUGH */
		case SNMP_SYNTAX_NOSUCHINSTANCE:/* FALLTHROUGH */
		case SNMP_SYNTAX_ENDOFMIBVIEW:	/* FALLTHROUGH */
		default:
			log_warnx("snmp server %s: oid %s: field %s: response %s(%u)",
			    item->hostnames[item->hostindex],
			    asn_oid2str_r(&item->field_oid, asnbuf),
			    item->field,
			    snmp_get_syntaxmsg(value->syntax),
			    value->syntax);
			break;
		};

		if (item->vtype == VALUE_REAL)
			log_debug ("got value for field '%s': %lld",
			           item->field, item->v.i_value);
		else if (item->vtype == VALUE_FLOAT)
			log_debug ("got value for field '%s': %.4lf",
			           item->field, item->v.f_value);
		else
			log_debug ("got value for field '%s': U",
			           item->field);
	}

	complete_requests (item, code);

	/* If the entire poll is done, then complete it */
	finish_poll (item->poller, when);
}