示例#1
0
function logout()
{
    $args['method'] = "glpi.doLogout";
    if ($result = call_glpi($args)) {
        return true;
    }
}
function getServicesStates($session, $filter = "", $start = 0, $limit = 5000)
{
    global $verbose, $limitation;
    /*
     * Get hosts states
     */
    $args['session'] = $session;
    $args['method'] = "monitoring.getServicesStates";
    /* Filter used in DB query; you may use : 
          `glpi_entities`.`name`, for entity name, or any column name from glpi_entities table
          `glpi_computers`.`name`, for computer name, or any column name from glpi_computers table
          `glpi_computers`.*,
          `glpi_plugin_monitoring_hosts`.*,
          `glpi_plugin_monitoring_services`.*,
          `glpi_plugin_monitoring_componentscatalogs_hosts`.*,
          `glpi_plugin_monitoring_components`.*
       */
    // $args['filter'] = "`glpi_computers`.`name` LIKE 'ek3k%'";
    $args['filter'] = $filter;
    $args['start'] = $start;
    $args['limit'] = $limitation == 0 ? $limit : $limitation;
    if ($servicesStates = call_glpi($args)) {
        echo "+ Got " . count($servicesStates) . " records.\n";
        if ($verbose) {
            echo "Services states : \n";
            foreach ($servicesStates as $service) {
                echo " - " . $service['host_name'] . " / " . $service['name'] . " is " . $service['state'] . " (" . $service['state_type'] . ")\n";
            }
        }
        return $servicesStates;
    }
    return null;
}