how to get metrics report using api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sacom01
Posts: 194
Joined: Wed Dec 23, 2020 10:15 pm

how to get metrics report using api

Post by sacom01 »

hi team,
the metrics report only have some default services (disk, cpu, memory, load,swap), and does not include services i created so i want to get a csv or pdf file in metrics report using API.

i use this url but it just return like below :
http://192.168.xxx.xxx/nagiosxi/api/v1/ ... ck_cudepth

Result:

{
"recordcount": 0,
"servicestatus": [

]
}


Or is there anyway for get all services metrics report?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: how to get metrics report using api

Post by ssax »

The metrics report is not currently available through the API.

Only specific services created by the wizards (or matching exactly what the wizards use) will show up in the metrics report.

Does it show the services under here:

http://192.168.X.X/nagiosxi/api/v1/obje ... Y&pretty=1

Or here?

http://192.168.X.X/nagiosxi/api/v1/obje ... t&pretty=1
sacom01
Posts: 194
Joined: Wed Dec 23, 2020 10:15 pm

Re: how to get metrics report using api

Post by sacom01 »

thanks for your respone.

i have 2 questions :
1. how to get a service for all host, e.g memory service for all hosts.
2. how to import it to excel or pdf to see a graphics mode as attach file.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: how to get metrics report using api

Post by ssax »

1. You can create a servicegroup for memory, then add all the memory services in them, then view the servicegroup information under Home > Servicegroup Summary and click the first icon next to the service group to see all of the services and their current status. You could schedule that page in a PDF report by clicking the very top right menu with three horizontal lines in it, then click the very first icon to schedule the page as a PDF.

2. You would go to Home > Metrics and run the report, then click the very top right menu with three horizontal lines in it, then click the very first icon to schedule the page as a PDF. There isn't currently a way to export the Metrics report functional other than doing that.
sacom01
Posts: 194
Joined: Wed Dec 23, 2020 10:15 pm

Re: how to get metrics report using api

Post by sacom01 »

hi ssax,
my 2 questions :
"1. how to get a service for all host, e.g memory service for all hosts.
2. how to import it to excel or pdf to see a graphics mode as attach file."

I mean i want to do this using API. I have many services which not include in Metrics report, so i want to get them from API and import to csv or pdf file.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: how to get metrics report using api

Post by ssax »

1. The only way to get services to show up in Metrics is if they match one of the commands with metrics below, those are the only services that will show up in Metrics at this time (which get created automatically when you run the wizards and select those services but you can manually do it too):
- You can technically create a service with the same Check Command and metric and attach it to a host and it should show up in there
- You can edit one of the services that is currently showing up in there to see how the service is setup to understand the info below better

Load:
- Plugin: check_local_load

NRPE # These are from the NPRE Wizards
- Check Command: check_nrpe
- Check Command Metric: check_load

SNMP # These are from the SNMP Wizards
- Check Command: check_xi_service_snmp # These are from the SNMP Wizards
- Check Command OID: .1.3.6.1.4.1.2021.10.1.3.1

Disk:

NCPA # These are from the NCPA Wizards
- Check Command: check_xi_ncpa
- Check Command Metric: disk/logical OR disk/physical

NSClient++:
- Check Command: check_nt OR check_xi_service_nsclient
- Check Command Metric: USEDDISKSPACE

WMI:
- Check Command: check_xi_service_wmiplus OR check_xi_service_wmiplus_authfile
- Check Command Metric: checkdrivesize

Linux NRPE:
- Check Command: check_nrpe
- Check Command Metric: check_disk

SNMP:
- Check Command: check_xi_service_snmp_linux_storage OR check_xi_service_snmp_win_storage


CPU:

NSClient++:
- Check Command: check_xi_service_nsclient
- Check Command Metric: CPULOAD

NRPE:
- Check Command: check_nrpe
- Check Command Metric: check_cpu_stats

NCPA:
- Check Command: check_xi_ncpa_agent OR check_xi_ncpa
- Check Command Metric: cpu/percent

WMI:
- Check Command: check_xi_service_wmiplus OR check_xi_service_wmiplus_authfile
- Check Command Metric: checkcpu

SNMP:
- Check Command: check_xi_service_snmp_linux_storage OR check_xi_service_snmp_win_storage

Swap:

Plugin: check_local_swap

NRPE:
- Check Command: check_nrpe
- Check Command Metric: check_swap

SNMP Linux:
- Check Command: check_xi_service_snmp_linux_storage
- Check Command Metric: Swap_space

NCPA:
- Check Command: check_xi_ncpa_agent OR check_xi_ncpa
- Check Command Metric: memory/swap/percent OR memory/swap

Memory:

NSClient++
- Check Command: check_xi_service_nsclient
- Check Command Metric: MEMUSE

NRPE:
- Check Command: check_nrpe
- Check Command Metric: check_mem

NCPA:
- Check Command: check_xi_ncpa_agent OR check_xi_ncpa
- Check Command Metric: memory/virtual OR memory/virtual/percent

WMI:
- Check Command: check_xi_service_wmiplus OR check_xi_service_wmiplus_authfile
- Check Command Metric: checkmem

SNMP:
- Check Command: check_xi_service_snmp_linux_storage OR check_xi_service_snmp_win_storage
- Check Command Metric: Physical Memory OR Memory OR Physical_memory

The metrics functionality is programmatically done, you cannot get that output from the API. If you want it to show what metrics shows then you would need to do this:
2. You would go to Home > Metrics and run the report, then click the very top right menu with three horizontal lines in it, then click the very first icon to schedule the page as a PDF. There isn't currently a way to export the Metrics report functional other than doing that.
You can view the service status through the API via the endpoints we were previously using.
Locked