Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-NagiosXi functions don't work as expected #4

Open
rwaal opened this issue Jun 7, 2019 · 1 comment
Open

Get-NagiosXi functions don't work as expected #4

rwaal opened this issue Jun 7, 2019 · 1 comment

Comments

@rwaal
Copy link
Contributor

rwaal commented Jun 7, 2019

Hi @wasserja. I found your Nagios module and did some experimenting. However, I found that the functions didn't work the way that I expected.

I started out by setting the values of my Nagios server in the parameters NagiosXiApiUrl and NagiosXiApiKey in MrANagios.psm1. Then I tried several functions.

Example: Get-NagiosXiServiceStatus
When using the command Get-NagiosXiServiceStatus -HostName 'hostname01' no output is written to the console. When using the -verbose switch, I see that the communication with the Nagios server takes place, as can be seen in the following output:

VERBOSE: Query host_name=hostname01
VERBOSE: Query host_name=hostname01
VERBOSE: No Service name entered.
VERBOSE: Query host_name=hostname01
VERBOSE: Query host_name=hostname01
VERBOSE: Valid Resource, continuing.
VERBOSE: Invoking Nagios XI REST API
VERBOSE: Uri https://mynagios.domain.com/nagiosxi/api/v1/objects/servicestatus/?apikey=123456789&host_name=hostname01
VERBOSE: GET https://mynagios.domain.com/nagiosxi/api/v1/objects/servicestatus/?apikey=123456789&host_name=hostname01 with 0-byte payload
VERBOSE: received 7534-byte response of content type application/json
VERBOSE: Content encoding: utf-8

I was looking in function and saw the following code:

if ($Summary) {
$ServiceStatus.servicestatuslist.servicestatus | Select-Object -Property host_name, name, status_text
}
else {
$ServiceStatus.servicestatuslist.servicestatus
}

In my situation, the object $ServiceStatus.servicestatuslist.servicestatus returns nothing, because $ServiceStatus doesn't have a property called servicestatuslist. However, it does contain a property servicestatus . I changed the code to the code below, which fixed the problem for me.

        if ($Summary) {
            $ServiceStatus.servicestatus | Select-Object -Property host_name, name, status_text
        }
        else {
            $ServiceStatus.servicestatus
        }

Is there something that I am missing, or is there simply an error in the code? By the way, I have noticed similar problems with the other Get-NagiosXi functions.

As a side note: are you open for contributions? I'm happy to make modifications and would like to introduce some functions for additional Nagios functionality.

Thanks!

@wasserja
Copy link
Owner

Thank you for the feedback. It has been two years since I've worked with Nagios XI during which time I suspect the API may have changed (or my code never worked?). Please do help fix it if it is worth it to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants