Had great success using the command line 'curl' to add hosts/services in mass.
What I would like to do is have a simple php page where a user could enter a host name and then all the baseline checks are implemented.
Just curious if anyone has tried this. I have poured over PHP Curl docs but they don't seem to fit what I am trying to do.
Nagios XI 5 - restapi php
Re: Nagios XI 5 - restapi php
I've done it 
I wrote it as a component with a crazy amount of coding. I can share, but it'd need cleaned up bad as it has my API key and other items hardcoded...you'd have to redo a bunch, but it'd be a start.
I wrote it as a component with a crazy amount of coding. I can share, but it'd need cleaned up bad as it has my API key and other items hardcoded...you'd have to redo a bunch, but it'd be a start.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
-
krobertson71
- Posts: 444
- Joined: Tue Feb 11, 2014 10:16 pm
Re: Nagios XI 5 - restapi php
That would be a great help. Thanks!
Re: Nagios XI 5 - restapi php
Attached! Good luck figuring out my hacked code 
It adds to the menu on the left when you click "Configure" across the top menu. Advanced users can see it. At the bottom of the addl and addw files there are two different options for applying the changes remarked out, one gives a link and the other auto does it. I am having a service receive a passive check and alert me so I can manually apply changes when I want.
Edit #1 - I redacted URL and APIKey in all the files
Edit #2 - We are a hosting company, all customers have their own templates and stuff, you'll see the code that figures that all out, just wanted to explain that.
Edit #3 - You'll also see it sends a passive result to the same "Host Automation" service if for some reason an API call fails so that my team and figure the issue and get the host added
Edit #4 - Woot, my 2000th post!
It adds to the menu on the left when you click "Configure" across the top menu. Advanced users can see it. At the bottom of the addl and addw files there are two different options for applying the changes remarked out, one gives a link and the other auto does it. I am having a service receive a passive check and alert me so I can manually apply changes when I want.
Edit #1 - I redacted URL and APIKey in all the files
Edit #2 - We are a hosting company, all customers have their own templates and stuff, you'll see the code that figures that all out, just wanted to explain that.
Edit #3 - You'll also see it sends a passive result to the same "Host Automation" service if for some reason an API call fails so that my team and figure the issue and get the host added
Edit #4 - Woot, my 2000th post!
You do not have the required permissions to view the files attached to this post.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
-
krobertson71
- Posts: 444
- Joined: Tue Feb 11, 2014 10:16 pm
Re: Nagios XI 5 - restapi php
Great stuff!!
This will help a lot. I wasn't sure you could just echo the curl url with the post variables and have it work.. Bravo.
So just echo $result does the trick? Just making sure my above statement was correct...
This will help a lot. I wasn't sure you could just echo the curl url with the post variables and have it work.. Bravo.
So just echo $result does the trick? Just making sure my above statement was correct...
Re: Nagios XI 5 - restapi php
I put the command within ` marks(same key as ~) assigning it to a variable, that runs the command. No echo was used except to actually echo text.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
-
krobertson71
- Posts: 444
- Joined: Tue Feb 11, 2014 10:16 pm
Re: Nagios XI 5 - restapi php
Got ya. This is nice. Just need to chop some stuff out as we use NCPA, but this makes sense to me. GO ME!
Thanks for the help. Greatly appreciated!!!
Thanks for the help. Greatly appreciated!!!
Re: Nagios XI 5 - restapi php
Thanks for sharing, BanditBBS!
@krobertson71
Is it all right to lock this thread?
@krobertson71
Is it all right to lock this thread?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Nagios XI 5 - restapi php
Congrats!Edit #4 - Woot, my 2000th post!
I'll have a look at your component too. Tx
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Nagios XI 5 - restapi php
So I had a look at the component. It definitely is a nice starting point for more customization. Would be nice to see this in GitHub? 
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net