Monday, June 23, 2014

Rails - Make Delayed job work with Rspec in tests

Turn off the queuing and let delayed job to run:

Delayed::Worker.delay_jobs = false

Friday, June 20, 2014

Rails override Time.now to return Time.zone.now

In initializer, add this:


class << Time
alias :system_now :now
def now
ActiveSupport::TimeWithZone.new(self.system_now.utc, Time.zone)
end
end

Tuesday, June 17, 2014

Nagios create plugins

On monitoring host:

Create plugin in /usr/lib/nagios/plugins (in C/Perl/Script/etc)
Enable plugin by:
1. define comment in /etc/nagios-plugins/config/somefile.cfg
2. edit /etc/nagios/conf.d/localhost_nagios2.cfg

Restart:
sudo service nagios3 restart

Thursday, June 12, 2014

Reviewed Ubuntu Server monitoring tools

Tried:
1. Nagios
2. Munin
3. Cacti
4. Zabbix

Turn out I like both Nagios and Zabbix.

Wednesday, June 11, 2014

Setup Nagios on Ubuntu 12.10

sudo apt-get update
sudo apt-get install nagios3 nagios-nrpe-plugin

If you have other web pages or apps running on the same server, the following information might be useful to separate Nagios as it's own Apache virtual host on a non-standard port (for example 43326 here).

Remove standard config and create Apache virtual host;

sudo cp /etc/apache2/conf.d/nagios.conf /etc/apache2/sites-available/nagio  s3  sudo rm /etc/apache2/conf.d/nagios.conf  sudo vi /etc/apache2/sites-available/nagios3  

To beginning of file add;

Listen 43326  <VirtualHost *:43326>      ServerAdmin webmaster@localhost      DocumentRoot /var/www/nagios3  

To the end of the file add;

</VirtualHost>  

Enable the new site;

sudo a2ensite nagios3  

If you run a firewall (UFW), open the port;

sudo ufw allow 43326  

Restart Apache

sudo service apache2 restart

Ubuntu OS upgrade

http://www.cyberciti.biz/faq/howto-upgrade-to-ubuntu-14-04-from-ubuntu-13-10-or-12-04/

Linux system monitoring

http://www.linuxscrew.com/2012/03/22/linux-monitoring-tools/
http://www.tecmint.com/command-line-tools-to-monitor-linux-performance/
http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
http://www.thegeekstuff.com/2011/12/linux-performance-monitoring-tools/
http://www.opensourceforu.com/2013/12/look-top-three-network-monitoring-tools/