Page 1 of 1
Dashboard with just CPU Load Graphs
Posted: Tue Feb 20, 2018 4:30 pm
by emartine
I received a request to create a dashboard that shows 7 days worth of CPU load for 88 servers. I know I can do this one by one... but is there an easier way to do this?
Re: Dashboard with just CPU Load Graphs
Posted: Wed Feb 21, 2018 9:33 am
by mcapra
I can't think of a good way to do that automagically.
Assuming all of the CPU checks produce identically formatted outputs for their perfdata, you could probably modify the Metrics component and trick it into doing this without too much pain.
Re: Dashboard with just CPU Load Graphs
Posted: Wed Feb 21, 2018 10:12 am
by kyang
Thanks for the help
@mcapra!
emartine, he's right, I think the metrics component is what you are looking for. Here is an example.
Capture.PNG
Let us know if this helps!
Re: Dashboard with just CPU Load Graphs
Posted: Wed Feb 21, 2018 11:49 am
by emartine
I wish it were that easy. The checks are called CPU Load and not CPU Usage. Attempting to view the items via host group or service group don't show any matching metrics data.
Re: Dashboard with just CPU Load Graphs
Posted: Wed Feb 21, 2018 11:55 am
by emartine
By the way. I can't make a dashboard with the metric graphs.
Re: Dashboard with just CPU Load Graphs
Posted: Wed Feb 21, 2018 1:31 pm
by kyang
Sorry for the misunderstanding.
The performance graphs component under "Graphs" only allows for per host as well. So that isn't much help.
I don't think there is any current method easier than manually 1 by 1 unfortunately and since this is for dashboards.
Re: Dashboard with just CPU Load Graphs
Posted: Tue Feb 27, 2018 2:48 pm
by emartine
When I click the "Add It" button from the Add to Dashboard arrow. It is submitting the Dashlet title, and it also requests Selects a Dashboard to Add To. It also knows that I requested a 7 day period. There has to be a way to capture the command that is being submitted so I can submit it as a for loop for all 88 servers. I've done 44 manually for CPU and it was a time waster.
Re: Dashboard with just CPU Load Graphs
Posted: Tue Feb 27, 2018 4:00 pm
by tmcdonald
Do you know how to use the Developer console of your web browser? It's a bit hacky, but I wrote up a bash script to automate this for you if you can get the right values:
Code: Select all
#!/bin/bash
nagiosxi=$1
cookie=$2
dashboard=$3
nsp=$4
hostfile=$5
while read hostname; do
curl "http://$1/nagiosxi/includes/components/graphexplorer/dashifygraph.php" -H "Host: $nagiosxi" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Referer: http://$nagiosxi/nagiosxi/includes/components/xicore/status.php?show=services" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "X-Requested-With: XMLHttpRequest" -H "Cookie: nagiosxi=$cookie" -H "Connection: keep-alive" --data "url=visApi.php"%"3Ftype"%"3Dperfdata"%"26host"%"3D$hostname"%"26service"%"3DCPU"%"252BLoad"%"26div"%"3Dgraphcontainer"%"26height"%"3D500&dashletName=$hostname+"%"3A+CPU+Load&boardName=$dashboard&nsp=$nsp"
done < $hostfile
As an example, I ran it as follows:
./post.sh 192.168.3.32 r52d723m8alntm2ksvqgd2i245 home e6f63f9dc3008a578d08c484d82dd50a035ce3ca106724bd6ae70f7adff3b534 hosts
against a dummy hostfile that just included
localhost 3 times:
Code: Select all
[root@localhost tmp]# cat hosts
localhost
localhost
localhost
You would need to get the hostnames in that file, one per line. I'm guessing since you used the words "for loop" that this should be within your grasp, but let me know if you need further assistance. This is a bit out of scope, but most of the work has been done for you so it might just take a little massaging to get right.