Lines 168-173
Link Here
|
168 |
MYSQL mysql; |
168 |
MYSQL mysql; |
169 |
MYSQL_RES *result; |
169 |
MYSQL_RES *result; |
170 |
MYSQL_ROW row; |
170 |
MYSQL_ROW row; |
|
|
171 |
MYSQL_FIELD *field; |
171 |
|
172 |
|
172 |
db_connect(set.dbdb, &mysql); |
173 |
db_connect(set.dbdb, &mysql); |
173 |
|
174 |
|
Lines 217-223
Link Here
|
217 |
"status, status_event_count, status_fail_date, " |
218 |
"status, status_event_count, status_fail_date, " |
218 |
"status_rec_date, status_last_error, " |
219 |
"status_rec_date, status_last_error, " |
219 |
"min_time, max_time, cur_time, avg_time, " |
220 |
"min_time, max_time, cur_time, avg_time, " |
220 |
"total_polls, failed_polls, availability " |
221 |
"total_polls, failed_polls, availability, snmp_sysUptimeInstance, snmp_sysDescr, snmp_sysObjectID, " |
|
|
222 |
"snmp_sysContact, snmp_sysName, snmp_sysLocation" |
221 |
" FROM host" |
223 |
" FROM host" |
222 |
" WHERE id=%i", host_id); |
224 |
" WHERE id=%i", host_id); |
223 |
|
225 |
|
Lines 287-293
Link Here
|
287 |
"status, status_event_count, status_fail_date, " |
289 |
"status, status_event_count, status_fail_date, " |
288 |
"status_rec_date, status_last_error, " |
290 |
"status_rec_date, status_last_error, " |
289 |
"min_time, max_time, cur_time, avg_time, " |
291 |
"min_time, max_time, cur_time, avg_time, " |
290 |
"total_polls, failed_polls, availability " |
292 |
"total_polls, failed_polls, availability, snmp_sysUptimeInstance, snmp_sysDescr, snmp_sysObjectID, " |
|
|
293 |
"snmp_sysContact, snmp_sysName, snmp_sysLocation" |
291 |
" FROM host" |
294 |
" FROM host" |
292 |
" WHERE id=%i", host_id); |
295 |
" WHERE id=%i", host_id); |
293 |
|
296 |
|
Lines 376-413
Link Here
|
376 |
|
379 |
|
377 |
if (row) { |
380 |
if (row) { |
378 |
/* initialize variables first */ |
381 |
/* initialize variables first */ |
379 |
host->id = 0; |
382 |
host->id = 0; // 0 |
380 |
host->hostname[0] = '\0'; |
383 |
host->hostname[0] = '\0'; // 1 |
381 |
host->snmp_session = NULL; |
384 |
host->snmp_session = NULL; // - |
382 |
host->snmp_community[0] = '\0'; |
385 |
host->snmp_community[0] = '\0'; // 2 |
383 |
host->snmp_version = 1; |
386 |
host->snmp_version = 1; // 3 |
384 |
host->snmp_username[0] = '\0'; |
387 |
host->snmp_username[0] = '\0'; // 4 |
385 |
host->snmp_password[0] = '\0'; |
388 |
host->snmp_password[0] = '\0'; // 5 |
386 |
host->snmp_auth_protocol[0] = '\0'; |
389 |
host->snmp_auth_protocol[0] = '\0'; // 6 |
387 |
host->snmp_priv_passphrase[0] = '\0'; |
390 |
host->snmp_priv_passphrase[0] = '\0'; // 7 |
388 |
host->snmp_priv_protocol[0] = '\0'; |
391 |
host->snmp_priv_protocol[0] = '\0'; // 8 |
389 |
host->snmp_context[0] = '\0'; |
392 |
host->snmp_context[0] = '\0'; // 9 |
390 |
host->snmp_port = 161; |
393 |
host->snmp_port = 161; // 10 |
391 |
host->snmp_timeout = 500; |
394 |
host->snmp_timeout = 500; // 11 |
392 |
host->snmp_retries = set.snmp_retries; |
395 |
host->snmp_retries = set.snmp_retries; // - |
393 |
host->max_oids = 10; |
396 |
host->max_oids = 10; // 12 |
394 |
host->availability_method = 0; |
397 |
host->availability_method = 0; // 13 |
395 |
host->ping_method = 0; |
398 |
host->ping_method = 0; // 14 |
396 |
host->ping_port = 23; |
399 |
host->ping_port = 23; // 15 |
397 |
host->ping_timeout = 500; |
400 |
host->ping_timeout = 500; // 16 |
398 |
host->ping_retries = 2; |
401 |
host->ping_retries = 2; // 17 |
399 |
host->status = HOST_UP; |
402 |
host->status = HOST_UP; // 18 |
400 |
host->status_event_count = 0; |
403 |
host->status_event_count = 0; // 19 |
401 |
host->status_fail_date[0] = '\0'; |
404 |
host->status_fail_date[0] = '\0'; // 20 |
402 |
host->status_rec_date[0] = '\0'; |
405 |
host->status_rec_date[0] = '\0'; // 21 |
403 |
host->status_last_error[0] = '\0'; |
406 |
host->status_last_error[0] = '\0'; // 22 |
404 |
host->min_time = 0; |
407 |
host->min_time = 0; // 23 |
405 |
host->max_time = 0; |
408 |
host->max_time = 0; // 24 |
406 |
host->cur_time = 0; |
409 |
host->cur_time = 0; // 25 |
407 |
host->avg_time = 0; |
410 |
host->avg_time = 0; // 26 |
408 |
host->total_polls = 0; |
411 |
host->total_polls = 0; // 27 |
409 |
host->failed_polls = 0; |
412 |
host->failed_polls = 0; // 28 |
410 |
host->availability = 100; |
413 |
host->availability = 100; // 29 |
|
|
414 |
host->snmp_sysUpTimeInstance = 0; // 30 |
415 |
host->snmp_sysDescr[0] = '\0'; // 31 |
416 |
host->snmp_sysObjectID[0] = '\0'; // 32 |
417 |
host->snmp_sysContact[0] = '\0'; // 33 |
418 |
host->snmp_sysName[0] = '\0'; // 34 |
419 |
host->snmp_sysLocation[0] = '\0'; // 35 |
411 |
|
420 |
|
412 |
/* populate host structure */ |
421 |
/* populate host structure */ |
413 |
host->ignore_host = FALSE; |
422 |
host->ignore_host = FALSE; |
Lines 451-456
Link Here
|
451 |
if (row[28] != NULL) host->failed_polls = atoi(row[28]); |
460 |
if (row[28] != NULL) host->failed_polls = atoi(row[28]); |
452 |
if (row[29] != NULL) host->availability = atof(row[29]); |
461 |
if (row[29] != NULL) host->availability = atof(row[29]); |
453 |
|
462 |
|
|
|
463 |
if (row[30] != NULL) host->snmp_sysUpTimeInstance=atoi(row[30]); |
464 |
if (row[31] != NULL) STRNCOPY(host->snmp_sysDescr, row[31]); |
465 |
if (row[32] != NULL) STRNCOPY(host->snmp_sysObjectID, row[32]); |
466 |
if (row[33] != NULL) STRNCOPY(host->snmp_sysContact, row[33]); |
467 |
if (row[34] != NULL) STRNCOPY(host->snmp_sysName, row[34]); |
468 |
if (row[35] != NULL) STRNCOPY(host->snmp_sysLocation, row[35]); |
469 |
|
454 |
/* correct max_oid bounds issues */ |
470 |
/* correct max_oid bounds issues */ |
455 |
if ((host->max_oids == 0) || (host->max_oids > 100)) { |
471 |
if ((host->max_oids == 0) || (host->max_oids > 100)) { |
456 |
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)); |
472 |
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)); |
Lines 494-499
Link Here
|
494 |
host->ignore_host = FALSE; |
510 |
host->ignore_host = FALSE; |
495 |
if (host_thread == 1) { |
511 |
if (host_thread == 1) { |
496 |
update_host_status(HOST_UP, host, ping, host->availability_method); |
512 |
update_host_status(HOST_UP, host, ping, host->availability_method); |
|
|
513 |
|
514 |
if (host->availability_method == AVAIL_SNMP) { |
515 |
get_system_information(host, &mysql); |
516 |
|
517 |
|
518 |
} |
497 |
} |
519 |
} |
498 |
}else{ |
520 |
}else{ |
499 |
host->ignore_host = TRUE; |
521 |
host->ignore_host = TRUE; |
Lines 509-515
Link Here
|
509 |
"SET status='%i', status_event_count='%i', status_fail_date='%s'," |
531 |
"SET status='%i', status_event_count='%i', status_fail_date='%s'," |
510 |
" status_rec_date='%s', status_last_error='%s', min_time='%f'," |
532 |
" status_rec_date='%s', status_last_error='%s', min_time='%f'," |
511 |
" max_time='%f', cur_time='%f', avg_time='%f', total_polls='%i'," |
533 |
" max_time='%f', cur_time='%f', avg_time='%f', total_polls='%i'," |
512 |
" failed_polls='%i', availability='%.4f' " |
534 |
" failed_polls='%i', availability='%.4f', snmp_sysDescr='%s', " |
|
|
535 |
" snmp_sysObjectID='%s', snmp_sysUpTimeInstance='%i', " |
536 |
" snmp_sysContact='%s', snmp_sysName='%s', snmp_sysLocation='%s' " |
513 |
"WHERE id='%i'", |
537 |
"WHERE id='%i'", |
514 |
host->status, |
538 |
host->status, |
515 |
host->status_event_count, |
539 |
host->status_event_count, |
Lines 523-528
Link Here
|
523 |
host->total_polls, |
547 |
host->total_polls, |
524 |
host->failed_polls, |
548 |
host->failed_polls, |
525 |
host->availability, |
549 |
host->availability, |
|
|
550 |
host->snmp_sysDescr, |
551 |
host->snmp_sysObjectID, |
552 |
host->snmp_sysUpTimeInstance, |
553 |
host->snmp_sysContact, |
554 |
host->snmp_sysName, |
555 |
host->snmp_sysLocation, |
526 |
host->id); |
556 |
host->id); |
527 |
|
557 |
|
528 |
db_insert(&mysql, update_sql); |
558 |
db_insert(&mysql, update_sql); |
Lines 1255-1260
Link Here
|
1255 |
poll_time = get_time_as_double() - poll_time; |
1285 |
poll_time = get_time_as_double() - poll_time; |
1256 |
SPINE_LOG_MEDIUM(("Host[%i] TH[%i] Total Time: %5.2g Seconds", host_id, host_thread, poll_time)); |
1286 |
SPINE_LOG_MEDIUM(("Host[%i] TH[%i] Total Time: %5.2g Seconds", host_id, host_thread, poll_time)); |
1257 |
|
1287 |
|
|
|
1288 |
query1[0] = '\0'; |
1289 |
snprintf(query1, BUFSIZE, "UPDATE host SET polling_time='%g' WHERE id=%i", poll_time, host_id); |
1290 |
db_query(&mysql, query1); |
1291 |
|
1258 |
mysql_close(&mysql); |
1292 |
mysql_close(&mysql); |
1259 |
|
1293 |
|
1260 |
#ifndef OLD_MYSQL |
1294 |
#ifndef OLD_MYSQL |
Lines 1309-1314
Link Here
|
1309 |
|
1343 |
|
1310 |
} |
1344 |
} |
1311 |
|
1345 |
|
|
|
1346 |
void get_system_information(host_t *host, MYSQL *mysql) { |
1347 |
snmp_oids_t *snmp_oids; |
1348 |
|
1349 |
if (set.mibs) { |
1350 |
int num_oids = 6; |
1351 |
|
1352 |
/* create an array for snmp oids */ |
1353 |
snmp_oids = (snmp_oids_t *) calloc(num_oids, sizeof(snmp_oids_t)); |
1354 |
|
1355 |
/* initialize all the memory to insure we don't get issues */ |
1356 |
memset(snmp_oids, 0, sizeof(snmp_oids_t)*num_oids); |
1357 |
|
1358 |
STRNCOPY(snmp_oids[0].oid, ".1.3.6.1.2.1.1.1.0"); |
1359 |
STRNCOPY(snmp_oids[1].oid, ".1.3.6.1.2.1.1.2.0"); |
1360 |
STRNCOPY(snmp_oids[2].oid, ".1.3.6.1.2.1.1.3.0"); |
1361 |
STRNCOPY(snmp_oids[3].oid, ".1.3.6.1.2.1.1.4.0"); |
1362 |
STRNCOPY(snmp_oids[4].oid, ".1.3.6.1.2.1.1.5.0"); |
1363 |
STRNCOPY(snmp_oids[5].oid, ".1.3.6.1.2.1.1.6.0"); |
1364 |
snmp_get_multi(host, snmp_oids, num_oids); |
1365 |
|
1366 |
mysql_real_escape_string(mysql, host->snmp_sysDescr, snmp_oids[0].result, strlen(snmp_oids[0].result)); |
1367 |
mysql_real_escape_string(mysql, host->snmp_sysObjectID, snmp_oids[1].result, strlen(snmp_oids[1].result)); |
1368 |
host->snmp_sysUpTimeInstance = atoi(snmp_oids[2].result); |
1369 |
mysql_real_escape_string(mysql, host->snmp_sysContact, snmp_oids[3].result, strlen(snmp_oids[3].result)); |
1370 |
mysql_real_escape_string(mysql, host->snmp_sysName, snmp_oids[4].result, strlen(snmp_oids[4].result)); |
1371 |
mysql_real_escape_string(mysql, host->snmp_sysLocation, snmp_oids[5].result, strlen(snmp_oids[5].result)); |
1372 |
}else{ |
1373 |
int num_oids = 1; |
1374 |
|
1375 |
/* create an array for snmp oids */ |
1376 |
snmp_oids = (snmp_oids_t *) calloc(num_oids, sizeof(snmp_oids_t)); |
1377 |
|
1378 |
/* initialize all the memory to insure we don't get issues */ |
1379 |
memset(snmp_oids, 0, sizeof(snmp_oids_t)*num_oids); |
1380 |
|
1381 |
STRNCOPY(snmp_oids[0].oid, ".1.3.6.1.2.1.1.3.0"); |
1382 |
snmp_get_multi(host, snmp_oids, num_oids); |
1383 |
|
1384 |
host->snmp_sysUpTimeInstance = atoi(snmp_oids[2].result); |
1385 |
} |
1386 |
|
1387 |
free(snmp_oids); |
1388 |
} |
1389 |
|
1312 |
/*! \fn int validate_result(char *result) |
1390 |
/*! \fn int validate_result(char *result) |
1313 |
* \brief validates the output from the polling action is valid |
1391 |
* \brief validates the output from the polling action is valid |
1314 |
* \param result the value to be checked for legality |
1392 |
* \param result the value to be checked for legality |