Export Allowed Hosts with Specific Information to CSV
Posted: Thu Oct 27, 2016 8:16 am
I got a user with readonly access to a specific hostgroup on my server.
He would like to be able to export a CSV file of all the hosts he has access to.
Looking around I found a few possible solutions, but they aren't very customizable. For example allowing me or him to specify which columns should be exported.
Examples of what I found: (source)
So is there a way for me to maybe create my own version of one of those?
Also found linux code, so I could maybe make a bash script to do this, but there are a few issues with this.
First of all, it gets ALL hosts, rather than only the ones the user has access to. I am not familier with how the nagiosql is structured, so I don't know how to limit it to a hostgroup.
Not to mention the fact that I need display it on the Nagios XI site, which I have no idea how to do. Maybe it is possible to create a tool or something that can do this?
The output I am hoping to produce is simply something like this:
Is anyone able to point me in the right direction?
He would like to be able to export a CSV file of all the hosts he has access to.
Looking around I found a few possible solutions, but they aren't very customizable. For example allowing me or him to specify which columns should be exported.
Examples of what I found: (source)
Code: Select all
http://<ip>/nagios/cgi-bin/objectjson.cgi?query=hostlistCode: Select all
http://<ip>/nagiosxi/backend/?cmd=gethosts&brevity=3Also found linux code, so I could maybe make a bash script to do this, but there are a few issues with this.
Code: Select all
echo "use nagiosql; select display_name,notes,address from tbl_host into outfile '/tmp/hosts.csv' fields terminated by ',' enclosed by '\"' lines terminated by '\n'" | mysql -u root -pnagiosxiNot to mention the fact that I need display it on the Nagios XI site, which I have no idea how to do. Maybe it is possible to create a tool or something that can do this?
The output I am hoping to produce is simply something like this:
Code: Select all
<display_name>,<notes>,<address>
<display_name>,<notes>,<address>
<display_name>,<notes>,<address>