Skip to content

Commit

Permalink
Revise logon::check_defaults to only trigger when NMIS is installed f…
Browse files Browse the repository at this point in the history
…or the integration_pre. Remove logging from this call in integration_nmis_helper and also replace bad PRE log items with correct POST items.
  • Loading branch information
mark-unwin committed Aug 16, 2021
1 parent ebcda41 commit bba2f15
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 97 deletions.
12 changes: 6 additions & 6 deletions code_igniter/application/controllers/logon.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ public function check_defaults()
}

// Run an integration for Linux default only to populate the locations, pollers and groups
if ($this->db->table_exists('integrations') and $this->db->table_exists('integrations_log')) {
if ($this->db->table_exists('integrations') and
$this->db->table_exists('integrations_log') and
php_uname('s') !== 'Windows NT' and
file_exists('/usr/local/nmis9/conf/Config.nmis')) {
$sql = "SELECT id FROM integrations WHERE name = 'Default NMIS Integration' ORDER BY id LIMIT 1";
$query = $this->db->query($sql);
$result = $query->result();
Expand All @@ -437,18 +440,15 @@ public function check_defaults()
$integration = $this->m_integrations->read($result[0]->id);
$integration = $integration[0];
$integration->debug = false;
$integration->log = false;
if (!empty($integration->attributes->attributes->url) and
(stripos($integration->attributes->attributes->url, 'localhost') !== false or
stripos($integration->attributes->attributes->url, '127.0.0.1') !== false or
stripos($integration->attributes->attributes->url, '127.0.1.1') !== false) and
empty($integration->attributes->attributes->username) and
empty($integration->attributes->attributes->password) and
php_uname('s') !== 'Windows NT') {
empty($integration->attributes->attributes->password)) {
// We should be able to run the integration, assuming config auth_token set
$this->load->helper('integrations_nmis');
// Remove any existing logs
$sql = "DELETE FROM integrations_log WHERE integrations_id = ?";
$query = $this->db->query($sql, $integration->id);
integrations_pre($integration);
}
}
Expand Down
Loading

0 comments on commit bba2f15

Please sign in to comment.