Page 1 of 1

Nagios XI / Audit Log / CSV-Export

Posted: Thu Jul 14, 2016 8:28 am
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

Re: Nagios XI / Audit Log / CSV-Export

Posted: Thu Jul 14, 2016 9:55 am
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

Re: Nagios XI / Audit Log / CSV-Export

Posted: Thu Jul 14, 2016 10:17 am
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.

Re: Nagios XI / Audit Log / CSV-Export

Posted: Thu Jul 14, 2016 10:39 am
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

Re: Nagios XI / Audit Log / CSV-Export

Posted: Thu Jul 14, 2016 10:44 am
by IMTECH
Thanks again!

That will work till we upgrade :-)

Re: Nagios XI / Audit Log / CSV-Export

Posted: Thu Jul 14, 2016 11:00 am
by mcapra
Sure thing! Is it alright if I lock this thread and mark the issue as resolved?

Re: Nagios XI / Audit Log / CSV-Export

Posted: Mon Jul 18, 2016 1:00 am
by IMTECH
Yes, of course.