summaryrefslogtreecommitdiffstats
path: root/ldap/servers/snmp
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2005-03-31 00:10:15 +0000
committerNathan Kinder <nkinder@redhat.com>2005-03-31 00:10:15 +0000
commit283759753b198ffc18d172c2f5e1fbef5efb0b75 (patch)
tree3299de4fccb6a866d2af5b24a58732b9bf8d819d /ldap/servers/snmp
parentb1c0fcde718656bd267ed97c7ff2ae2d861e054f (diff)
downloadds-283759753b198ffc18d172c2f5e1fbef5efb0b75.tar.gz
ds-283759753b198ffc18d172c2f5e1fbef5efb0b75.tar.xz
ds-283759753b198ffc18d172c2f5e1fbef5efb0b75.zip
Update components and SNMP config changes
Diffstat (limited to 'ldap/servers/snmp')
-rw-r--r--ldap/servers/snmp/ldap-agent.c44
-rw-r--r--ldap/servers/snmp/ldap-agent.h5
-rw-r--r--ldap/servers/snmp/main.c85
3 files changed, 44 insertions, 90 deletions
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 */