Page 1 of 1

migrating psql to my sql. custom actions componet info lost.

Posted: Thu Dec 13, 2018 2:49 pm
by benhank
HOKAY!
I have a server running xi 5.5.7
I am testing the postgreql to mysql migration by following these steps as defined in the kb article:

Code: Select all

cd /tmp
wget https://github.com/ChrisLundquist/pg2mysql/archive/master.zip
unzip master.zip
cd /tmp/pg2mysql-master/
pg_dump --no-acl --no-owner --format p --data-only -U nagiosxi nagiosxi > nagiosxi.psql
php pg2mysql_cli.php nagiosxi.psql nagiosxi.mysql myisam
wget https://assets.nagios.com/downloads/nagiosxi/scripts/nagiosxi_create_db.sql
mysql -uroot -pnagiosxi < nagiosxi_create_db.sql
perl -l -n -i -e 'print $_; print "max_allowed_packet=512M" if(/\[mysqld\]/);' /etc/my.cnf
service mysqld restart || systemctl restart mariadb
mysql -uroot -pnagiosxi nagiosxi --max_allowed_packet=512M --force < nagiosxi.mysql
mysql -u root -pnagiosxi -e "CREATE USER 'nagiosxi'@'localhost' IDENTIFIED BY 'n@gweb';"
mysql -u root -pnagiosxi -e "GRANT ALL ON nagiosxi.* TO 'nagiosxi'@'localhost'; FLUSH PRIVILEGES;"
cp -p /usr/local/nagiosxi/html/config.inc.php /usr/local/nagiosxi/html/config.inc.php.backup
sed -i 's/pgsql/mysql/' /usr/local/nagiosxi/html/config.inc.php
mv /usr/local/nagiosxi/html/includes/components/nagiosim ~/nagiosim.backup &>/dev/null
service postgresql stop || systemctl stop postgresql
chkconfig postgresql off || systemctl disable postgresql
Which worked.
However prior to the migration my actions component

Code: Select all

/administrator/systemextentions/manage components/ACTIONS
contained 201 custom actions.
After the migration :
Capture.PNG
Also, an issue that I had , which got resolved in this post:

Code: Select all

https://support.nagios.com/forum/viewtopic.php?f=16&t=51587
returned.

In order to test my theory I ran these commands to reverse the postgresql migration:

Code: Select all

service postgresql start 
sudo cp -p /usr/local/nagiosxi/html/config.inc.php /usr/local/nagiosxi/html/config.inc.php.attempted
sudo cp -p /usr/local/nagiosxi/html/config.inc.php.backup /usr/local/nagiosxi/html/config.inc.php
and my actions component contained the 201 custom commands again.
I also had to reapply the fix for the wproc issue after reversing the migration .
So I have come to the conclusion that migrating from postgreql to mysql is what caused me to lose the info in the actions component.

Re: migrating psql to my sql. custom actions componet info l

Posted: Thu Dec 13, 2018 6:02 pm
by ssax
Likely has issues with escaping, please run these commands and PM me the resulting nagiosxi.psql and the nagiosxi.psql2 files:

Code: Select all

pg_dump --no-acl --no-owner --format p --data-only -U nagiosxi nagiosxi > nagiosxi.psql
pg_dump -U nagiosxi nagiosxi > nagiosxi.psql2

Re: migrating psql to my sql. custom actions componet info l

Posted: Mon Dec 17, 2018 5:57 pm
by ssax
Sorry, please run this one and send me the resulting /tmp/nagiosxi.psql3 file

Code: Select all

pg_dump -U nagiosxi -c nagiosxi > /tmp/nagiosxi.psql3