Thursday, October 15, 2015

Logwatch + MailGun

I really like the way Logwatch works but I hate when I can't properly send mail due to reverse DNS restrictions, based on this post [1] I came with the idea of leveraging the power of MailGun in order to send Logwatch email notifications and it went successfuly.

In the logwatch main configuration file (/etc/logwatch/conf/logwatch.conf) on Debian, change the following:

  1. comment out the sendmail line

  2. # mailer = "/usr/sbin/sendmail -t"

  3. add a line to use our custom mailgun mailer script


  4. mailer = "/usr/local/sbin/mailgun"

After changing the values, you can run a test with the following command line

/etc/cron.daily/00logwatch

The mailgun shell script can be (literally) checked out here [2].


  1. http://blog.thinkingcapstudios.net/2012/07/installing-lemonstand-on-ubuntu-part-2/
  2. https://gist.github.com/tonejito/1a50b4d8b181393ebf77


--
    = ^ . ^ =

Tuesday, July 21, 2015

XenServer and NTP

After spending hours and hours trying to set up the timezone and hwclock via ntp on a Debian 7.8 Wheezy VM on XenServer 6.5 I gave up and ended up setting the timezone to UTC because the clock was only displayed correctly if the tz was UTC (damn bad).

I came up this morning with the idea of checking the time of the XenServer dom0 to see if at least the physical box had its time ok. Big was my surprise when I realized the dom0's time was also skewed just like in the VMs as stated on [1]

I restarted the NTP daemon because I configured it to point to the ntp pool when setting up the box. Big was my surprise when I realized the NTP daemon was starting, but the synchronization was failed:

[root@xenserver ~]# service ntpd restart
Shutting down ntpd:                   [  OK  ]
ntpd: Synchronizing with time server: [FAILED]
Starting ntpd:                        [  OK  ]


I restarted the NTP daemon on the old fashioned way, since the XenServer 6.5 is based on CentOS, that shouldn't be an issue.

[root@xenserver ~]# /bin/bash -vx /etc/init.d/ntpd restart

After some output, I realized the script runs ntpdate to get the synchronization done like this:

ntpd: Synchronizing with time server: + /sbin/ntpdate -U ntp -s -b 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org

After running the command with debug and verbose flags I realized that there was something wrong with using an privileged port and dropping privileges to the ntp user, so turning on the -u flag on /etc/sysconfig/ntpd was the right way to do it. [2] [3]

[root@xenserver ~]# cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -x"

# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK=no

# Additional options for ntpdate
NTPDATE_OPTIONS="-u"


After the change everything went smoothly:

[root@xenserver ~]# service ntpd restart
Shutting down ntpd:                   [  OK  ]
ntpd: Synchronizing with time server: [  OK  ]
Starting ntpd:                        [  OK  ]


--
= ^ . ^ =

[1] http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/guest.html#time_linux
[2] https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sect-Date_and_Time_Configuration-Command_Line_Configuration-Network_Time_Protocol.html
[3] http://linux.die.net/man/8/ntpdate

Thursday, July 2, 2015

Bulk enable servers in phpMyAdmin

Put this in config.inc.php in phpMyAdmin if you are connecting to a bunch of servers (like I do xD).


--
= ^ . ^ =