Nagios XI – Adding Microsoft Server Services via API

When automating server provisioning you might be considering implementing Nagios for monitoring servers and services as part of the build process. Apart from the help section of Nagios console giving some hints on how to interact with the API, there isn’t much else to go on so I’m sharing my learnings on how to do this.

I’m not going to go through the whole implementation of automating Nagios into server builds but more specifically connecting to the API.

The Nagios reference is http://host.example.com/nagiosxi/help/ and then click on “Config Reference”

The first step is to add the host – now this is in the Nagios help section so hopefully, this is nothing new

You will need to change the FQDN, API Key, Hostname and address to your requirements to make this work for you.

Scroll to the right of the code to see it all.

One thing to note is every setting is separated by a “&” and variables specified by the check start with “!”. This is the key to understanding how this works.

Add Processor

Add Disk

Add Memory

Add Uptime

Make sure you change the FQDN, API Key, Hostname and password variables for this to work.

I found the configuration wizard very helpful, what I did was add the service I wanted to check, see what the “check command” was and the variables set and then crafted my own curl command to add to Nagios.

Powershell – The size limit for this request was exceeded

powershell

The size limit for this request was exceeded

So this sounds easy he said – run me a report that gets all objects from a group based on certain attributes and export it to Microsoft Excel.

No worries, I had that scripted for three groups to export to three different Excel files in under 10 minutes – until I ran it and came across “Get-ADGroupMember : The size limit for this request was exceeded”

get-adgroupmember

Okay so I start doing some research thinking “this is just a speed bump” and I’ll sort it out in five minutes! I came across hundreds of people with the same issue and finding “workarounds” none of which worked.

I thought it might be best to publish this to the public in case someone else comes across it.

Now just to let everyone know if they know the answer already or have other solutions – I cannot go changing the maximum value and time limit on all the Domain Controllers.

The code:

Note: You will need to change the search base to match your domain

I’m getting the attributes “Name,SurName,GivenName,department,mail,pager,division” for this particular report but you can modify to your requirements.

Obviously you don’t need to do this for getting members of groups with under 1,500 objects.