Beispiel #1
0
void
send_trap_vars(int trap, int specific, netsnmp_variable_list * vars)
{
    if (trap == SNMP_TRAP_ENTERPRISESPECIFIC)
        send_enterprise_trap_vars(trap, specific, objid_enterprisetrap,
                                  OID_LENGTH(objid_enterprisetrap), vars);
    else
        send_enterprise_trap_vars(trap, specific, trap_version_id,
                                  OID_LENGTH(trap_version_id), vars);
}
Beispiel #2
0
void SendcpqHostGenericTrap()
{
    static oid compaq[] = { 1, 3, 6, 1, 4, 1, 232 };
    static oid compaq_len = 7;
    static oid sysName[] = { 1, 3, 6, 1, 2, 1, 1, 5, 0 };
    static oid cpqHoTrapFlags[] = { 1, 3, 6, 1, 4, 1, 232, 11, 2, 11, 1, 0 };
    static oid cpqHoGenericData[] = { 1, 3, 6, 1, 4, 1, 232, 11, 2, 8, 1, 0 };
    static oid cpqHoMibHealthStatus[] = { 1, 3, 6, 1, 4, 1, 232, 11, 2, 10, 7, 0};
    static oid cpqHostMibStatus[] = { 1, 3, 6, 1, 4, 1, 232, 11, 2, 10, 1, 0};

    netsnmp_variable_list *var_list = NULL;
    struct utsname sys_name;
    unsigned int cpqHoTrapFlag;

    DEBUGMSGTL(("cpqHost", "Sending periodic test trap\n"));

    uname(&sys_name);   /* get sysName */

    snmp_varlist_add_variable(&var_list, sysName,
            sizeof(sysName) / sizeof(oid),
            ASN_OCTET_STR,
            (u_char *) sys_name.nodename,
            strlen(sys_name.nodename));

    snmp_varlist_add_variable(&var_list, cpqHoTrapFlags,
            sizeof(cpqHoTrapFlags) / sizeof(oid),
            ASN_INTEGER, &cpqHoTrapFlag,
            sizeof(cpqHoTrapFlag));

    snmp_varlist_add_variable(&var_list, cpqHoGenericData,
            sizeof(cpqHoGenericData) / sizeof(oid),
            ASN_OCTET_STR, (u_char *) GenericData,
            strlen(GenericData));

    snmp_varlist_add_variable(&var_list, cpqHoMibHealthStatus,
            sizeof(cpqHoMibHealthStatus) / sizeof(oid),
            ASN_OCTET_STR, (u_char *) cpqHoMibHealthStatusArray,
            64);

    snmp_varlist_add_variable(&var_list, cpqHostMibStatus,
            sizeof(cpqHostMibStatus) / sizeof(oid),
            ASN_OCTET_STR, (u_char *) cpqHostMibStatusArray,
            20*sizeof(MibStatusEntry));

    send_enterprise_trap_vars(SNMP_TRAP_ENTERPRISESPECIFIC,
                    11003,
                    compaq,
                    compaq_len,
                    var_list);

    DEBUGMSGTL(("cpqhost:", "Free varbind list...\n"));
    snmp_free_varbind(var_list);
    DEBUGMSGTL(("cpqhost:", "Done freeing varbind list...\n"));

}
Beispiel #3
0
/*ARGSUSED*/
static void
send_trap(fmd_hdl_t *hdl, const char *uuid, const char *code, const char *url)
{
	static const oid sunFmProblemTrap_oid[] = { SUNFMPROBLEMTRAP_OID };
	const size_t sunFmProblemTrap_len = OID_LENGTH(sunFmProblemTrap_oid);

	static const oid sunFmProblemUUID_oid[] =
	    { SUNFMPROBLEMTABLE_OID, 1, SUNFMPROBLEM_COL_UUID };
	static const oid sunFmProblemCode_oid[] =
	    { SUNFMPROBLEMTABLE_OID, 1, SUNFMPROBLEM_COL_CODE };
	static const oid sunFmProblemURL_oid[] =
	    { SUNFMPROBLEMTABLE_OID, 1, SUNFMPROBLEM_COL_URL };

	const size_t sunFmProblem_base_len = OID_LENGTH(sunFmProblemUUID_oid);

	size_t uuid_len = strlen(uuid);
	size_t var_len = sunFmProblem_base_len + 1 + uuid_len;
	oid var_name[MAX_OID_LEN];
	int i;

	netsnmp_variable_list *notification_vars = NULL;

	/*
	 * The format of our trap varbinds' oids is as follows:
	 *
	 * +-----------------------+---+--------+----------+------+
	 * | SUNFMPROBLEMTABLE_OID | 1 | column | uuid_len | uuid |
	 * +-----------------------+---+--------+----------+------+
	 *					 \---- index ----/
	 *
	 * A common mistake here is to send the trap with varbinds that
	 * do not contain the index.  All the indices are the same, and
	 * all the oids are the same length, so the only thing we need to
	 * do for each varbind is set the table and column parts of the
	 * variable name.
	 */

	if (var_len > MAX_OID_LEN) {
		snmp_stats.bad_uuid.fmds_value.ui64++;
		return;
	}

	var_name[sunFmProblem_base_len] = (oid)uuid_len;
	for (i = 0; i < uuid_len; i++)
		var_name[i + sunFmProblem_base_len + 1] = (oid)uuid[i];

	/*
	 * Ordinarily, we would need to add the OID of the trap itself
	 * to the head of the variable list; this is required by SNMP v2.
	 * However, send_enterprise_trap_vars does this for us as a part
	 * of converting between v1 and v2 traps, so we skip directly to
	 * the objects we're sending.
	 */

	(void) memcpy(var_name, sunFmProblemUUID_oid,
	    sunFmProblem_base_len * sizeof (oid));
	(void) snmp_varlist_add_variable(&notification_vars, var_name, var_len,
	    ASN_OCTET_STR, (uchar_t *)uuid, strlen(uuid));
	(void) memcpy(var_name, sunFmProblemCode_oid,
	    sunFmProblem_base_len * sizeof (oid));
	(void) snmp_varlist_add_variable(&notification_vars, var_name, var_len,
	    ASN_OCTET_STR, (uchar_t *)code, strlen(code));
	(void) memcpy(var_name, sunFmProblemURL_oid,
	    sunFmProblem_base_len * sizeof (oid));
	(void) snmp_varlist_add_variable(&notification_vars, var_name, var_len,
	    ASN_OCTET_STR, (uchar_t *)url, strlen(url));

	/*
	 * This function is capable of sending both v1 and v2/v3 traps.
	 * Which is sent to a specific destination is determined by the
	 * configuration file(s).
	 */
	send_enterprise_trap_vars(SNMP_TRAP_ENTERPRISESPECIFIC,
	    sunFmProblemTrap_oid[sunFmProblemTrap_len - 1],
	    (oid *)sunFmProblemTrap_oid, sunFmProblemTrap_len - 2,
	    notification_vars);

	snmp_free_varbind(notification_vars);
}
Beispiel #4
0
static void
event_send_trap(CRTL_ENTRY_T * evptr, u_char is_rising,
                u_int alarm_index,
                u_int value, u_int the_threshold,
                oid * alarmed_var, size_t alarmed_var_length,
                u_int sample_type)
{
    static oid      rmon1_trap_oid[] = { 1, 3, 6, 1, 2, 1, 16, 0, 0 };
    static oid      alarm_index_oid[] =
        { 1, 3, 6, 1, 2, 1, 16, 3, 1, 1, 1 };
    static oid      alarmed_var_oid[] =
        { 1, 3, 6, 1, 2, 1, 16, 3, 1, 1, 3 };
    static oid      sample_type_oid[] =
        { 1, 3, 6, 1, 2, 1, 16, 3, 1, 1, 4 };
    static oid      value_oid[] = { 1, 3, 6, 1, 2, 1, 16, 3, 1, 1, 5 };
    static oid      threshold_oid[] = { 1, 3, 6, 1, 2, 1, 16, 3, 1, 1, 7 };     /* rising case */
    netsnmp_variable_list *top = NULL;
    register int    iii;

    /*
     * set the last 'oid' : risingAlarm or fallingAlarm 
     */
    if (is_rising) {
        iii = OID_LENGTH(rmon1_trap_oid);
        rmon1_trap_oid[iii - 1] = 1;
        iii = OID_LENGTH(threshold_oid);
        threshold_oid[iii - 1] = 7;
    } else {
        iii = OID_LENGTH(rmon1_trap_oid);
        rmon1_trap_oid[iii - 1] = 0;
        iii = OID_LENGTH(threshold_oid);
        threshold_oid[iii - 1] = 8;
    }

    /*
     * build the var list 
     */
    top = oa_bind_var(top, &alarm_index, ASN_INTEGER, sizeof(u_int),
                      alarm_index_oid, OID_LENGTH(alarm_index_oid));

    top =
        oa_bind_var(top, alarmed_var, ASN_OBJECT_ID,
                    sizeof(oid) * alarmed_var_length, alarmed_var_oid,
                    OID_LENGTH(alarmed_var_oid));

    top = oa_bind_var(top, &sample_type, ASN_INTEGER, sizeof(u_int),
                      sample_type_oid, OID_LENGTH(sample_type_oid));

    top = oa_bind_var(top, &value, ASN_INTEGER, sizeof(u_int),
                      value_oid, OID_LENGTH(value_oid));

    top = oa_bind_var(top, &the_threshold, ASN_INTEGER, sizeof(u_int),
                      threshold_oid, OID_LENGTH(threshold_oid));


    send_enterprise_trap_vars(SNMP_TRAP_ENTERPRISESPECIFIC, 0,
                              rmon1_trap_oid,
                              OID_LENGTH(rmon1_trap_oid), top);
    ag_trace("rmon trap has been sent");
    snmp_free_varbind(top);

}