/** * @see PluginOcsinventoryngOcsClient::getSnmp() * @param array $options * @return array */ public function getSnmp($options) { if (isset($options['OFFSET'])) { $offset = "OFFSET " . $options['OFFSET']; } else { $offset = ""; } if (isset($options['MAX_RECORDS'])) { $max_records = "LIMIT " . $options['MAX_RECORDS']; } else { $max_records = ""; } if (isset($options['ORDER'])) { $order = $options['ORDER']; } else { $order = " LASTDATE "; } if (isset($options['FILTER'])) { $filters = $options['FILTER']; if (isset($filters['IDS']) and $filters['IDS']) { $ids = $filters['IDS']; $where_ids = " AND snmp.ID IN ("; $where_ids .= join(',', $ids); $where_ids .= ") "; } else { $where_ids = ""; } if (isset($filters['EXCLUDE_IDS']) and $filters['EXCLUDE_IDS']) { $exclude_ids = $filters['EXCLUDE_IDS']; $where_exclude_ids = " AND snmp.ID NOT IN ("; $where_exclude_ids .= join(',', $exclude_ids); $where_exclude_ids .= ") "; } else { $where_exclude_ids = ""; } if (isset($filters['DEVICEIDS']) and $filters['DEVICEIDS']) { $deviceids = $filters['DEVICEIDS']; $where_deviceids = " AND snmp.SNMPDEVICEID IN ('"; $where_deviceids .= join('\',\'', $deviceids); $where_deviceids .= "') "; } else { $where_deviceids = ""; } if (isset($filters['EXCLUDE_DEVICEIDS']) and $filters['EXCLUDE_DEVICEIDS']) { $exclude_deviceids = $filters['EXCLUDE_DEVICEIDS']; $where_exclude_deviceids = " AND snmp.SNMPDEVICEID NOT IN ("; $where_exclude_deviceids .= join(',', $exclude_deviceids); $where_exclude_deviceids .= ") "; } else { $where_exclude_deviceids = ""; } if (isset($filters['INVENTORIED_SINCE']) and $filters['INVENTORIED_SINCE']) { $since = $filters['INVENTORIED_SINCE']; $where_since = " AND (`snmp`.`LASTDATE` > "; $where_since .= "'" . $since . "'"; $where_since .= ") "; } else { $where_since = ""; } if (isset($filters['INVENTORIED_BEFORE']) and $filters['INVENTORIED_BEFORE']) { $before = $filters['INVENTORIED_BEFORE']; $where_before = " AND (UNIX_TIMESTAMP(`snmp`.`LASTDATE`) < (UNIX_TIMESTAMP(" . $before . ")-180"; // $where_before .= "'" .$before. "'"; $where_before .= ")) "; } else { $where_before = ""; } if (isset($filters['CHECKSUM']) and $filters['CHECKSUM']) { $checksum = $filters['CHECKSUM']; $where_checksum = " AND ('" . $checksum . "' & snmp.CHECKSUM) "; } else { $where_checksum = ""; } $where_condition = $where_ids . $where_exclude_ids . $where_deviceids . $where_exclude_deviceids . $where_checksum . $where_since . $where_before; } else { $where_condition = ""; } $query = "SELECT DISTINCT snmp.ID FROM snmp, snmp_accountinfo\n WHERE snmp.SNMPDEVICEID NOT LIKE '\\_%'\n AND snmp.ID = snmp_accountinfo.SNMP_ID\n {$where_condition}"; $request = $this->db->query($query); if ($this->db->numrows($request)) { $count = $this->db->numrows($request); $query = "SELECT DISTINCT snmp.ID, snmp.NAME FROM snmp, snmp_accountinfo\n WHERE snmp.SNMPDEVICEID NOT LIKE '\\_%'\n AND snmp.ID = snmp_accountinfo.SNMP_ID\n {$where_condition}\n ORDER BY {$order}\n {$max_records} {$offset}"; $request = $this->db->query($query); $this->getAccountInfoColumns(); while ($snmpid = $this->db->fetch_assoc($request)) { $snmpids[] = $snmpid['ID']; } $res["TOTAL_COUNT"] = $count; // if (isset($options['DISPLAY']['CHECKSUM'])) { // $checksum = $options['DISPLAY']['CHECKSUM']; // } else { // $checksum = self::CHECKSUM_NONE; // } // if (isset($options['DISPLAY']['WANTED'])) { // $wanted = $options['DISPLAY']['WANTED']; // } else { // $wanted = self::WANTED_NONE; // } $complete = 1; if (isset($options['COMPLETE'])) { $complete = $options['COMPLETE']; } $res["SNMP"] = $this->getSnmpSections($snmpids, $complete); } else { $res = array(); } return $res; }
/** * @see PluginOcsinventoryngOcsClient::getComputers() */ public function getComputers($options) { if (isset($options['OFFSET'])) { $offset = "OFFSET " . $options['OFFSET']; } else { $offset = ""; } if (isset($options['MAX_RECORDS'])) { $max_records = "LIMIT " . $options['MAX_RECORDS']; } else { $max_records = ""; } if (isset($options['ORDER'])) { $order = $options['ORDER']; } else { $order = " LASTDATE "; } if (isset($options['FILTER'])) { $filters = $options['FILTER']; if (isset($filters['IDS']) and $filters['IDS']) { $ids = $filters['IDS']; $where_ids = " AND hardware.ID IN ("; $where_ids .= join(',', $ids); $where_ids .= ") "; } else { $where_ids = ""; } if (isset($filters['EXCLUDE_IDS']) and $filters['EXCLUDE_IDS']) { $exclude_ids = $filters['EXCLUDE_IDS']; $where_exclude_ids = " AND hardware.ID NOT IN ("; $where_exclude_ids .= join(',', $exclude_ids); $where_exclude_ids .= ") "; } else { $where_exclude_ids = ""; } if (isset($filters['DEVICEIDS']) and $filters['DEVICEIDS']) { $deviceids = $filters['DEVICEIDS']; $where_deviceids = " AND hardware.DEVICEID IN ('"; $where_deviceids .= join('\',\'', $deviceids); $where_deviceids .= "') "; } else { $where_deviceids = ""; } if (isset($filters['EXCLUDE_DEVICEIDS']) and $filters['EXCLUDE_DEVICEIDS']) { $exclude_deviceids = $filters['EXCLUDE_DEVICEIDS']; $where_exclude_deviceids = " AND hardware.DEVICEID NOT IN ("; $where_exclude_deviceids .= join(',', $exclude_deviceids); $where_exclude_deviceids .= ") "; } else { $where_exclude_deviceids = ""; } if (isset($filters['TAGS']) and $filters['TAGS']) { $tags = $filters['TAGS']; $where_tags = " AND accountinfo.TAG IN ("; $where_tags .= "'" . join('\',\'', $tags) . "'"; $where_tags .= ") "; } else { $where_tags = ""; } if (isset($filters['EXCLUDE_TAGS']) and $filters['EXCLUDE_TAGS']) { $exclude_tags = $filters['EXCLUDE_TAGS']; $where_exclude_tags = " AND accountinfo.TAG NOT IN ("; $where_exclude_tags .= "'" . join('\',\'', $exclude_tags) . "'"; $where_exclude_tags .= ") "; } else { $where_exclude_tags = ""; } if (isset($filters['INVENTORIED_SINCE']) and $filters['INVENTORIED_SINCE']) { $since = $filters['INVENTORIED_SINCE']; $where_since = " AND (`hardware`.`LASTDATE` > "; $where_since .= "'" . $since . "'"; $where_since .= ") "; } else { $where_since = ""; } if (isset($filters['INVENTORIED_BEFORE']) and $filters['INVENTORIED_BEFORE']) { $before = $filters['INVENTORIED_BEFORE']; $where_before = " AND (UNIX_TIMESTAMP(`hardware`.`LASTDATE`) < (UNIX_TIMESTAMP(" . $before . ")"; // $where_before .= "'" .$before. "'"; $where_before .= ") "; } else { $where_before = ""; } if (isset($filters['CHECKSUM']) and $filters['CHECKSUM']) { $checksum = $filters['CHECKSUM']; $where_checksum = " AND ('" . $checksum . "' & hardware.CHECKSUM) "; } else { $where_checksum = ""; } $where_condition = $where_ids . $where_exclude_ids . $where_deviceids . $where_exclude_deviceids . $where_tags . $where_exclude_tags . $where_checksum . $where_since . $where_before; } else { $where_condition = ""; } $query = "SELECT DISTINCT hardware.ID FROM hardware, accountinfo\n WHERE hardware.DEVICEID NOT LIKE '\\_%'\n AND hardware.ID = accountinfo.HARDWARE_ID\n {$where_condition}"; $request = $this->db->query($query); if ($this->db->numrows($request)) { $count = $this->db->numrows($request); $query = "SELECT DISTINCT hardware.ID FROM hardware, accountinfo\n WHERE hardware.DEVICEID NOT LIKE '\\_%'\n AND hardware.ID = accountinfo.HARDWARE_ID\n {$where_condition}\n ORDER BY {$order}\n {$max_records} {$offset}"; $request = $this->db->query($query); $accountinfomap = $this->getAccountInfoColumns(); while ($hardwareid = $this->db->fetch_assoc($request)) { $hardwareids[] = $hardwareid['ID']; } $res["TOTAL_COUNT"] = $count; if (isset($options['DISPLAY']['CHECKSUM'])) { $checksum = $options['DISPLAY']['CHECKSUM']; } else { $checksum = self::CHECKSUM_NONE; } if (isset($options['DISPLAY']['WANTED'])) { $wanted = $options['DISPLAY']['WANTED']; } else { $wanted = self::WANTED_NONE; } $res["COMPUTERS"] = $this->getComputerSections($hardwareids, $checksum, $wanted); } else { $res = array(); } return $res; }