LSI RAID Inventory in GLPI

LSI RAID Inventory in GLPI
In my work, I often experience obsessions about the lack of information about the infrastructure, and with an increase in the fleet of serviced servers, this turns into real torture. Even when I was an admin in small organizations, I always wanted to know what was where, where it was plugged in, which of the people was responsible for which piece of iron or service, and most importantly, to fix changes in everything. When you come to a new place and encounter some kind of incident, a lot of time is spent on searching for this information. Next, I will tell you what I had to deal with in RuVDS, and how I solved the problem indicated in the title.

prehistory

Being an enterprise administrator, I had little experience in the data center, but out of the corner of my eye I saw RackTables. It visually presented a rack with all the servers, UPSs, switches and all the connections between them. RuVDS did not have such a system, but only Excel / paper files with information about servers, some of their components, rack numbers, etc. With this approach, it is very difficult to track changes in small components. But the most important and frequently replaced consumables for servers are disks. It is very important to maintain up-to-date information on the status of disks and their strategic reserve. If a drive crashes out of the RAID array and is not quickly replaced, this can eventually lead to fatal consequences. Therefore, we really need a system that tracks the location of disks and their condition in order to understand what we may be missing and which models we need to purchase.

GLPI came to the rescue, an open source product designed to improve the work of IT departments and bring them to the ideals of ITIL. In addition to equipment inventory and rack management, it has a knowledge base, service desk, document management, and much more. GLPI has many plugins, including FusionInventory and OCS Inventory, that allow you to automatically collect information about computers and other devices through agent installation and SNMP. You can read more about installing GLPI and plugins in other articles, best of all - official documentation. You can install it on our hosting on a ready-made template LAMP.

However, after deploying the agent, we will open the computer components in GLPI and see this:

LSI RAID Inventory in GLPI
The problem is that none of the plugins can see information about physical disks in LSI RAID arrays. After seeing how this issue is resolved for monitoring in Zabbix using a PowerShell script lsi-raid.ps1 I decided to write a similar one to transfer information to GLPI.
Information about the disks in the array can be obtained using utilities from the controller manufacturer, in the case of LSI, this is StorCLI. From it you can get data in JSON format, parse it and pass it to the GLPI API. We will bind disks to computers that FusionInventory has already created. When re-executed, the script will update data on disks and add new ones. The Send-RAIDtoGLPI.ps1 script itself lies here on GitHub. Next, I'll show you how to use it.

What will be required

  1. GLPI version 9.5.1 (tested on this one)
  2. plugin Fusion Inventory and agent under Windows
  3. Windows 2012 R2 (and higher) as a host system, or a management-VM with a controller forwarded to it, PowerShell version 4 or higher
  4. Installed MegaRAID driver
  5. Module for PowerShell - PSGLPI
  6. GLPI account with Admin profile for authorization via API generated by UserToken and AppToken

An important point. For some reason, GLPI has 2 different entities for the disk model, but there is no β€œmedia type” property. Therefore, to record the properties of HDD and SSD, I decided to use the drop-down list "Hard Drive Models" (front/devicemodel.php?itemtype=DeviceHardDriveModel). The script must have these values ​​in the GLPI database, otherwise it will not be able to write data about the disk model. Therefore, you need to add HDD to this empty list first, then SSD, so that the IDs of these elements in the database are 1 and 2. If there are others, then replace in this line of the Send-RAIDtoGLPI.ps1 script after HDD and SSD instead of 1 and 2 the corresponding IDs :

deviceharddrivemodels_id = switch ($MediaType) { "HDD" { "1" }; "SSD" { "2" }; default { "" } }

If you don't want to mess with it or you use this drop-down list differently, you can simply remove this line from the script.

You also need to add the statuses for the disks to the "Element Statuses" (/front/state.php). I added the statuses "MediaError" (there was at least one disk access error) and "OK", a line in the script where their IDs are passed, "2" for "OK" and "1" for "MediaError":

states_id = switch ($MediaError) { 0 { "2" }; { $_ -gt 0 } { "1" } }

These statuses are needed for convenience, if you do not need these properties, you can also delete this line entirely.

In the script itself, do not forget to set the variables to yours. $GlpiCreds must contain the URL to the GLPI API server, UserToken and AppToken.

What's in the script

Due to the cumbersome JSON parsing and the if-sheets, the script is poorly readable, so I will describe its logic here.

When it is first launched on the host, the script goes through all the controllers and searches for disks in the GLPI database by serial numbers; if it does not find it, it looks for the model. If it does not find the model either, then it adds the new disk model to GLPI and enters this disk into the database.

Each new pass, the script will try to detect new disks, but it cannot delete the missing ones, therefore, you will have to do it manually.

Deployment Example

The script repository contains the Deploy-Send-RAIDtoGLPI.ps1 script, which will download a ZIP archive with the necessary files from our GLPI server and deploy them on each host.

After copying the files, the script will install the FusionInventory agent as a daily task and create the same task for our script. After a successful implementation, we will finally be able to see the disks in the "Components" section of the computer in GLPI.

Experience the Power of Effective Results

Now, by going to GLPI in the menu "Settings" -> "Components" -> "Hard Drives", we can click on drive models and look at their number in order to understand what we need to purchase.

LSI RAID Inventory in GLPI
LSI RAID Inventory in GLPI

Source: habr.com

Add a comment