diff options
| author | Nathan Kinder <nkinder@redhat.com> | 2005-03-31 00:10:15 +0000 |
|---|---|---|
| committer | Nathan Kinder <nkinder@redhat.com> | 2005-03-31 00:10:15 +0000 |
| commit | 283759753b198ffc18d172c2f5e1fbef5efb0b75 (patch) | |
| tree | 3299de4fccb6a866d2af5b24a58732b9bf8d819d /ldap | |
| parent | b1c0fcde718656bd267ed97c7ff2ae2d861e054f (diff) | |
| download | ds-283759753b198ffc18d172c2f5e1fbef5efb0b75.tar.gz ds-283759753b198ffc18d172c2f5e1fbef5efb0b75.tar.xz ds-283759753b198ffc18d172c2f5e1fbef5efb0b75.zip | |
Update components and SNMP config changes
Diffstat (limited to 'ldap')
| -rw-r--r-- | ldap/schema/00core.ldif | 3 | ||||
| -rw-r--r-- | ldap/servers/slapd/agtmmap.c | 10 | ||||
| -rw-r--r-- | ldap/servers/slapd/agtmmap.h | 5 | ||||
| -rw-r--r-- | ldap/servers/slapd/fedse.c | 3 | ||||
| -rw-r--r-- | ldap/servers/slapd/snmp_collator.c | 82 | ||||
| -rw-r--r-- | ldap/servers/slapd/snmp_collator.h | 12 | ||||
| -rw-r--r-- | ldap/servers/snmp/ldap-agent.c | 44 | ||||
| -rw-r--r-- | ldap/servers/snmp/ldap-agent.h | 5 | ||||
| -rw-r--r-- | ldap/servers/snmp/main.c | 85 |
9 files changed, 155 insertions, 94 deletions
diff --git a/ldap/schema/00core.ldif b/ldap/schema/00core.ldif index 4d04fcd7..1a7d95da 100644 --- a/ldap/schema/00core.ldif +++ b/ldap/schema/00core.ldif @@ -188,6 +188,7 @@ attributeTypes: ( 2.16.840.1.113730.3.1.235 NAME 'nsSNMPContact' DESC 'Netscape attributeTypes: ( 2.16.840.1.113730.3.1.236 NAME 'nsSNMPDescription' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.237 NAME 'nsSNMPMasterHost' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.238 NAME 'nsSNMPMasterPort' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) +attributeTypes: ( 2.16.840.1.113730.3.1.593 NAME 'nsSNMPName' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.241 NAME 'displayName' DESC 'inetOrgPerson attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN 'RFC 2798' ) attributeTypes: ( 2.16.840.1.113730.3.1.242 NAME 'nsSystemIndex' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) attributeTypes: ( 2.16.840.1.113730.3.1.327 NAME 'nsIndexType' DESC 'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'Netscape Directory Server' ) @@ -316,7 +317,7 @@ objectClasses: ( 2.16.840.1.113730.3.2.39 NAME 'nsslapdConfig' DESC 'Netscape de objectClasses: ( 2.16.840.1.113730.3.2.40 NAME 'directoryServerFeature' DESC 'Netscape defined objectclass' SUP top MAY ( oid $ cn $ multiLineDescription ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.41 NAME 'nsslapdPlugin' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsslapd-pluginPath $ nsslapd-pluginInitFunc $ nsslapd-pluginType $ nsslapd-pluginId $ nsslapd-pluginVersion $ nsslapd-pluginVendor $ nsslapd-pluginDescription $ nsslapd-pluginEnabled ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.42 NAME 'vlvIndex' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ vlvSort ) MAY ( vlvEnabled $ vlvUses ) X-ORIGIN 'Netscape Directory Server' ) -objectClasses: ( 2.16.840.1.113730.3.2.43 NAME 'nsSNMP' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSNMPEnabled ) MAY ( nsSNMPOrganization $ nsSNMPLocation $ nsSNMPContact $ nsSNMPDescription $ nsSNMPMasterHost $ nsSNMPMasterPort ) X-ORIGIN 'Netscape Directory Server' ) +objectClasses: ( 2.16.840.1.113730.3.2.43 NAME 'nsSNMP' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSNMPEnabled ) MAY ( nsSNMPOrganization $ nsSNMPLocation $ nsSNMPContact $ nsSNMPDescription $ nsSNMPName $ nsSNMPMasterHost $ nsSNMPMasterPort ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.44 NAME 'nsIndex' DESC 'Netscape defined objectclass' SUP top MUST ( cn $ nsSystemIndex ) MAY ( description $ nsIndexType $ nsMatchingRule ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113730.3.2.84 NAME 'cosDefinition' DESC 'Netscape defined objectclass' SUP top MAY ( costargettree $ costemplatedn $ cosspecifier $ cosattribute $ aci $ cn $ uid ) X-ORIGIN 'Netscape Directory Server' ) objectClasses: ( 2.16.840.1.113719.2.142.6.1.1 NAME 'ldapSubEntry' DESC 'LDAP Subentry class, version 1' SUP top STRUCTURAL MAY ( cn ) X-ORIGIN 'LDAP Subentry Internet Draft' ) diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c index c67282cb..453e999d 100644 --- a/ldap/servers/slapd/agtmmap.c +++ b/ldap/servers/slapd/agtmmap.c @@ -357,6 +357,16 @@ agt_mread_stats (int hdl, struct hdr_stats_t *pHdrInfo, struct ops_stats_t *pDsO pHdrInfo->updateTime = pfile_stats->hdr_stats.updateTime; strncpy(pHdrInfo->dsVersion, pfile_stats->hdr_stats.dsVersion, (sizeof(pHdrInfo->dsVersion)/sizeof(char)) - 1); + strncpy(pHdrInfo->dsName, pfile_stats->hdr_stats.dsName, + (sizeof(pHdrInfo->dsName)/sizeof(char)) - 1); + strncpy(pHdrInfo->dsDescription, pfile_stats->hdr_stats.dsDescription, + (sizeof(pHdrInfo->dsDescription)/sizeof(char)) - 1); + strncpy(pHdrInfo->dsOrganization, pfile_stats->hdr_stats.dsOrganization, + (sizeof(pHdrInfo->dsOrganization)/sizeof(char)) - 1); + strncpy(pHdrInfo->dsLocation, pfile_stats->hdr_stats.dsLocation, + (sizeof(pHdrInfo->dsLocation)/sizeof(char)) - 1); + strncpy(pHdrInfo->dsContact, pfile_stats->hdr_stats.dsContact, + (sizeof(pHdrInfo->dsContact)/sizeof(char)) - 1); } if (pDsOpsTbl != NULL) { diff --git a/ldap/servers/slapd/agtmmap.h b/ldap/servers/slapd/agtmmap.h index 330475e9..f3cf81d1 100644 --- a/ldap/servers/slapd/agtmmap.h +++ b/ldap/servers/slapd/agtmmap.h @@ -72,6 +72,11 @@ struct hdr_stats_t{ time_t startTime; time_t updateTime; char dsVersion[100]; + char dsName[30]; + char dsDescription[30]; + char dsOrganization[30]; + char dsLocation[30]; + char dsContact[30]; }; struct ops_stats_t{ diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c index f636a530..bf75fc0a 100644 --- a/ldap/servers/slapd/fedse.c +++ b/ldap/servers/slapd/fedse.c @@ -105,8 +105,9 @@ static const char *internal_entries[] = "dn:cn=SNMP,cn=config\n" "objectclass:top\n" "objectclass:nsSNMP\n" - "cn:SNMP\n" + "cn:SNMP\n" "nsSNMPEnabled:on\n" + "nsSNMPName:\n" "nsSNMPOrganization:\n" "nsSNMPLocation:\n" "nsSNMPContact:\n" diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c index 3c0f5e65..7613edb0 100644 --- a/ldap/servers/slapd/snmp_collator.c +++ b/ldap/servers/slapd/snmp_collator.c @@ -35,6 +35,9 @@ char *make_ds_url(char *host, int port); void print_snmp_interaction_table(); int search_interaction_table(char *dsURL, int *isnew); +static void loadConfigStats(); +static Slapi_Entry *getConfigEntry( Slapi_Entry **e ); +static void freeConfigEntry( Slapi_Entry **e ); /* snmp stats stuff */ struct agt_stats_t *stats=NULL; @@ -81,6 +84,9 @@ int snmp_collator_init(){ stats->hdr_stats.restarted = 0; stats->hdr_stats.startTime = time(0); /* This is a bit off, hope it's ok */ + /* load config stats */ + loadConfigStats(); + /* point these at the mmaped data */ g_get_global_snmp_vars()->ops_tbl.dsAnonymousBinds = &(stats->ops_stats.dsAnonymousBinds); g_get_global_snmp_vars()->ops_tbl.dsUnAuthBinds = &(stats->ops_stats.dsUnAuthBinds); @@ -380,10 +386,11 @@ int snmp_collator_start() } } - +/* read config entry for entity table data */ + /* point stats struct at mmap data */ - stats = (struct agt_stats_t *) mmap_tbl [hdl].fp; + stats = (struct agt_stats_t *) mmap_tbl [hdl].fp; /* initialize stats data */ @@ -605,7 +612,78 @@ snmp_as_entry(Slapi_Entry *e) add_counter_to_value(e,"SlaveHits",stats->entries_stats.dsSlaveHits); } +static void +loadConfigStats() { + Slapi_Entry *entry = NULL; + char *name = NULL; + char *desc = NULL; + char *org = NULL; + char *loc = NULL; + char *contact = NULL; + + /* Read attributes from SNMP config entry */ + getConfigEntry( &entry ); + if ( entry != NULL ) { + name = slapi_entry_attr_get_charptr( entry, SNMP_NAME_ATTR ); + desc = slapi_entry_attr_get_charptr( entry, SNMP_DESC_ATTR ); + org = slapi_entry_attr_get_charptr( entry, SNMP_ORG_ATTR ); + loc = slapi_entry_attr_get_charptr( entry, SNMP_LOC_ATTR ); + contact = slapi_entry_attr_get_charptr( entry, SNMP_CONTACT_ATTR ); + freeConfigEntry( &entry ); + } + + /* Load stats into table */ + if ( name != NULL) { + strncpy(stats->hdr_stats.dsName, name, + (sizeof(stats->hdr_stats.dsName)/sizeof(char)) - 1); + } + + if ( desc != NULL) { + strncpy(stats->hdr_stats.dsDescription, desc, + (sizeof(stats->hdr_stats.dsDescription)/sizeof(char)) - 1); + } + + if ( org != NULL) { + strncpy(stats->hdr_stats.dsOrganization, org, + (sizeof(stats->hdr_stats.dsOrganization)/sizeof(char)) - 1); + } + + if ( loc != NULL) { + strncpy(stats->hdr_stats.dsLocation, loc, + (sizeof(stats->hdr_stats.dsLocation)/sizeof(char)) - 1); + } + + if ( contact != NULL) { + strncpy(stats->hdr_stats.dsContact, contact, + (sizeof(stats->hdr_stats.dsContact)/sizeof(char)) - 1); + } + + /* Free strings */ + slapi_ch_free((void **) &name); + slapi_ch_free((void **) &desc); + slapi_ch_free((void **) &org); + slapi_ch_free((void **) &loc); + slapi_ch_free((void **) &contact); +} +static Slapi_Entry * +getConfigEntry( Slapi_Entry **e ) { + Slapi_DN sdn; + + slapi_sdn_init_dn_byref( &sdn, SNMP_CONFIG_DN ); + slapi_search_internal_get_entry( &sdn, NULL, e, + plugin_get_default_component_id()); + slapi_sdn_done( &sdn ); + return *e; +} + +static void +freeConfigEntry( Slapi_Entry **e ) { + if ( (e != NULL) && (*e != NULL) ) { + slapi_entry_free( *e ); + *e = NULL; + } +} diff --git a/ldap/servers/slapd/snmp_collator.h b/ldap/servers/slapd/snmp_collator.h index 77dd4bc1..d9406518 100644 --- a/ldap/servers/slapd/snmp_collator.h +++ b/ldap/servers/slapd/snmp_collator.h @@ -5,6 +5,18 @@ * END COPYRIGHT BLOCK **/ /****************************************************************************** * +* defines +* +******************************************************************************/ +#define SNMP_CONFIG_DN "cn=SNMP,cn=config" +#define SNMP_NAME_ATTR "nsSNMPName" +#define SNMP_DESC_ATTR "nsSNMPDescription" +#define SNMP_ORG_ATTR "nsSNMPOrganization" +#define SNMP_LOC_ATTR "nsSNMPLocation" +#define SNMP_CONTACT_ATTR "nsSNMPContact" + +/****************************************************************************** +* * function prototypes * ******************************************************************************/ diff --git a/ldap/servers/snmp/ldap-agent.c b/ldap/servers/snmp/ldap-agent.c index 12bc5db4..b2a62afe 100644 --- a/ldap/servers/snmp/ldap-agent.c +++ b/ldap/servers/snmp/ldap-agent.c @@ -40,8 +40,6 @@ init_ldap_agent(void) { server_instance *serv_p = NULL; stats_table_context *new_row = NULL; - int err; - int stats_hdl = -1; /* Define and create the table */ initialize_stats_table(); @@ -229,7 +227,6 @@ load_stats_table(netsnmp_cache *cache, void *foo) { server_instance *serv_p = NULL; stats_table_context *ctx = NULL; - netsnmp_variable_list *vars = NULL; time_t previous_start; int previous_state; int stats_hdl = -1; @@ -527,14 +524,13 @@ dsEntityTable_get_value(netsnmp_request_info *request, { netsnmp_variable_list *var = request->requestvb; stats_table_context *context = (stats_table_context *) item; - server_instance *server = (server_instance *) context->entity_tbl; switch (table_info->colnum) { case COLUMN_DSENTITYDESCR: snmp_set_var_typed_value(var, ASN_OCTET_STR, - (u_char *) server->description, - strlen(server->description)); + (u_char *) context->hdr_tbl.dsDescription, + strlen(context->hdr_tbl.dsDescription)); break; case COLUMN_DSENTITYVERS: @@ -545,26 +541,26 @@ dsEntityTable_get_value(netsnmp_request_info *request, case COLUMN_DSENTITYORG: snmp_set_var_typed_value(var, ASN_OCTET_STR, - (u_char *) server->org, - strlen(server->org)); + (u_char *) context->hdr_tbl.dsOrganization, + strlen(context->hdr_tbl.dsOrganization)); break; case COLUMN_DSENTITYLOCATION: snmp_set_var_typed_value(var, ASN_OCTET_STR, - (u_char *) server->location, - strlen(server->location)); + (u_char *) context->hdr_tbl.dsLocation, + strlen(context->hdr_tbl.dsLocation)); break; case COLUMN_DSENTITYCONTACT: snmp_set_var_typed_value(var, ASN_OCTET_STR, - (u_char *) server->contact, - strlen(server->contact)); + (u_char *) context->hdr_tbl.dsContact, + strlen(context->hdr_tbl.dsContact)); break; case COLUMN_DSENTITYNAME: snmp_set_var_typed_value(var, ASN_OCTET_STR, - (u_char *) server->name, - strlen(server->name)); + (u_char *) context->hdr_tbl.dsName, + strlen(context->hdr_tbl.dsName)); break; default:/* We shouldn't get here */ @@ -614,8 +610,8 @@ send_DirectoryServerDown_trap(server_instance *serv_p) snmp_varlist_add_variable(&var_list, dsEntityDescr_oid, OID_LENGTH(dsEntityDescr_oid), ASN_OCTET_STR, - (u_char *) serv_p->description, - strlen(serv_p->description)); + (u_char *) ctx->hdr_tbl.dsDescription, + strlen(ctx->hdr_tbl.dsDescription)); snmp_varlist_add_variable(&var_list, dsEntityVers_oid, OID_LENGTH(dsEntityVers_oid), ASN_OCTET_STR, @@ -625,14 +621,14 @@ send_DirectoryServerDown_trap(server_instance *serv_p) dsEntityLocation_oid, OID_LENGTH(dsEntityLocation_oid), ASN_OCTET_STR, - (u_char *) serv_p->location, - strlen(serv_p->location)); + (u_char *) ctx->hdr_tbl.dsLocation, + strlen(ctx->hdr_tbl.dsLocation)); snmp_varlist_add_variable(&var_list, dsEntityContact_oid, OID_LENGTH(dsEntityContact_oid), ASN_OCTET_STR, - (u_char *) serv_p->contact, - strlen(serv_p->contact)); + (u_char *) ctx->hdr_tbl.dsContact, + strlen(ctx->hdr_tbl.dsContact)); /* Send the trap */ send_v2trap(var_list); @@ -679,8 +675,8 @@ send_DirectoryServerStart_trap(server_instance *serv_p) snmp_varlist_add_variable(&var_list, dsEntityDescr_oid, OID_LENGTH(dsEntityDescr_oid), ASN_OCTET_STR, - (u_char *) serv_p->description, - strlen(serv_p->description)); + (u_char *) ctx->hdr_tbl.dsDescription, + strlen(ctx->hdr_tbl.dsDescription)); snmp_varlist_add_variable(&var_list, dsEntityVers_oid, OID_LENGTH(dsEntityVers_oid), ASN_OCTET_STR, @@ -690,8 +686,8 @@ send_DirectoryServerStart_trap(server_instance *serv_p) dsEntityLocation_oid, OID_LENGTH(dsEntityLocation_oid), ASN_OCTET_STR, - (u_char *) serv_p->location, - strlen(serv_p->location)); + (u_char *) ctx->hdr_tbl.dsLocation, + strlen(ctx->hdr_tbl.dsLocation)); /* Send the trap */ send_v2trap(var_list); diff --git a/ldap/servers/snmp/ldap-agent.h b/ldap/servers/snmp/ldap-agent.h index 250a3d60..084d3623 100644 --- a/ldap/servers/snmp/ldap-agent.h +++ b/ldap/servers/snmp/ldap-agent.h @@ -39,11 +39,6 @@ typedef struct server_instance_s { int server_state; char *stats_file; char *dse_ldif; - char *description; - char *org; - char *location; - char *contact; - char *name; struct server_instance_s *next; } server_instance; diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c index 3d5e654d..9836b066 100644 --- a/ldap/servers/snmp/main.c +++ b/ldap/servers/snmp/main.c @@ -111,8 +111,9 @@ main (int argc, char *argv[]) { strcat((char *) log_hdl->token, LDAP_AGENT_LOGFILE); } } else { - /* agent-logdir not set, so write locally */ - log_hdl->token = strdup(LDAP_AGENT_LOGFILE); + /* agent-logdir not set */ + printf("ldap-agent: Error determining log directory.\n"); + exit(1); } netsnmp_enable_filelog(log_hdl, 1); @@ -202,6 +203,13 @@ load_config(char *conf_path) char *p = NULL; char *p2 = NULL; + /* Make sure we are getting an absolute path */ + if (*conf_path != '/') { + printf("ldap-agent: Error opening config file: %s\n", conf_path); + printf("ldap-agent: You must specify the absolute path to your config file\n"); + exit(1); + } + /* Open config file */ if ((conf_file = fopen(conf_path, "r")) == NULL) { printf("ldap-agent: Error opening config file: %s\n", conf_path); @@ -211,10 +219,19 @@ load_config(char *conf_path) /* set pidfile path */ for (p = (conf_path + strlen(conf_path) - 1); p >= conf_path; p--) { if (*p == '/') { + /* set pidfile path */ if ((pidfile = malloc((p - conf_path) + strlen(LDAP_AGENT_PIDFILE) + 2)) != NULL) { strncpy(pidfile, conf_path, (p - conf_path + 1)); strcat(pidfile, LDAP_AGENT_PIDFILE); + } else { + printf("ldap-agent: malloc error processing config file\n"); + exit(1); + } + + /* set default logdir to location of config file */ + if ((agent_logdir = malloc((p - conf_path) + 1)) != NULL) { + strncpy(agent_logdir, conf_path, (p - conf_path)); break; } else { printf("ldap-agent: malloc error processing config file\n"); @@ -236,6 +253,11 @@ load_config(char *conf_path) strcpy(agentx_master, p); } } else if ((p = strstr(line, "agent-logdir")) != NULL) { + /* free the default logdir setting */ + if (agent_logdir != NULL) { + free(agent_logdir); + } + /* load agent-logdir setting */ p = p + 12; if ((p = strtok(p, " \t\n")) != NULL) { @@ -259,65 +281,6 @@ load_config(char *conf_path) if ((serv_p->dse_ldif = malloc(strlen(p) + 17)) != NULL) { snprintf(serv_p->dse_ldif, strlen(p) + 17, "%s/config/dse.ldif", p); } - - /* second token is the name */ - p = p2; - if((p2 = strchr(p, ':')) != NULL) { - *p2 = '\0'; - ++p2; - if ((serv_p->name = malloc(strlen(p) + 1)) != NULL) - snprintf(serv_p->name, strlen(p) + 1, "%s", p); - } else { - printf("ldap-agent: Invalid config file\n"); - exit(1); - } - - /* third token is the description */ - p = p2; - if((p2 = strchr(p, ':')) != NULL) { - *p2 = '\0'; - ++p2; - if ((serv_p->description = malloc(strlen(p) + 1)) != NULL) - snprintf(serv_p->description, strlen(p) + 1, "%s", p); - } else { - printf("ldap-agent: Invalid config file\n"); - exit(1); - } - - /* fourth token is the org */ - p = p2; - if((p2 = strchr(p, ':')) != NULL) { - *p2 = '\0'; - ++p2; - if ((serv_p->org = malloc(strlen(p) + 1)) != NULL) - snprintf(serv_p->org, strlen(p) + 1, "%s", p); - } else { - printf("ldap-agent: Invalid config file\n"); - exit(1); - } - - /* fifth token is the location */ - p = p2; - if((p2 = strchr(p, ':')) != NULL) { - *p2 = '\0'; - ++p2; - if ((serv_p->location = malloc(strlen(p) + 1)) != NULL) - snprintf(serv_p->location, strlen(p) + 1, "%s", p); - } else { - printf("ldap-agent: Invalid config file\n"); - exit(1); - } - - /* sixth token is the contact */ - p = p2; - if((p2 = strchr(p, '\n')) != NULL) { - *p2 = '\0'; - if ((serv_p->contact = malloc(strlen(p) + 1)) != NULL) - snprintf(serv_p->contact, strlen(p) + 1, "%s", p); - } else { - printf("ldap-agent: Invalid config file\n"); - exit(1); - } } /* Open dse.ldif */ |
