You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-analyzer/cacti-spine/files/cacti-spine-0.8.8d-polling_...

221 lines
8.7 KiB

--- a/poller.c
+++ b/poller.c
@@ -168,7 +168,6 @@
MYSQL mysql;
MYSQL_RES *result;
MYSQL_ROW row;
- MYSQL_FIELD *field;
db_connect(set.dbdb, &mysql);
@@ -218,8 +217,7 @@
"status, status_event_count, status_fail_date, "
"status_rec_date, status_last_error, "
"min_time, max_time, cur_time, avg_time, "
- "total_polls, failed_polls, availability, snmp_sysUptimeInstance, snmp_sysDescr, snmp_sysObjectID, "
- "snmp_sysContact, snmp_sysName, snmp_sysLocation"
+ "total_polls, failed_polls, availability "
" FROM host"
" WHERE id=%i", host_id);
@@ -289,8 +287,7 @@
"status, status_event_count, status_fail_date, "
"status_rec_date, status_last_error, "
"min_time, max_time, cur_time, avg_time, "
- "total_polls, failed_polls, availability, snmp_sysUptimeInstance, snmp_sysDescr, snmp_sysObjectID, "
- "snmp_sysContact, snmp_sysName, snmp_sysLocation"
+ "total_polls, failed_polls, availability "
" FROM host"
" WHERE id=%i", host_id);
@@ -379,44 +376,38 @@
if (row) {
/* initialize variables first */
- host->id = 0; // 0
- host->hostname[0] = '\0'; // 1
- host->snmp_session = NULL; // -
- host->snmp_community[0] = '\0'; // 2
- host->snmp_version = 1; // 3
- host->snmp_username[0] = '\0'; // 4
- host->snmp_password[0] = '\0'; // 5
- host->snmp_auth_protocol[0] = '\0'; // 6
- host->snmp_priv_passphrase[0] = '\0'; // 7
- host->snmp_priv_protocol[0] = '\0'; // 8
- host->snmp_context[0] = '\0'; // 9
- host->snmp_port = 161; // 10
- host->snmp_timeout = 500; // 11
- host->snmp_retries = set.snmp_retries; // -
- host->max_oids = 10; // 12
- host->availability_method = 0; // 13
- host->ping_method = 0; // 14
- host->ping_port = 23; // 15
- host->ping_timeout = 500; // 16
- host->ping_retries = 2; // 17
- host->status = HOST_UP; // 18
- host->status_event_count = 0; // 19
- host->status_fail_date[0] = '\0'; // 20
- host->status_rec_date[0] = '\0'; // 21
- host->status_last_error[0] = '\0'; // 22
- host->min_time = 0; // 23
- host->max_time = 0; // 24
- host->cur_time = 0; // 25
- host->avg_time = 0; // 26
- host->total_polls = 0; // 27
- host->failed_polls = 0; // 28
- host->availability = 100; // 29
- host->snmp_sysUpTimeInstance = 0; // 30
- host->snmp_sysDescr[0] = '\0'; // 31
- host->snmp_sysObjectID[0] = '\0'; // 32
- host->snmp_sysContact[0] = '\0'; // 33
- host->snmp_sysName[0] = '\0'; // 34
- host->snmp_sysLocation[0] = '\0'; // 35
+ host->id = 0;
+ host->hostname[0] = '\0';
+ host->snmp_session = NULL;
+ host->snmp_community[0] = '\0';
+ host->snmp_version = 1;
+ host->snmp_username[0] = '\0';
+ host->snmp_password[0] = '\0';
+ host->snmp_auth_protocol[0] = '\0';
+ host->snmp_priv_passphrase[0] = '\0';
+ host->snmp_priv_protocol[0] = '\0';
+ host->snmp_context[0] = '\0';
+ host->snmp_port = 161;
+ host->snmp_timeout = 500;
+ host->snmp_retries = set.snmp_retries;
+ host->max_oids = 10;
+ host->availability_method = 0;
+ host->ping_method = 0;
+ host->ping_port = 23;
+ host->ping_timeout = 500;
+ host->ping_retries = 2;
+ host->status = HOST_UP;
+ host->status_event_count = 0;
+ host->status_fail_date[0] = '\0';
+ host->status_rec_date[0] = '\0';
+ host->status_last_error[0] = '\0';
+ host->min_time = 0;
+ host->max_time = 0;
+ host->cur_time = 0;
+ host->avg_time = 0;
+ host->total_polls = 0;
+ host->failed_polls = 0;
+ host->availability = 100;
/* populate host structure */
host->ignore_host = FALSE;
@@ -460,13 +451,6 @@
if (row[28] != NULL) host->failed_polls = atoi(row[28]);
if (row[29] != NULL) host->availability = atof(row[29]);
- if (row[30] != NULL) host->snmp_sysUpTimeInstance=atoi(row[30]);
- if (row[31] != NULL) STRNCOPY(host->snmp_sysDescr, row[31]);
- if (row[32] != NULL) STRNCOPY(host->snmp_sysObjectID, row[32]);
- if (row[33] != NULL) STRNCOPY(host->snmp_sysContact, row[33]);
- if (row[34] != NULL) STRNCOPY(host->snmp_sysName, row[34]);
- if (row[35] != NULL) STRNCOPY(host->snmp_sysLocation, row[35]);
-
/* correct max_oid bounds issues */
if ((host->max_oids == 0) || (host->max_oids > 100)) {
SPINE_LOG(("Host[%i] TH[%i] WARNING: Max OIDS is out of range with value of '%i'. Resetting to default of 5", host_id, host_thread, host->max_oids));
@@ -510,12 +494,6 @@
host->ignore_host = FALSE;
if (host_thread == 1) {
update_host_status(HOST_UP, host, ping, host->availability_method);
-
- if (host->availability_method == AVAIL_SNMP) {
- get_system_information(host, &mysql);
-
-
- }
}
}else{
host->ignore_host = TRUE;
@@ -531,9 +509,7 @@
"SET status='%i', status_event_count='%i', status_fail_date='%s',"
" status_rec_date='%s', status_last_error='%s', min_time='%f',"
" max_time='%f', cur_time='%f', avg_time='%f', total_polls='%i',"
- " failed_polls='%i', availability='%.4f', snmp_sysDescr='%s', "
- " snmp_sysObjectID='%s', snmp_sysUpTimeInstance='%i', "
- " snmp_sysContact='%s', snmp_sysName='%s', snmp_sysLocation='%s' "
+ " failed_polls='%i', availability='%.4f' "
"WHERE id='%i'",
host->status,
host->status_event_count,
@@ -547,12 +523,6 @@
host->total_polls,
host->failed_polls,
host->availability,
- host->snmp_sysDescr,
- host->snmp_sysObjectID,
- host->snmp_sysUpTimeInstance,
- host->snmp_sysContact,
- host->snmp_sysName,
- host->snmp_sysLocation,
host->id);
db_insert(&mysql, update_sql);
@@ -1285,10 +1255,6 @@
poll_time = get_time_as_double() - poll_time;
SPINE_LOG_MEDIUM(("Host[%i] TH[%i] Total Time: %5.2g Seconds", host_id, host_thread, poll_time));
- query1[0] = '\0';
- snprintf(query1, BUFSIZE, "UPDATE host SET polling_time='%g' WHERE id=%i", poll_time, host_id);
- db_query(&mysql, query1);
-
mysql_close(&mysql);
#ifndef OLD_MYSQL
@@ -1343,50 +1309,6 @@
}
-void get_system_information(host_t *host, MYSQL *mysql) {
- snmp_oids_t *snmp_oids;
-
- if (set.mibs) {
- int num_oids = 6;
-
- /* create an array for snmp oids */
- snmp_oids = (snmp_oids_t *) calloc(num_oids, sizeof(snmp_oids_t));
-
- /* initialize all the memory to insure we don't get issues */
- memset(snmp_oids, 0, sizeof(snmp_oids_t)*num_oids);
-
- STRNCOPY(snmp_oids[0].oid, ".1.3.6.1.2.1.1.1.0");
- STRNCOPY(snmp_oids[1].oid, ".1.3.6.1.2.1.1.2.0");
- STRNCOPY(snmp_oids[2].oid, ".1.3.6.1.2.1.1.3.0");
- STRNCOPY(snmp_oids[3].oid, ".1.3.6.1.2.1.1.4.0");
- STRNCOPY(snmp_oids[4].oid, ".1.3.6.1.2.1.1.5.0");
- STRNCOPY(snmp_oids[5].oid, ".1.3.6.1.2.1.1.6.0");
- snmp_get_multi(host, snmp_oids, num_oids);
-
- mysql_real_escape_string(mysql, host->snmp_sysDescr, snmp_oids[0].result, strlen(snmp_oids[0].result));
- mysql_real_escape_string(mysql, host->snmp_sysObjectID, snmp_oids[1].result, strlen(snmp_oids[1].result));
- host->snmp_sysUpTimeInstance = atoi(snmp_oids[2].result);
- mysql_real_escape_string(mysql, host->snmp_sysContact, snmp_oids[3].result, strlen(snmp_oids[3].result));
- mysql_real_escape_string(mysql, host->snmp_sysName, snmp_oids[4].result, strlen(snmp_oids[4].result));
- mysql_real_escape_string(mysql, host->snmp_sysLocation, snmp_oids[5].result, strlen(snmp_oids[5].result));
- }else{
- int num_oids = 1;
-
- /* create an array for snmp oids */
- snmp_oids = (snmp_oids_t *) calloc(num_oids, sizeof(snmp_oids_t));
-
- /* initialize all the memory to insure we don't get issues */
- memset(snmp_oids, 0, sizeof(snmp_oids_t)*num_oids);
-
- STRNCOPY(snmp_oids[0].oid, ".1.3.6.1.2.1.1.3.0");
- snmp_get_multi(host, snmp_oids, num_oids);
-
- host->snmp_sysUpTimeInstance = atoi(snmp_oids[2].result);
- }
-
- free(snmp_oids);
-}
-
/*! \fn int validate_result(char *result)
* \brief validates the output from the polling action is valid
* \param result the value to be checked for legality