Nagios XI / Audit Log / CSV-Export

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
IMTECH
Posts: 53
Joined: Fri Nov 25, 2011 6:35 am

Nagios XI / Audit Log / CSV-Export

Post by IMTECH »

Hi,

is there an automated method to export the audit log csv from the command line? (eg. cronjob)
We need to load it periodically to another application.

I tried using wget and cookies but always endet up with "Your session has timed out." so I guess my authentification is done wrong.

Kind regards,
Gerhard
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios XI / Audit Log / CSV-Export

Post by mcapra »

You could try this one-liner:

Code: Select all

echo "use nagiosxi; select * into outfile '/tmp/audit_log.csv' fields terminated by ',' enclosed by '\"' lines terminated by '\n' from xi_auditlog" | mysql -u root -pnagiosxi
Seems to work for me. Bear in mind that on some systems the file might actually not go into /tmp, but rather /tmp/systemd-private-<long hash>-mariadb.service-<random>/tmp/audit_log.csv
Former Nagios employee
https://www.mcapra.com/
IMTECH
Posts: 53
Joined: Fri Nov 25, 2011 6:35 am

Re: Nagios XI / Audit Log / CSV-Export

Post by IMTECH »

Thanks, that would work - but unfortunately we are still on a 2014-version so that probably explains why I didnt see it myself in the database ;-)

Any idea how this could be resolved on 2014R2.7 ?
Upgrade is already planned, but will take place later this year.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios XI / Audit Log / CSV-Export

Post by mcapra »

If you're using postgres for the database, try:

Code: Select all

echo "\copy xi_auditlog to '/tmp/audit_log.csv' csv header" |  psql -d nagiosxi -U nagiosxi -w
Former Nagios employee
https://www.mcapra.com/
IMTECH
Posts: 53
Joined: Fri Nov 25, 2011 6:35 am

Re: Nagios XI / Audit Log / CSV-Export

Post by IMTECH »

Thanks again!

That will work till we upgrade :-)
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios XI / Audit Log / CSV-Export

Post by mcapra »

Sure thing! Is it alright if I lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
IMTECH
Posts: 53
Joined: Fri Nov 25, 2011 6:35 am

Re: Nagios XI / Audit Log / CSV-Export

Post by IMTECH »

Yes, of course.
Locked