Skip to content

Commit c9aa7c1

Browse files
author
Cacti EDU
committed
1.44: findhosts.php sanity checks
1 parent 04c3a19 commit c9aa7c1

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

README

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Contact ........ eric@ericdives.com
55
Home Site ...... http://runningoffatthemouth.com
66
Program ........ DP Discover
7-
Version ........ 1.43
7+
Version ........ 1.44
88
Purpose ........ Find Network Equipment Using Discovery Protocols
99

1010
*******************************************************************************/
@@ -39,6 +39,9 @@ existing hosts via SNMP, and attempts to add unknown equipment to Cacti.
3939

4040
----[ Changelog
4141

42+
--- 1.44 ---
43+
- Added some sanity checks at the beginning of "findhosts.php" so that if
44+
required things are missing, the check stops running.
4245
--- 1.43 ---
4346
- "disabled" hosts are completely ignored - they are not probed for *dp
4447
information.

findhosts.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@
204204

205205
// Get array of snmp information.
206206
$known_hosts = db_fetch_assoc("SELECT id, host_template_id, description, hostname, snmp_community, snmp_version, snmp_username, snmp_password, snmp_port, snmp_timeout, disabled, availability_method, ping_method, ping_port, ping_timeout, ping_retries, snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, max_oids, device_threads FROM host");
207+
if (!is_array($known_hosts)) {
208+
cacti_log("DP Discover failed to pull known hosts? Exiting.", true, "POLLER");
209+
exit;
210+
}
207211

208212
// Get Oses
209213
$temp = db_fetch_assoc("SELECT plugin_dpdiscover_template.*, host_template.name
@@ -213,10 +217,19 @@
213217

214218
$os = array();
215219
$templates = array();
220+
$count = 0;
216221
if (is_array($temp)) {
217222
foreach ($temp as $d) {
218223
$os[] = $d;
224+
$count++;
219225
}
226+
}else{
227+
cacti_log("DP Discover ended: had issues finding DPDiscover Templates, exiting.", true, "POLLER");
228+
exit;
229+
}
230+
if($count == 0) {
231+
cacti_log("No DP Discover Templates found, exiting.", true, "POLLER");
232+
exit;
220233
}
221234
$temp = db_fetch_assoc("SELECT id, name FROM host_template");
222235
if (is_array($temp)) {
@@ -957,6 +970,9 @@ function dpdiscover_recreate_tables () {
957970

958971
function dpdiscover_find_os($text) {
959972
global $os;
973+
if($text == "") {
974+
return false;
975+
}
960976
for ($a = 0; $a < count($os); $a++) {
961977
if (stristr($text, $os[$a]['sysdescr'])) {
962978
return $os[$a];

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function dpdiscover_check_upgrade () {
122122
function plugin_dpdiscover_version () {
123123
return array(
124124
'name' => 'dpdiscover',
125-
'version' => '1.43',
125+
'version' => '1.44',
126126
'longname' => 'DP Discover',
127127
'author' => 'Eric Stewart',
128128
'homepage' => 'http://runningoffatthemouth.com/?p=1067',

0 commit comments

Comments
 (0)