<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-13480204</id><updated>2025-12-06T01:44:51.143-08:00</updated><title type='text'>IT on Demand</title><subtitle type='html'>創業,IT 趨勢, 創業點子, 商業, 行銷, 自動化家庭&#xa;Entrepreneurship, IT trend, business ideas, marketing, home automation, virtualization, mobile, VoIP, asterisk, FreeSWITCH, open source</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://unicsolution.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-13480204.post-2189398163364125198</id><published>2015-09-03T13:27:00.001-07:00</published><updated>2021-08-14T17:13:34.605-07:00</updated><title type='text'>OMD (Check_MK) Alert Notification Integration with PagerDuty Done Right</title><content type='html'>&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0CxL9cgX74-1eax6MrwjGVK_Ng7zMfzqMXuXCBxrSOabd3n9KxYn0yB86LZ4-61MuNNrw1Atf9o3aknbmLeWUMegdLXqyl2Sx9lkldlBqpQmm7R6_upe22FN9Kc3VWZTFqM1i/s0/shit%252520hit%252520the%252520fan.jpg&quot; alt=&quot;enter image description here&quot; title=&quot;shit hit the fan.jpg&quot;&gt; &lt;br&gt;
Yes, &lt;strong&gt;shit just hit the fan&lt;/strong&gt;. What are you gonna do?&lt;/p&gt;

&lt;p&gt;If you are thinking about integrating OMD or Check_MK alert notification with PagerDuty.com, you are in the right place. The &lt;a href=&quot;https://www.pagerduty.com/docs/guides/omd-check_mk-integration-guide/&quot;&gt;official documentation&lt;/a&gt; from PagerDuty is not done right by the &lt;strong&gt;Flexible Notification&lt;/strong&gt; feature provided with OMD (Open Monitoring Distribution) or Check_MK.&lt;/p&gt;

&lt;p&gt;If you don’t know what &lt;a href=&quot;https://mathias-kettner.de/checkmk_flexible_notifications.html&quot;&gt;Flexible Notification&lt;/a&gt; is or what OMD is about, I recommend you to check out my other blog post - &lt;a href=&quot;http://blog.unicsolution.com/2013/11/best-monitoring-solution-omd-nagios.html&quot;&gt;The Best Open Source Monitoring Solution 2015&lt;/a&gt;.&lt;/p&gt;



&lt;h2 id=&quot;create-notification-service-on-pagerduty&quot;&gt;Create Notification Service on PagerDuty&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; Log in to PagerDuty as an admin user. Click &lt;strong&gt;Service&lt;/strong&gt; under the &lt;strong&gt;Configuration&lt;/strong&gt; menu option. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_Ia514L-zl7TQf8KpbKqIMZBvwv7I5l-1bUtTVzVB3OnxlsPuZH6ivblGJoWzPdPD3Nmc_x2CXY4QyY3FRFndRbC_6Cj_QvT74ynH-edlxH2IBdp6DEdGK1rE6Nb68_WUeHEw/s0/2015-09-01%252520at%2525204.45%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;pagerduty step 1.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; Click the &lt;strong&gt;Add New Service&lt;/strong&gt; button. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggyUDfFC0ACXIhwwN-cri6ehexmnO_G5vMf5tXighCjzV-mQUZQQ6Vu_iTQWReBRG-qivly_pVzXSeOA7DWyJrBpurbKBIU9JQ5QMIpJuF-57R-RkJovfMpdsxO48LKabRqjeo/s0/2015-09-01%252520at%2525204.41%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;pagerduty step 2.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; Fill out the form as the arrows indicated in the following image. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvPPZGWGZfqRR38G38st3tnLI4SuaviMBPCfHYHKKwWaQfExHJ-VfrZVX8a-XoczXzhD8nvzFENTsa4UGceohHJ9upRbREzsJMezqcgNnjAqpK1hRXD_7o0l3Zuafw1Ib8jEe8/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;pagerduty step 3.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt; Congratulations, we are done with the PagerDuty part. Grab the &lt;strong&gt;Service API Key&lt;/strong&gt; for you are going to need it later. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg43ckvWiDjmavlGHO19MqQh_7dsXLQzE6hyaFJqLDGomVoxHboKzVnUyWFVnrRYlGOMoMB8UPi4O9tE6wJUNrtTNdc215RlGCDhibU_pvFu67lbtB-e6pSSLVr_p2MX8bF2pB1/s0/2015-09-02%252520at%2525201.07%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;pagerduty step 4.png&quot;&gt;&lt;/p&gt;



&lt;h2 id=&quot;install-pagerduty-notification-script&quot;&gt;Install PagerDuty Notification Script&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; SSH into the OMD server&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; Install Perl dependencies&lt;/p&gt;

&lt;p&gt;FOR RHEL, Fedora, CentOS, and other Redhat-based distributions:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;yum install perl-libwww-perl perl-Crypt-SSLeay perl-Sys-Syslog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For Debian, Ubuntu, and other Debian-based distributions:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;apt-get install libwww-perl libcrypt-ssleay-perl libsys-syslog-perl&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; Download &lt;strong&gt;pagerduty_nagios.pl&lt;/strong&gt; from github, copy it to &lt;strong&gt;/usr/local/bin&lt;/strong&gt; and make it executable:&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;wget https://raw.github.com/PagerDuty/pagerduty-nagios-pl/master/pagerduty_nagios.pl 
cp pagerduty_nagios.pl /usr/local/bin
chmod +x /usr/local/bin/pagerduty_nagios.pl&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt; Create &lt;strong&gt;cron job&lt;/strong&gt; to flush notification queue &lt;br&gt;
First become the OMD/Check_MK site user in shell, then create a &lt;strong&gt;cron.d&lt;/strong&gt; file under &lt;code&gt;/omd/sites/&amp;lt;&amp;lt;Site Name&amp;gt;&amp;gt;/etc/cron.d/pagerduty&lt;/code&gt; with the following content:&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;#
# Flush PagerDuty notification queue
#

* * * * * /usr/local/bin/pagerduty_nagios.pl flush&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now enable the cron job as the OMD site user:&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;omd reload crontab&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Since the cron job runs every minute, you can change back to the &lt;strong&gt;root&lt;/strong&gt; user and check to see if the cron job has been triggered as expected.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;[root@omd.server.com ~]# tail -f /var/log/cron
Sep  4 08:25:01 omd.server.com CROND[24090]: (omd_user) CMD (/usr/local/bin/pagerduty_nagios.pl flush)
Sep  4 08:26:01 omd.server.com CROND[27175]: (omd_user) CMD (/usr/local/bin/pagerduty_nagios.pl flush)
Sep  4 08:27:01 omd.server.com CROND[30195]: (omd_user) CMD (/usr/local/bin/pagerduty_nagios.pl flush)&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;integrate-with-omd-flexible-notification&quot;&gt;Integrate with OMD Flexible Notification&lt;/h2&gt;

&lt;p&gt;Assume you are still connected to OMD server with SSH. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; Adding custom Flexible Notification script &lt;br&gt;
copy and save the following script to location &lt;strong&gt;/omd/sites/{YOUR-SITE}/local/share/check_mk/notifications/pagerduty.sh&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;#!/bin/bash
# PagerDuty

PAGERDUTY=&quot;/usr/local/bin/pagerduty_nagios.pl&quot;

# For Service notification
if [ &quot;$NOTIFY_WHAT&quot; = &quot;SERVICE&quot; ]; then
    echo &quot;$PAGERDUTY enqueue -f pd_nagios_object=service -f CONTACTPAGER=\&quot;$NOTIFY_PARAMETER_1\&quot; -f NOTIFICATIONTYPE=\&quot;$NOTIFY_NOTIFICATIONTYPE\&quot; -f HOSTNAME=\&quot;$NOTIFY_HOSTNAME\&quot; -f SERVICEDESC=\&quot;$NOTIFY_SERVICEDESC\&quot; -f SERVICESTATE=\&quot;$NOTIFY_SERVICESTATE\&quot;&quot;
    $PAGERDUTY enqueue -f pd_nagios_object=service -f CONTACTPAGER=&quot;$NOTIFY_PARAMETER_1&quot; -f NOTIFICATIONTYPE=&quot;$NOTIFY_NOTIFICATIONTYPE&quot; -f HOSTNAME=&quot;$NOTIFY_HOSTNAME&quot; -f SERVICEDESC=&quot;$NOTIFY_SERVICEDESC&quot; -f SERVICESTATE=&quot;$NOTIFY_SERVICESTATE&quot;

# For Host notification
else
    $PAGERDUTY enqueue -f pd_nagios_object=host -f CONTACTPAGER=&quot;$NOTIFY_PARAMETER_1&quot; -f NOTIFICATIONTYPE=&quot;$NOTIFY_NOTIFICATIONTYPE&quot; -f HOSTNAME=&quot;$NOTIFY_HOSTNAME&quot; -f HOSTSTATE=&quot;$NOTIFY_HOSTSTATE&quot;
fi&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; Make it executable&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;chmod +x pagerduty.sh&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; Log in to OMD or Check_MK web interface and configure &lt;strong&gt;Flexible Notification&lt;/strong&gt; to use the NEW &lt;strong&gt;PagerDuty&lt;/strong&gt; notification script. &lt;/p&gt;

&lt;p&gt;Assuming you already know how to operate &lt;a href=&quot;https://mathias-kettner.de/checkmk_flexible_notifications.html&quot;&gt;Flexible Notification&lt;/a&gt;. Select &lt;strong&gt;PagerDuty&lt;/strong&gt; as the &lt;strong&gt;Notification Plugin&lt;/strong&gt; and put the &lt;strong&gt;API key&lt;/strong&gt; you acquired earlier when setting up PagerDuty service into the &lt;strong&gt;Plugin Arguments&lt;/strong&gt; field as shown in the image. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWuitJyOaAFjU7g6BblX6LhagilJVBLn4G8Yg083CiEFXpjQs52K4kQvHGlTWSyMCtUeNmahOsJkp7ngqPzptUrKSbfTcOWpwL8WCXoTJzKCRFmdCL1LEsbUXXM-TkuUComC_i/s0/2015-09-01%252520at%2525205.27%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;Flexable notification integration.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;Since &lt;strong&gt;pagerduty_nagios.pl&lt;/strong&gt; was designed to work with &lt;strong&gt;Nagios&lt;/strong&gt;, it doesn’t take flapping notifications. Make sure you &lt;strong&gt;uncheck&lt;/strong&gt; those boxes. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqH4pgZE3A7t-pM3deyKrDaDlWLxCN9JZ2oIupzZgzbMEXyk_BEzxvFCH2aa9EJqehmxpSz811PqYwg8LtBujdOetze-Dap_tQzwGKFNiXDPI-v1l-KAeT6hLokkXkxRIkNi0Y/s0/&quot; alt=&quot;enter image description here&quot; title=&quot;flexible notification 2.png&quot;&gt; &lt;br&gt;
&lt;i class=&quot;fa fa-bullhorn&quot;&gt;&lt;/i&gt; You can create multiple &lt;strong&gt;PagerDuty services&lt;/strong&gt; and pair them up with OMD/Check_MK &lt;strong&gt;Flexible Notification&lt;/strong&gt;. Happy ending. &lt;/p&gt;



&lt;h2 id=&quot;testing-and-troubleshooting&quot;&gt;Testing and Troubleshooting&lt;/h2&gt;



&lt;h3 id=&quot;test-pagerdutynagiospl&quot;&gt;Test pagerduty_nagios.pl&lt;/h3&gt;

&lt;p&gt;To send a test notification directly with the &lt;strong&gt;pagerduty_nagios.pl&lt;/strong&gt;, use the following example and swap out &lt;code&gt;&amp;lt;&amp;lt;API Key&amp;gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&amp;lt;HOST Name&amp;gt;&amp;gt;&lt;/code&gt; with your own value. &lt;/p&gt;

&lt;p&gt;&lt;i class=&quot;fa fa-asterisk&quot;&gt;&lt;/i&gt; Make sure you become the OMD site user first because once you run the command once, it’s going to create a directly in &lt;strong&gt;/tmp/pagerduty_nagios&lt;/strong&gt;. If you run the command as &lt;strong&gt;root&lt;/strong&gt; now, you will have permission issue later when OMD is trying to send notification to PagerDuty with a different user.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;/usr/local/bin/pagerduty_nagios.pl enqueue -f pd_nagios_object=service -f CONTACTPAGER=&quot;&amp;lt;&amp;lt;API Key&amp;gt;&amp;gt;&quot; -f NOTIFICATIONTYPE=&quot;PROBLEM&quot; -f HOSTNAME=&quot;&amp;lt;&amp;lt;HOST Name&amp;gt;&amp;gt;&quot; -f SERVICEDESC=&quot;this is just a test&quot; -f SERVICESTATE=&quot;CRIT&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You will be able to find output in &lt;strong&gt;syslog&lt;/strong&gt;, and depend on the OS variation you use, location may vary. &lt;/p&gt;

&lt;p&gt;If you get the following error message like I did:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;perl: symbol lookup error: /omd/sites/&amp;lt;&amp;lt;site Name&amp;gt;&amp;gt;/lib/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Encode/Encode.so: undefined symbol: Perl_Istack_sp_ptr&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add the following lines to the beginning of the PagerDuty Perl Script located &lt;strong&gt;/usr/local/bin/pagerduty_nagios.pl&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-perl&quot;&gt;use lib &#39;/usr/lib64/perl5/&#39;;
no lib &#39;/omd/sites/monitor/lib/perl5/lib/perl5/x86_64-linux-thread-multi&#39;;&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;test-with-flexible-notification&quot;&gt;Test with Flexible Notification&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; &lt;br&gt;
You first need to enable debugging for notification from the web UI. Enable setting in &lt;strong&gt;Global Settings&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Notifications&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Debug notifications&lt;/strong&gt;. The resulting log file is in the directory notify below Check_MK’s var directory. OMD users find the file in &lt;code&gt;~/var/check_mk/notify/notify.log&lt;/code&gt;. Remember switch it back after you are done debugging. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; &lt;br&gt;
Now pick a &lt;strong&gt;Host&lt;/strong&gt; for &lt;strong&gt;Service&lt;/strong&gt; that you’ve configure it’s notification to use the &lt;strong&gt;PagerDuty plugin&lt;/strong&gt;,  Click the &lt;strong&gt;Hammer icon&lt;/strong&gt; on the top and click on &lt;strong&gt;Critical&lt;/strong&gt; button in the &lt;strong&gt;Various Commands&lt;/strong&gt; section.  &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJuaJ1xGewFMP51q2gKpMmOJp_9C7Kr08PPVkYCMtaDOLt4R05yTmzQE5gVkXSO9d0aTKImtvFu5qEo8WKuUEAQbPudQlEIbdtTbPahdc-RJrTstIkbUOnFCY1LPZ6OOEzGTl5/s0/2015-09-02%252520at%2525202.58%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;OMD notification test 2.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; &lt;br&gt;
Now log in to the &lt;strong&gt;PagerDuty account&lt;/strong&gt; and select &lt;strong&gt;Dashboard&lt;/strong&gt; form the top menu. In a minute or two, you should see some thing as shown in the image. If not, you need to go back to the &lt;strong&gt;log files&lt;/strong&gt; and figure out why. &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNaNSiX1nR-Jnvuc3UISPwgxlmKrkPl1dbRZogZsQynqWb_eLbttckwE1lut4QBDYY4dCI-AZ1VwTZVsl9esM8v50I19_1FevBbk8pft6-wCkVrY2AsGHYHuAPVVTKBXL2m1kW/s0/2015-09-02%252520at%2525203.05%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;pagerduty dashboard.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;If you do see your fake incident appear on the PagerDuty dashboard, CONGRATULATIONS &lt;i class=&quot;fa fa-bullseye&quot;&gt;&lt;/i&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Share with us, comment on what notification mechanism do you use? Do you build it in-house or use a popular 3rd party service?&lt;/strong&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/2189398163364125198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/2189398163364125198'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2015/09/omd-checkmk-alert-notification.html' title='OMD (Check_MK) Alert Notification Integration with PagerDuty Done Right'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0CxL9cgX74-1eax6MrwjGVK_Ng7zMfzqMXuXCBxrSOabd3n9KxYn0yB86LZ4-61MuNNrw1Atf9o3aknbmLeWUMegdLXqyl2Sx9lkldlBqpQmm7R6_upe22FN9Kc3VWZTFqM1i/s72-c/shit%252520hit%252520the%252520fan.jpg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-5409393952775856792</id><published>2015-07-17T15:01:00.001-07:00</published><updated>2021-08-14T17:13:37.863-07:00</updated><title type='text'>Scale Selenium Grid in 5 Seconds with Zero Docker Experience</title><content type='html'>&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4SrpH_CSt1cT2ueFZrPp4OTcjGYKhiosVLFM0YuYcIbEbfV1eVpZRZeAQTG7WYmT63iaouGV_EOcAIBWGDHFDyT2Bp7MPRzB9-alrTJvDy9qhu8gsRIqGIosUVyvRAhsG1eTN/w638-h479-no/&quot; alt=&quot;usability testing&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;p&gt;The reason to use CoreOS as a Docker server is because CoreOS is an extremely light weight, stripped down Linux distribution containing none of the extras that are associated with Ubuntu and the like. And it was designed to run Docker and Docker clusters, so by using it we are buying the future.&lt;/p&gt;

&lt;p&gt;Many cloud service provider already has CoreOS image to start with. If you are not going to be running the CoreOS server on bare metal or if you have other Docker server already installed,  you can skip this step. &lt;/p&gt;



&lt;h2 id=&quot;install-coreos-on-bare-metal-hardware&quot;&gt;Install CoreOS on Bare Metal (Hardware)&lt;/h2&gt;

&lt;p&gt;Download the stable CoreOS ISO from here: &lt;a href=&quot;https://coreos.com/os/docs/latest/installing-to-disk.html&quot;&gt;Download Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you can burn the ISO into a CD/DVD or a bootable USB disk and use it as the boot source to boot up your physical server.&lt;/p&gt;

&lt;p&gt;Once the command line becomes available, create a &lt;code&gt;cloud-config.yml&lt;/code&gt; file with the ssh-key you will be using to connect to the server from remote later. The content of the file should look like this:&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;#cloud-config

ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUafOgrm+h...&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote&gt;
  &lt;p&gt;CoreOS allows you to declaratively customize various OS-level items, such as network configuration, user accounts, and systemd units. This document describes the full list of items we can configure. The coreos-cloudinit program uses these files as it configures the OS after startup or during runtime.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Unlike AWS, &lt;strong&gt;cloud-config&lt;/strong&gt; file is run during EACH system boot. While it is inspired by the &lt;strong&gt;cloud-init&lt;/strong&gt; project, there are tools isn’t used by CoreOS. Only the relevant subset of its configuration items is implemented in CoreOS &lt;strong&gt;cloud-config&lt;/strong&gt; file. Please refer to the official CoreOS document for detial on the subject.  &lt;br&gt;
&lt;a href=&quot;https://coreos.com/os/docs/latest/cloud-config.html&quot;&gt;&lt;code&gt;cloud-config&lt;/code&gt; Documentation Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now run the install command with the &lt;strong&gt;cloud-config&lt;/strong&gt; file name as argument:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;coreos-install -d /dev/sda -c cloud-config.yml&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you complete the above steps, reboot the server and make sure you remove your boot disk or boot CD/DVD. The server will boot up in command line mode and display it’s IP address obtained from DHCP server. From this point on, you can only ssh into the server via the ssh-key you provided earlier.&lt;/p&gt;



&lt;h2 id=&quot;install-and-setup-docker-compose&quot;&gt;Install and Setup Docker Compose&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Compose is a tool for defining and running multi-container applications with Docker. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;Docker Compose&lt;/code&gt; is the key component here to make spinning up or tearing down an entire Selenium Grid Farm (1 hub + multiple browsers) in a single command. Yes, you read it right, just &lt;strong&gt;ONE command&lt;/strong&gt;. Installing &lt;code&gt;Compose&lt;/code&gt; is a bit tricky though because of how CoreOS is built.&lt;/p&gt;

&lt;p&gt;Here is the &lt;i class=&quot;fa fa-youtube&quot;&gt;&lt;/i&gt; video that showed me how to install &lt;code&gt;docker-compose&lt;/code&gt; on CoreOS toward the end of the video. You can skip the video because it’s 46 minutes long. And I will show you the exact steps on how you can do the same next.&lt;/p&gt;

&lt;div class=&quot;embed-div&quot;&gt;
&lt;iframe src=&quot;https://www.youtube.com/embed/InLmXWgPzBs&quot; scrolling=&quot;no&quot; allowfullscreen=&quot;&quot;&gt; &lt;/iframe&gt;&lt;/div&gt;

&lt;h3 id=&quot;install-docker-compose&quot;&gt;Install Docker Compose&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;docker-compose&lt;/code&gt; is just a precompiled binary file we can download from its &lt;i class=&quot;fa fa-github&quot;&gt;&lt;/i&gt; &lt;a href=&quot;https://github.com/docker/compose/releases/&quot;&gt;Github Page&lt;/a&gt;. Check out the link and choose the latest version number to replace in the following code (run as the default &lt;code&gt;core&lt;/code&gt; user):&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir ~/bin
curl -L https://github.com/docker/compose/releases/download/1.3.3/docker-compose-`uname -s`-`uname -m` &amp;gt; ~/bin/docker-compose
chmod +x ~/bin/docker-compose
echo &quot;export PATH=&quot;$PATH:$HOME/bin&quot;&quot; &amp;gt;&amp;gt; ~/.bashrc
source ~/.bashrc&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Again if you are not using CoreOS, please follow the &lt;a href=&quot;https://docs.docker.com/compose/install/&quot;&gt;official installation instruction&lt;/a&gt; and skip the above code block.&lt;/p&gt;

&lt;p&gt;Now the &lt;code&gt;docker-compose&lt;/code&gt; command is ready for use, simply run &lt;code&gt;docker-compose&lt;/code&gt; in shell, you should see the following:&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;core@localhost ~ $ docker-compose
Define and run multi-container applications with Docker.

Usage:
  docker-compose [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE           Specify an alternate compose file (default: docker-compose.yml)
  -p, --project-name NAME   Specify an alternate project name (default: directory name)
  --verbose                 Show more output
  -v, --version             Print version and exit

Commands:
  build              Build or rebuild services
  help               Get help on a command
...&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&quot;configure-docker-compose-application-file&quot;&gt;Configure Docker Compose Application File&lt;/h3&gt;

&lt;p&gt;We’ll be using Docker images build by the official &lt;a href=&quot;https://registry.hub.docker.com/repos/selenium/&quot;&gt;Selenium repository&lt;/a&gt; on Docker Hub, so you don’t need to build your own.&lt;/p&gt;

&lt;p&gt;Under &lt;code&gt;/home/core/&lt;/code&gt; , create a file named &lt;code&gt;docker-compose.yml&lt;/code&gt; with the following content:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;hub:
  image: selenium/hub
  ports:
    - &quot;4444:4444&quot;
firefox:
  image: selenium/node-firefox
  links:
    - hub
chrome:
  image: selenium/node-chrome
  links:
    - hub&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can use other browser images in the &lt;a href=&quot;https://registry.hub.docker.com/repos/selenium/&quot;&gt;Selenium repository&lt;/a&gt; in the &lt;code&gt;docker-compose.yml&lt;/code&gt; file, and they should just work.&lt;/p&gt;



&lt;h2 id=&quot;manage-selenium-grid-with-docker-compose&quot;&gt;Manage Selenium Grid with Docker Compose&lt;/h2&gt;

&lt;p&gt;If you are running this for the first time, expect Docker to download all the necessary images in the beginning. Once all the images are downloaded into local repository, it will just take seconds to start the Selenium Grid in the future. &lt;/p&gt;



&lt;h3 id=&quot;start-selenium-grid&quot;&gt;Start Selenium Grid&lt;/h3&gt;

&lt;p&gt;As user &lt;code&gt;core&lt;/code&gt;, run:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;docker-compose -f ~/docker-compose.yml up -d&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By appending the &lt;code&gt;-d&lt;/code&gt; argument at the end of the command, you are telling Compose to run the application in the background (daemon). &lt;/p&gt;

&lt;p&gt;Sample output:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;core@localhost /usr $ docker-compose -f ~/docker-compose.yml up -d
Recreating core_hub_1...
Recreating core_firefox_1...
Recreating core_chrome_1...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you can verify it by running &lt;code&gt;docker ps&lt;/code&gt;:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;core@localhost /usr $ docker ps
CONTAINER ID        IMAGE                          COMMAND                CREATED              STATUS              PORTS                                                                         NAMES
a09d3ab302fa        selenium/node-chrome:latest    &quot;/opt/bin/entry_poin   About a minute ago   Up About a minute                                                                                 core_chrome_1
298a612a387a        selenium/node-firefox:latest   &quot;/opt/bin/entry_poin   About a minute ago   Up About a minute                                                                                 core_firefox_1
62136ab8fdb0        selenium/hub:latest            &quot;/opt/bin/entry_poin   About a minute ago   Up About a minute   0.0.0.0:4444-&amp;gt;4444/tcp                                                        core_hub_1&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To see the real action in browser, open url &lt;strong&gt;&lt;a href=&quot;http://your-coreos-IP:4444/grid/console&quot;&gt;http://your-coreos-IP:4444/grid/console&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfxkN4Lxi3bRzVbQQZqS-dxuj-t990T4L9Jn9rjHZE6uiit_h8vipokZip6Q1aUcgHnKR3nVSYw6yQzXSz1NqdYYpco-x17jKJEgzy0E42Xe_ZIAFiZzJ_BCVsnjWl85-5pVCT/s0/2015-07-17%252520at%2525201.45%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;selenium hub.png&quot;&gt;&lt;/p&gt;

&lt;h3 id=&quot;scale-selenium-grid&quot;&gt;Scale Selenium Grid&lt;/h3&gt;

&lt;p&gt;Let’s say you need 5 Firefox browser and 5 Chrome browser in your Grid. Simply run:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;docker-compose scale firefox=5 chrome=5&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Sample output:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;core@localhost ~ $ docker-compose scale firefox=5 chrome=5
Creating core_firefox_2...
Creating core_firefox_3...
Creating core_firefox_4...
Creating core_firefox_5...
Starting core_firefox_2...
Starting core_firefox_3...
Starting core_firefox_4...
Starting core_firefox_5...
Creating core_chrome_2...
Creating core_chrome_3...
Creating core_chrome_4...
Creating core_chrome_5...
Starting core_chrome_2...
Starting core_chrome_3...
Starting core_chrome_4...
Starting core_chrome_5...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And now your Selenium Hub management web page looks like this: &lt;br&gt;
enter image description here&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnnqq4F2ij_923kdk_aFhtJMH9i2nOQf4RlA8IihAmPyHBTPszcDiknq05Ppv89tJdlsz6NvenLUhVbjeD7VPtPq7DJYyvwjQeldpoVOPotBhU90EmdS_MW2F_0sR3HEN8TsCh/w669-h599-no/&quot; alt=&quot;selenium grid with multiple browsers&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;h3 id=&quot;tearing-down-selenium-grid&quot;&gt;Tearing Down Selenium Grid&lt;/h3&gt;

&lt;p&gt;Demolishing the entire selenium grid is just as easy as starting them. Since it only takes seconds to start, have a clean slate for all the Selenium tests is not a dream any more. You want all the browser to start without previous cookies or settings, and all is possible now with Docker containers.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;docker-compose -f ~/docker-compose.yml stop &amp;amp;&amp;amp; docker-compose -f ~/docker-compose.yml rm -f&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Sample output:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;core@localhost ~ $ docker-compose -f ~/docker-compose.yml stop &amp;amp;&amp;amp; docker-compose -f ~/docker-compose.yml rm -f
Stopping core_chrome_1...
Stopping core_firefox_1...
Stopping core_hub_1...
Going to remove core_chrome_1, core_firefox_1, core_hub_1
Removing core_hub_1...
Removing core_firefox_1...
Removing core_chrome_1...&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;integrate-with-jenkins&quot;&gt;Integrate with Jenkins&lt;/h2&gt;

&lt;p&gt;Now to have it integrated with Jenkins for automated testing. I will update this when I have this setup in my environment.&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/5409393952775856792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/5409393952775856792'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2015/07/scale-selenium-grid-in-5-seconds-with.html' title='Scale Selenium Grid in 5 Seconds with Zero Docker Experience'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4SrpH_CSt1cT2ueFZrPp4OTcjGYKhiosVLFM0YuYcIbEbfV1eVpZRZeAQTG7WYmT63iaouGV_EOcAIBWGDHFDyT2Bp7MPRzB9-alrTJvDy9qhu8gsRIqGIosUVyvRAhsG1eTN/s72-w638-h479-c-no/" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-8188305893897919278</id><published>2015-05-08T01:10:00.001-07:00</published><updated>2021-08-14T17:13:40.412-07:00</updated><title type='text'>How to Clone a Live Production Linux Server with This Cool Technique</title><content type='html'>&lt;p&gt;Do you find yourself stuck with some old Ubuntu Server that runs some critical application on a Physical Hardware which is running out of resources. You don’t want to waste rack space by cloning it to another physical server. You are a smart guy, you know cloning it to a VM gives you all the benefit of modern day server management. &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD1aIWrujnZtgS_nKtBFuq6rOqXHFXk_TKflWkPcPsfgEDCjzDROYj-spvHootxM-o2hP1e5zUI2iCVmMyi_2O2SvDaYS12FjAliN35xZC8gPzWKw0v2vX9ByU5VoiXPD6WVZD/s0/Star_Wars_The_Clone_Wars.png&quot; alt=&quot;live clone&quot; title=&quot;Star_Wars_The_Clone_Wars.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;What if the original hard drive has couple hundred Gigs of disk space and the actual data is only a few to a few dozen Gigs? You don’t want all that unused disk space to be also cloned into the VM via &lt;code&gt;dd&lt;/code&gt; command. Is there a way to &lt;strong&gt;clone the server to a smaller disk&lt;/strong&gt; that lives on a KVM VM guest? &lt;strong&gt;What if you can’t risk shutting down the physical server&lt;/strong&gt; because it is in production and is a single point of failure? Look no further, here’s how you can &lt;strong&gt;live clone&lt;/strong&gt; a old running Linux server to a KVM virtual machine.&lt;/p&gt;



&lt;h2 id=&quot;prepare-new-kvm-guest-image&quot;&gt;Prepare New KVM Guest Image&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; - Log in to your KVM host server and create a qcow2 image file with enough disk space to clone the actual data from the physical server:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;qemu-img create -f qcow2 new-vm.qcow2 100G&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; - Let’s attach the &lt;strong&gt;qcow2&lt;/strong&gt; file to a local device on KVM host so you can partition and format it.&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;mkdir /mnt/new-vm
modprobe nbd max_part=8
qemu-nbd -c /dev/nbd0 new-vm.qcow2
cfdisk /dev/nbd0
mkfs.ext3 -v /dev/nbd0p1&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;cfsidk&lt;/code&gt; - Create partition. Tailor this to your environment, instruction &lt;a href=&quot;http://www.absolutelinux.org/installing/cfdisk.shtml&quot;&gt;HERE&lt;/a&gt;. &lt;br&gt;
&lt;code&gt;mkfs.ext3&lt;/code&gt; - Format the disk to &lt;strong&gt;ext3&lt;/strong&gt; filesystem. You can also use &lt;code&gt;mkfs.ext4&lt;/code&gt; or other type of filesystem depend on your situation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; - Mount the drive&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;partprobe /dev/nbd0
mount /dev/nbd0p1 /mnt/new-vm&lt;/code&gt;&lt;/pre&gt;



&lt;h2 id=&quot;clone-data-from-physical-server&quot;&gt;Clone Data from Physical Server&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt; - Rsync (Copy) all the files from the physical server &lt;br&gt;
Do a dry run first. &lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;rsync -e &#39;ssh -p 22&#39; -avxn root@physical.server.com:/ /mnt/new-vm/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now do it for real if you don’t see any problem with the dry run.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;rsync -e &#39;ssh -p 22&#39; -avx root@physical.server.com:/ /mnt/new-vm/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 5.&lt;/strong&gt; - Sync data for the last time &lt;br&gt;
Make sure all cached data are written to the hard drive on the physical server by running:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;sync;sync;sync&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Go back to the KVM host and do final &lt;code&gt;rsync&lt;/code&gt; again&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;rsync -e &#39;ssh -p 22&#39; -avx root@physical.server.com:/ /mnt/new-vm/&lt;/code&gt;&lt;/pre&gt;



&lt;h2 id=&quot;clean-up&quot;&gt;Clean up&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 6.&lt;/strong&gt; - Update disk UUID in GRUB bootloader &lt;br&gt;
On the KVM host:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;blkid&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You will get a list of mounted drives UUID. Copy the one that follows &lt;code&gt;/dev/nbd0&lt;/code&gt;. Use that value and &lt;strong&gt;replace&lt;/strong&gt; all the disk UUID in &lt;code&gt;/mnt/new-vm/boot/grub/grub.cfg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7.&lt;/strong&gt; - Clean up &lt;code&gt;/etc/fstab&lt;/code&gt; &lt;br&gt;
Do the same for &lt;code&gt;/mnt/new-vm/etc/fstab&lt;/code&gt; and replace with the new UUID or just remove all UUID in the &lt;code&gt;fstab&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8.&lt;/strong&gt; - Clean up network settings&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change IP address by editing &lt;code&gt;/mnt/new-vm/etc/network/interfaces&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Remove cached mac address from udev. &lt;code&gt;/mnt/new-vm/etc/udev/rules.d/70-persistent-net.rules&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Edit any application settings that might create conflict with your physical server once you stand the new VM up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 9.&lt;/strong&gt; - Un-mount the drive&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;umount /mnt/new-vm
qemu-nbd -d /dev/nbd0&lt;/code&gt;&lt;/pre&gt;



&lt;h2 id=&quot;stand-up-the-new-vm&quot;&gt;Stand Up the New VM&lt;/h2&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;virt-install \
--connect qemu:///system \
-n vm-name \
--os-type linux \
--vcpus=2 \
--ram 2048 \
--disk path=/path/to/new-vm.qcow2 \
--vnc \
--vnclisten=127.0.0.1 \
--noautoconsole \
--import&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Change the &lt;code&gt;vm-name&lt;/code&gt;, &lt;code&gt;vcpus&lt;/code&gt;, &lt;code&gt;ram&lt;/code&gt;, and &lt;code&gt;disk&lt;/code&gt; location to your liking. If everything go smooth, you should see these success messages on screen:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;Starting install...
Creating domain...                                                                             |    0 B     00:01
Domain creation completed. You can restart your domain by running:
  virsh --connect qemu:///system start new-vm&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can now try to &lt;strong&gt;ssh&lt;/strong&gt; into the new VM using the new IP and see if things are working. To troubleshoot any issue, you will need to use VNC to connect to your VM and debug accordingly. Congratulations! You’ve now save your company from a legacy dying server to the new, shiny, scalable, replicable, and testable VM. Now this is money ~~~&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://diogogomes.com/2012/07/13/debootstrap-kvm-image/&quot;&gt;&lt;/a&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/8188305893897919278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/8188305893897919278'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2015/05/clone-live-linux-server-to-kvm.html' title='How to Clone a Live Production Linux Server with This Cool Technique'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD1aIWrujnZtgS_nKtBFuq6rOqXHFXk_TKflWkPcPsfgEDCjzDROYj-spvHootxM-o2hP1e5zUI2iCVmMyi_2O2SvDaYS12FjAliN35xZC8gPzWKw0v2vX9ByU5VoiXPD6WVZD/s72-c/Star_Wars_The_Clone_Wars.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-2037453282825725504</id><published>2015-01-21T01:05:00.001-08:00</published><updated>2021-08-14T17:13:43.805-07:00</updated><title type='text'>Kamailio High Availability Done Right with Keepalived</title><content type='html'>&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2WQCkUkq2F470z7wcDJ8bBhV9kaWttyE6sRPNSWOUGsvYUD0zojdzldvRcXQbemoHJBQUD-UpoBuLIY2DNiOUvwvJheArJQoGHmZ_rJGlBkCDtkaP-fi38_CP4pk9HCsy2bA2/s0/high-availability.jpg&quot; alt=&quot;enter image description here&quot; title=&quot;high-availability.jpg&quot;&gt;&lt;/p&gt;

&lt;p&gt;Keepalived is a Linux implementation of the VRRP (Virtual Router Redundancy Protocol) protocol to make IPs highly available - a so called VIP (Virtual IP).&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Usually the VRRP protocol ensures that one of participating nodes is &lt;br&gt;
  master. The backup node(s) listens for multicast packets from a node &lt;br&gt;
  with a higher priority. If the backup node fails to receive VRRP &lt;br&gt;
  advertisements for a period longer than three times of the &lt;br&gt;
  advertisement timer, the backup node takes the master state and &lt;br&gt;
  assigns the configured IP(s) to itself. In case there are more than &lt;br&gt;
  one backup nodes with the same priority, the one with the highest IP &lt;br&gt;
  wins the election.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I have ditched Corosync + Pacemaker for simpler and easily manageable cluster via Keepalived. Any of you who have played with Pacemaker will understand what I mean. I assume you’ve already got your Kamailio server installed and configured. &lt;/p&gt;



&lt;h2 id=&quot;install-packages&quot;&gt;Install Packages&lt;/h2&gt;

&lt;p&gt;I am using Ubuntu server for the installation. &lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;apt-get install -y keepalived sipsak&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;sipsak&lt;/code&gt; here will be wrapped in a check script to ensure Kamailio is still accepting SIP quests. VRRP is good for detecting network failure, but we also need something in place to check on the service level.&lt;/p&gt;



&lt;h2 id=&quot;set-kamailio-to-listen-on-vip&quot;&gt;Set Kamailio to listen on VIP&lt;/h2&gt;

&lt;p&gt;Allow Kamailio to bind or listen to the VIP even when the VIP does not exist on the backup node. You first need to append the following to &lt;code&gt;/etc/sysctl.conf&lt;/code&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;# allow services to bind to the virtual ip even when this server is the passive machine
net.ipv4.ip_nonlocal_bind = 1&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enable the setting immediately:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;sysctl -p&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Change Kamailio’s config file &lt;code&gt;/etc/Kamailio/Kamailio.cfg&lt;/code&gt; to force Kamailio to listen on the VIP:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;listen=&amp;lt;&amp;lt;VIP&amp;gt;&amp;gt;:&amp;lt;&amp;lt;Port Num&amp;gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Apply the above to both severs, and restart Kamailio:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;service Kamailio restart&lt;/code&gt;&lt;/pre&gt;



&lt;h2 id=&quot;configure-keepalived&quot;&gt;Configure Keepalived&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;/etc/keepalived/keepalived.conf&lt;/code&gt;  with the following content on both nodes&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;!Configuration File for keepalived

vrrp_script check_sip {
    script       &quot;/etc/keepalived/checksip.sh&quot;
    interval 5   # check every 5 seconds
    fall 2       # require 2 failures for KO
    rise 4       # require 4 successes for OK
}

vrrp_instance SBC_1 {
    state BACKUP
    interface eth0
    virtual_router_id 56
#   priority 100
    nopreempt
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass somepassword
    }
    virtual_ipaddress {
        123.123.123.123/24 brd 123.123.123.255 dev eth0 label eth0:0
    }
    track_script {
        check_sip
    }
    notify_master &quot;/etc/keepalived/master-backup.sh MASTER&quot;
    notify_backup &quot;/etc/keepalived/master-backup.sh BACKUP&quot;
    notify_fault &quot;/etc/keepalived/master-backup.sh FAULT&quot;
}&lt;/code&gt;&lt;/pre&gt;

&lt;ol&gt;
&lt;li&gt;If you have multiple pair of Keepalived cluster running on the same subnet, make sure each pair’s &lt;code&gt;vrrp_instance&lt;/code&gt; name and &lt;code&gt;virtual_router_id&lt;/code&gt; number are different or else the failover will not work correctly.&lt;/li&gt;
&lt;li&gt;Comment out the &lt;code&gt;priority&lt;/code&gt; so that the VIP won’t flap when a failed node comes back online. In other words, make the VIP sticky to the node it’s currently running on.&lt;/li&gt;
&lt;li&gt;Change the &lt;code&gt;fall&lt;/code&gt; and &lt;code&gt;rise&lt;/code&gt; interval under the &lt;code&gt;vrrp_script check_sip&lt;/code&gt; according to your need. Once the script determined that Kamailio is down, Keepalived will failover the VIP to the backup server.&lt;/li&gt;
&lt;li&gt;Notification parameters at the bottom of the configuration: &lt;br&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;notify_master&lt;/strong&gt; - will be triggered on the server that is becoming the master server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;notify_backup&lt;/strong&gt; - will be triggered on the server that is degraded to be a backup server or starting up as a backup server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;notify_faults&lt;/strong&gt; - will be triggered when any of the vrrp check script reached it’s threshold and determines the service is no longer available, then the status will turn into faults and trigger the notify_faults script.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apply the same configuration file on both the &lt;code&gt;master&lt;/code&gt; and &lt;code&gt;backup&lt;/code&gt; nodes. &lt;/p&gt;



&lt;h3 id=&quot;create-checking-script&quot;&gt;Create Checking Script&lt;/h3&gt;

&lt;p&gt;There is no fencing mechanism available for Keepalived. If two participating nodes don’t see each other, both will have the master state and both will carry the same IP(s). When I was looking for a way to detect which one should stay the master or give up his master state, I discovered the &lt;code&gt;Check Script&lt;/code&gt; mechanism.&lt;/p&gt;

&lt;p&gt;A check script is a script written in the language of your choice which is executed regularly. This script needs to have a return value: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0 for “everything is fine”&lt;/li&gt;
&lt;li&gt;1 (or other than 0) for “something went wrong”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This value is used by Keepalived to take action. Scripts are defined like this in &lt;code&gt;/etc/keepalived.conf&lt;/code&gt;:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;vrrp_script check_sip {
    script       &quot;/etc/keepalived/checksip.sh&quot;
    interval 5   # check every 5 seconds
    fall 2       # require 2 failures for KO
    rise 4       # require 4 successes for OK
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see in the example, it’s possible to specify the interval in seconds and also how many times the script needs to succeed or fail until any action is taken.&lt;/p&gt;

&lt;p&gt;The script can check anything you want. Here are some ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the daemon X running?&lt;/li&gt;
&lt;li&gt;Is the interface X on the remote switch Y up?&lt;/li&gt;
&lt;li&gt;Is the IP 8.8.8.8 pingable?&lt;/li&gt;
&lt;li&gt;Is there enough disk space available to run my application?&lt;/li&gt;
&lt;li&gt;$MYIDEA&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out the &lt;a href=&quot;#check-script-configuration-samples&quot;&gt;Check Script Configuration Samples&lt;/a&gt; section on how to do some of those.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;/etc/keepalived/checksip.sh&lt;/code&gt; and make sure it is executable.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;#!/bin/bash

if ls /etc/keepalived/MASTER; then
    timeout 1 sipsak -s sip:s@10.10.10.10:5060
    exit
else
    exit 0
fi&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This script will test SIP service on Kamailio’s private IP and make sure Kamailio is working on the Master node. I will explain how I use the &lt;code&gt;/etc/keepalived/master-backup.sh&lt;/code&gt; to determine the master node in a little bit.&lt;/p&gt;



&lt;h3 id=&quot;notify-script&quot;&gt;Notify Script&lt;/h3&gt;

&lt;p&gt;A notify script can be used to take other actions, not only removing or adding an IP to an interface. It can trigger any script you desire based on . And this is how it can be defined in the Keepalived configuration:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;vrrp_instance MyVRRPInstance {
 [...]
 notify_master &quot;/etc/keepalived/master-backup.sh MASTER&quot;
 notify_backup &quot;/etc/keepalived/master-backup.sh BACKUP&quot;
 notify_fault &quot;/etc/keepalived/master-backup.sh FAULT
}&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;notify_mater&lt;/strong&gt; - is triggered when the node becomes a master node.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;nofity_backup&lt;/strong&gt; - is triggered when the node becomes a backup node.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;notify_fault&lt;/strong&gt; - is triggered when VRRP determine the network is at fault or when one of your check script has reached its fault threshold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So with the above setting, we want to create the script in &lt;code&gt;/etc/keepalived/master-backup.sh&lt;/code&gt; and make it executable:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;#!/bin/bash

STATE=$1
NOW=$(date +&quot;%D %T&quot;)
KEEPALIVED=&quot;/etc/keepalived&quot;

case $STATE in
        &quot;MASTER&quot;) touch $KEEPALIVED/MASTER
                  echo &quot;$NOW Becoming MASTER&quot; &amp;gt;&amp;gt; $KEEPALIVED/COUNTER
                  /etc/init.d/Kamailio start
                  exit 0
                  ;;
        &quot;BACKUP&quot;) rm $KEEPALIVED/MASTER
                  echo &quot;$NOW Becoming BACKUP&quot; &amp;gt;&amp;gt; $KEEPALIVED/COUNTER
                  /etc/init.d/Kamailio stop || killall -9 Kamailio
                  exit 0
                  ;;
        &quot;FAULT&quot;)  rm $KEEPALIVED/MASTER
                  echo &quot;$NOW Becoming FAULT&quot; &amp;gt;&amp;gt; $KEEPALIVED/COUNTER
                  /etc/init.d/Kamailio stop || killall -9 Kamailio
                  exit 0
                  ;;
        *)        echo &quot;unknown state&quot;
                  echo &quot;$NOW Becoming UNKOWN&quot; &amp;gt;&amp;gt; $KEEPALIVED/COUNTER
                  exit 1
                  ;;
esac&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We rely on this script to start or stop &lt;code&gt;Kamailio&lt;/code&gt; server. The reason I am not running active-active Kamailio HA is because is because if the backup Kamailio is running and sending probing to its load balancing targets, it will generate good amount of VIP errors continuous in the syslog file for the VIP it does not own yet.&lt;/p&gt;

&lt;p&gt;I rather have a cleaner log file that I can use to troubleshoot later and sacrifice a few seconds waiting for the backup Kamailio to start.&lt;/p&gt;



&lt;h3 id=&quot;boot-sequence&quot;&gt;Boot Sequence&lt;/h3&gt;

&lt;p&gt;As I mentioned, we don’t want Kamailio to start on boot on its own. We want Keepalived to manage the start and stop of Kamailio application. Here is how we disable Kamailio on boot:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;update-rc.d -f Kamailio remove&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The boot system on Ubuntu is currently messed up. Some application use &lt;code&gt;Upstart&lt;/code&gt; and some application still use &lt;code&gt;System V&lt;/code&gt;, there is no telling which upstart managed application will start first. But if you are using MySQL as the database for Kamailio, you will want to ensure MySQL is started before Kamailio. And because we are using Keepalived to control Kamailio, therefore we want MySQL to start before Keepalived when boot:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disable Keepalived from starting via &lt;code&gt;System V&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;update-rc.d -f keepalived remove&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Create an Upstart script&lt;/strong&gt; in &lt;code&gt;/etc/init/keepalived.conf&lt;/code&gt; that will start Keepalived service after MySql server is started on boot:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;# Keepalived Service

description     &quot;Keepalived&quot;

start on started mysql
pre-start script
  /etc/init.d/keepalived start
end script
post-stop script
  /etc/init.d/keepalived stop
end script&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Restart Keepalived on both nodes when you are ready to :&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;service keepalived restart&lt;/code&gt;&lt;/pre&gt;



&lt;h2 id=&quot;check-script-configuration-samples&quot;&gt;Check Script Configuration Samples&lt;/h2&gt;

&lt;p&gt;Showcase different ways to check services:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;vrrp_script chk_sshd {
       script &quot;killall -0 sshd&quot;        # cheaper than pidof
       interval 2                      # check every 2 seconds
       weight -4                       # default prio: -4 if KO
       fall 2                          # require 2 failures for KO
       rise 2                          # require 2 successes for OK
}

vrrp_script chk_haproxy {
       script &quot;killall -0 haproxy&quot;     # cheaper than pidof
       interval 2                      # check every 2 seconds
}

vrrp_script chk_http_port {
       script &quot;&amp;lt;/dev/tcp/127.0.0.1/80&quot; # connects and exits
       interval 1                      # check every second
       weight -2                       # default prio: -2 if connect fails
}

vrrp_script chk_https_port {
       script &quot;&amp;lt;/dev/tcp/127.0.0.1/443&quot;
       interval 1
       weight -2
}

vrrp_script chk_smtp_port {
       script &quot;&amp;lt;/dev/tcp/127.0.0.1/25&quot;
       interval 1
       weight -2
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;How to incorporate the above checks into &lt;code&gt;vrrp_instance&lt;/code&gt; configs:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 100
    virtual_ipaddress {
        192.168.200.18/25
    }
    track_interface {
       eth1 weight 2   # prio = +2 if UP
       eth2 weight -2  # prio = -2 if DOWN
       eth3            # no weight, fault if down
    }
    track_script {
       chk_sshd                # use default weight from the script
       chk_haproxy weight 2    # +2 if process is present
       chk_http_port
       chk_https_port
       chk_smtp_port
    }
}

vrrp_instance VI_2 {
    interface eth1
    state MASTER
    virtual_router_id 52
    priority 100
    virtual_ipaddress {
        192.168.201.18/26
    }
    track_interface {
       eth0 weight 2   # prio = +2 if UP
       eth2 weight -2  # prio = -2 if DOWN
       eth3            # no weight, fault if down
    }
    track_script {
       chk_haproxy weight 2
       chk_http_port
       chk_https_port
       chk_smtp_port
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For every set of VIPs, use a new &lt;code&gt;vrrp_instance&lt;/code&gt; profile with unique instance name and &lt;code&gt;virtual_router_id&lt;/code&gt; number. &lt;code&gt;track_interface&lt;/code&gt; is optional for checking network interfaces, it will mark FAULT state if any of the interface goes down.&lt;/p&gt;



&lt;h2 id=&quot;monitoring-with-omd-or-checkmk&quot;&gt;Monitoring with OMD or Check_MK&lt;/h2&gt;

&lt;p&gt;Ah ha, I knew you would ask. This section will come out later.&lt;/p&gt;



&lt;h2 id=&quot;tcp-failover&quot;&gt;TCP Failover?&lt;/h2&gt;

&lt;p&gt;I have done my share of research work to find a solution to safely migrate established TCP connection from master node to backup node without success. It will be so cool to have SIP TCP session to stay alive during the failover. Even so, I am keeping my notes here for people who would like to give it a stab. &lt;/p&gt;

&lt;p&gt;All the following effort seemed like working when I check the TCP session after failover but when I actually trying to verify the session, it fails. If anyone of you know anything that works, please do share with us in the comment section. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.linuxjournal.com/article/10964?page=0,1&quot;&gt;Build a Better Firewall-Linux HA Firewall Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://conntrack-tools.netfilter.org/testcase.html&quot;&gt;Conntrack test case&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;i class=&quot;fa fa-star&quot;&gt;&lt;/i&gt; &lt;a href=&quot;http://sockmi.sourceforge.net/&quot;&gt;SockMi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;i class=&quot;fa fa-star&quot;&gt;&lt;/i&gt; &lt;a href=&quot;http://dragon.linux-vs.org/~dragonfly/htm/tcpha.htm&quot;&gt;TCPHA&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h3 id=&quot;conntrack-commands&quot;&gt;conntrack commands&lt;/h3&gt;

&lt;p&gt;&lt;i class=&quot;fa fa-external-link&quot;&gt;&lt;/i&gt; &lt;a href=&quot;http://manpages.ubuntu.com/manpages/lucid/man8/conntrack.8.html&quot;&gt;conntack man page&lt;/a&gt; &lt;br&gt;
Make sure you have the proper kernel modules enabled before any of the command can produce results for you. Run &lt;code&gt;lsmod&lt;/code&gt; in Linux shell and see if the output contains the following results.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nf_conntrack_ipv4      19716  0
nf_defrag_ipv4         12729  1 nf_conntrack_ipv4&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you don’t have the above, try running &lt;code&gt;modprobe ip_conntrack&lt;/code&gt; and retest the above.&lt;/p&gt;

&lt;p&gt;Assume you have the above ready, you can use the following commands to validate connection session on the Linux server.&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;# List connection tacking or expectation table and display output in extended format
conntrack -L -o extended

# List connection tacking or expectation table
conntrack -L

# Display a real-time event log
conntack -E&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;i class=&quot;fa fa-smile-o&quot;&gt;&lt;/i&gt; Happy HA~&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Special Thanks to These References:&lt;/strong&gt; &lt;br&gt;
&lt;i class=&quot;fa fa-star-o&quot;&gt;&lt;/i&gt; &lt;a href=&quot;https://tobrunet.ch/2013/07/keepalived-check-and-notify-scripts/&quot;&gt;https://tobrunet.ch/2013/07/keepalived-check-and-notify-scripts/&lt;/a&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/2037453282825725504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/2037453282825725504'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2015/01/kamailio-high-availability-with.html' title='Kamailio High Availability Done Right with Keepalived'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2WQCkUkq2F470z7wcDJ8bBhV9kaWttyE6sRPNSWOUGsvYUD0zojdzldvRcXQbemoHJBQUD-UpoBuLIY2DNiOUvwvJheArJQoGHmZ_rJGlBkCDtkaP-fi38_CP4pk9HCsy2bA2/s72-c/high-availability.jpg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-5669205148466547896</id><published>2014-07-19T17:32:00.001-07:00</published><updated>2021-08-14T17:13:45.704-07:00</updated><title type='text'>Fake it till You Make it ep. 1 - Learn New IT Skills Like a Maniac</title><content type='html'>&lt;p&gt;Remember the last time you need to pick up a piece of new technology or programming language among the other hundred thousand things you need to take care of? Well, it wasn’t pleasant was it. When I started learning about Linux, I wanted to be fast and know lots of command on top of my head. Years goes by, I realize my dream of wanting to be a COOL Sys Admin is slipping away because… until I found a solution toward the end of 2012. &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe0Rc-6hUkpK042l2W956MIQOw3b5yC2Ijx34i9IIeCSpsiKQctV18y75rBgFpKX9sIUKypCjIMoaHtdNggSJUw7dn5FlogAvuy4qJKFoEX9TxsgeQAfGZvKk1DXdD0uJljVMF/s0/sysadmin-hero.png&quot; alt=&quot;enter image description here&quot; title=&quot;sysadmin-hero.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;The technique I am about to reveal not only help IT people but anyone who needs to deal with typing, emailing, documenting, and customer support all the time. If my technique is able to save you an average of 5 minutes a day, that is about 30 HOURS SAVED every year. That time saved can be used to learn one extra skill or free for whatever you want to do. Without further ado, check out my presentation below:&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;sys-admin-on-steroids&quot;&gt;Sys Admin on Steroids&lt;/h2&gt;

&lt;div class=&quot;embed-div&quot;&gt;
&lt;iframe src=&quot;//www.slideshare.net/slideshow/embed_code/37147285&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC;border-width:1px 1px 0;margin-bottom:5px&quot; allowfullscreen=&quot;&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot;&gt; &lt;/iframe&gt;&lt;/div&gt;

&lt;p&gt;Let me know if you guys need some video demos to show how well it works in the comments area.&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/5669205148466547896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/5669205148466547896'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2014/07/fake-it-till-you-make-it-ep-1-learn-new.html' title='Fake it till You Make it ep. 1 - Learn New IT Skills Like a Maniac'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe0Rc-6hUkpK042l2W956MIQOw3b5yC2Ijx34i9IIeCSpsiKQctV18y75rBgFpKX9sIUKypCjIMoaHtdNggSJUw7dn5FlogAvuy4qJKFoEX9TxsgeQAfGZvKk1DXdD0uJljVMF/s72-c/sysadmin-hero.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-7026563920272861837</id><published>2014-05-14T23:08:00.001-07:00</published><updated>2021-08-14T17:13:49.893-07:00</updated><title type='text'>CPU Load Spiked with No Apparent Reason - Check RAID Battery</title><content type='html'>&lt;h2 id=&quot;scenario&quot;&gt;Scenario&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;If you got here in an emergency to bring back your server health&lt;/code&gt;&lt;/strong&gt;, please skip to the &lt;i class=&quot;fa fa-link&quot;&gt;&lt;/i&gt; &lt;a href=&quot;#urgent-care&quot;&gt;Ugent Care&lt;/a&gt; section at the bottom of this page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTeJjdvgig8TI1RDj_q2Z81S5x_L4At3xcqCGdHGR0JkmEotYn5Ip627xLRymnNPyPqBQ-XKnFFE9lBSM_zU9yhjXOUInLyxjmCm0KZMKFgftqs0Ls03lsni-BafMlcRczI5Gd/s0/low%252520battery.jpeg&quot; alt=&quot;enter image description here&quot; title=&quot;low battery.jpeg&quot;&gt; &lt;br&gt;
You are here because you can’t figure out what on earth is eating up your CPU load. I mean, you’ve checked almost everything that can cause high CPU load, things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Busy application&lt;/li&gt;
&lt;li&gt;Disk I/O bound&lt;/li&gt;
&lt;li&gt;Slow database queries&lt;/li&gt;
&lt;li&gt;System using swap instead or RAM&lt;/li&gt;
&lt;li&gt;Dependency on a remote mount point being slow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When none of the above seems to be the cause of your CPU load problem, you might want to check your RAID battery status or BBU (Battery Backup Unit) relearn cycle. The only kind of RAID controller covered here is LSI which you would find in most Dell servers.&lt;/p&gt;

&lt;h2 id=&quot;root-cause&quot;&gt;Root Cause&lt;/h2&gt;

&lt;p&gt;This is often seen on RAID controllers in Dell servers, specifically LSI controllers. The default behavior of the LSI RAID controller is to set to periodically go through a so-called ‘relearn cycle’ for its battery backup unit (BBU). During the process, it discharges, then re-charges and calibrates itself to find the current charge level. In this time frame, the RAID write cache policy is set to &lt;code&gt;WriteThrough&lt;/code&gt; instead of &lt;code&gt;WriteBack&lt;/code&gt; where &lt;code&gt;WriteThrough&lt;/code&gt; is accessing the physical disk directly and &lt;code&gt;WriteBack&lt;/code&gt; uses the RAID cache as the write buffer. &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEgo-W0IagpfhQyswQQkUq-qG-t9VdWF1F49HVGKrtnT4GT8qtzcVYYWZCUBwxsR3JfjtrdtMDRYIc7SMDT7nVAvT5ibzqdzCHpBPFGHgaa04Jla4UPDwv1YJhmI27reeexNos/s0/Screen%252520Shot%2525202014-05-14%252520at%25252010.00.10%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;CPU load spike.png&quot;&gt; &lt;br&gt;
Without the cache buffering, disk I/O is drastically slowed down and will cause CPU to wait much longer for any application requests. During busy hours, it will appears as a symptom of high CPU load with no visible reasons. There are a few things we can do to prevent this happening again in the future, but lets begin with the right tool and commands to use for troubleshooting.&lt;/p&gt;

&lt;h2 id=&quot;megacli-and-bbu&quot;&gt;MegaCli and BBU&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;MegaCli&lt;/code&gt; is the command line tool for managing LSI RAID controllers on Dell, and a few other servers. We want to first verify if your server is using LSI RAID controllers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check RAID Controller Brand&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;lspci | grep -i raid&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample Output:&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;01:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 1078 (rev 04)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Check Storage Device Detail&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;lshw -class storage&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample Output:&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;  *-storage
       description: RAID bus controller
       product: MegaRAID SAS 1078
       vendor: LSI Logic / Symbios Logic
       physical id: 0
       bus info: pci@0000:01:00.0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: storage pciexpress msi msix pm vpd bus_master cap_list rom
       configuration: driver=megaraid_sas latency=0
       resources: irq:16 memory:fc480000-fc4bffff ioport:ec00(size=256) memory:fc440000-fc47ffff memory:fc300000-fc307fff&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;install-megacli-tool&quot;&gt;Install MegaCli Tool&lt;/h3&gt;

&lt;p&gt;Download the MegaCli package from LSI website. &lt;i class=&quot;fa fa-download&quot;&gt;&lt;/i&gt;  &lt;a href=&quot;http://www.lsi.com/support/Pages/download-results.aspx?keyword=megacli&quot;&gt;Click Here to Find the right package&lt;/a&gt;. I would just get the &lt;code&gt;Latest MegaCli for Linux&lt;/code&gt; package for Linux servers. &lt;/p&gt;

&lt;p&gt;Unzip the downloaded file and install it with package manager that suits you. I am using Ubuntu here as an example:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;unzip MegaCli_Linux.zip
dpkg -i megacli_8.07.08-1_all.deb&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id=&quot;linux-kernel-30&quot;&gt;Linux Kernel &amp;gt;= 3.0&lt;/h4&gt;

&lt;p&gt;If your server is running on &lt;strong&gt;Kernel&lt;/strong&gt; that &lt;strong&gt;is newer or equal&lt;/strong&gt; to &lt;code&gt;version 3.0&lt;/code&gt;, you want to prefix your &lt;code&gt;MegaCli&lt;/code&gt; command like the following as a fix.&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;setarch x86_64 --uname-2.6 MegaCli&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;check-raid-and-battery-backup-unit-health&quot;&gt;Check RAID and Battery Backup Unit Health&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Check Enclosure Info&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -EncInfo -aALL -NoLog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;    Number of enclosures on adapter 0 -- 1

    Enclosure 0:
    Device ID                     : 32
    Number of Slots               : 6
    Number of Power Supplies      : 0
    Number of Fans                : 0
    Number of Temperature Sensors : 0
    Number of Alarms              : 0
    Number of SIM Modules         : 0
    Number of Physical Drives     : 4
    Status                        : Normal
    Position                      : Unavailable
    Connector Name                : Unavailable
    Partner Device Id             : 65535&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Show physical drive information of all connected drives&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -PDList -aALL -NoLog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;Adapter #0

Enclosure Device ID: 32
Slot Number: 0
Device Id: 0
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA
Raw Size: 238.474 GB [0x1dcf32b0 Sectors]
Non Coerced Size: 237.974 GB [0x1dbf32b0 Sectors]
Coerced Size: 237.875 GB [0x1dbc0000 Sectors]
Firmware state: Online
SAS Address(0): 0x4433221107000000
Connected Port Number: 1(path0)
Inquiry Data: S1ATNSAF156143F     Samsung SSD 840 PRO Series              DXM05B0Q
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Foreign State: None
Device Speed: Unknown
Link Speed: Unknown
Media Type: Solid State Device
------------------truncated-----------------------&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Show virtual drive information&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -LDInfo -Lall -aALL -NoLog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;Adapter 0 -- Virtual Drive Information:
Virtual Disk: 0 (Target Id: 0)
Name:
RAID Level: Primary-1, Secondary-0, RAID Level Qualifier-0
Size:475.599 GB
State: Optimal
Stripe Size: 64 KB
Number Of Drives per span:2
Span Depth:2
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Access Policy: Read/Write
Disk Cache Policy: Disk&#39;s Default
Encryption Type: None&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Make sure the &lt;code&gt;Current Cache Policy&lt;/code&gt; is using &lt;code&gt;WriteBack&lt;/code&gt; when battery is healthy. If you see &lt;code&gt;WriteThrough&lt;/code&gt; instead, you need to check into the &lt;a href=&quot;#show-battery-information&quot;&gt;BBU health&lt;/a&gt; and if it is running a &lt;code&gt;relearn&lt;/code&gt; of battery status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References (extracted from Dell OpenManage doc):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Write Policy:&lt;/code&gt; The write policies specify whether the controller sends a write-request completion signal as soon as the data is in the cache or after it has been written to disk.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write-Back. When using write-back caching, the controller sends a write-request completion signal as soon as the data is in the controller cache but has not yet been written to disk. Write-back caching may provide improved performance since subsequent read requests can more quickly retrieve data from the controller cache than they could from the disk. Write-back caching also entails a data security risk, however, since a system failure could prevent the data from being written to disk even though the controller has sent a write-request completion signal. In this case, data may be lost. Other applications may also experience problems when taking actions that assume the data is available on the disk.&lt;/li&gt;
&lt;li&gt;Write-Through. When using write-through caching, the controller sends a write-request completion signal only after the data is written to the disk. Write-through caching provides better data security than write-back caching, since the system assumes the data is available only after it has been safely written to the disk.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Read Policy:&lt;/code&gt; The read policies indicate whether or not the controller should read sequential sectors of the logical drive when seeking data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read-Ahead. When using read-ahead policy, the controller reads sequential sectors of the logical drive when seeking data. Read-ahead policy may improve system performance if the data is actually written to sequential sectors of the logical drive.&lt;/li&gt;
&lt;li&gt;No-Read-Ahead. Selecting no-read-ahead policy indicates that the controller should not use read-ahead policy.&lt;/li&gt;
&lt;li&gt;Adaptive Read-Ahead. When using adaptive read-ahead policy, the controller initiates read-ahead only if the two most recent read requests accessed sequential sectors of the disk. If subsequent read requests access random sectors of the disk, the controller reverts to no-read-ahead policy. The controller continues to evaluate whether read requests are accessing sequential sectors of the disk, and can initiate read-ahead if necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Cache Policy:&lt;/code&gt; The Direct I/O and Cache I/O cache policies apply to reads on a specific virtual disk. These settings do not affect the read-ahead policy. The cache policies are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cache I/O. Specifies that all reads are buffered in cache memory.&lt;/li&gt;
&lt;li&gt;Direct I/O. Specifies that reads are not buffered in cache memory. When using direct I/O, data is transferred to the controller cache and the host system simultaneously during a read request. If a subsequent read request requires data from the same data block, it can be read directly from the controller cache. The direct I/O setting does not override the cache policy settings. Direct I/O is also the default setting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Show battery information&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -AdpBbuCmd -GetBbuStatus -aALL -NoLog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;BBU status for Adapter: 0

BatteryType: BBU
Voltage: 4023 mV
Current: 0 mA
Temperature: 20 C

BBU Firmware Status:

  Charging Status              : None
  Voltage                      : OK
  Temperature                  : OK
  Learn Cycle Requested        : No
  Learn Cycle Active           : No
  Learn Cycle Status           : OK
  Learn Cycle Timeout          : No
  I2c Errors Detected          : No
  Battery Pack Missing         : No
  Battery Replacement required : No
  Remaining Capacity Low       : No
  Periodic Learn Required      : No

Battery state:

GasGuageStatus:
  Fully Discharged        : No
  Fully Charged           : No
  Discharging             : Yes
  Initialized             : Yes
  Remaining Time Alarm    : No
  Remaining Capacity Alarm: No
  Discharge Terminated    : No
  Over Temperature        : No
  Charging Terminated     : No
  Over Charged            : No

Relative State of Charge: 83 %
Charger Status: Complete
Remaining Capacity: 699 mAh
Full Charge Capacity: 840 mAh
isSOHGood: Yes&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The last section of the output would give you a summary of how much of the charge is still remaining in the battery and its capacity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Show battery capacity information&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL -NoLog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;BBU Capacity Info for Adapter: 0

Relative State of Charge: 57 %
Absolute State of charge: 48 %
Remaining Capacity: 921 mAh
Full Charge Capacity: 1619 mAh
Run time to empty: 65535 Min
Average time to empty: 65535 Min
Average Time to full: 65535 Min
Cycle Count: 11
Max Error: 100 %
Remaining Capacity Alarm: 190 mAh
Remaining Time Alarm: 10 Min&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Get event log since last reboot&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -AdpEventLog -GetSinceReboot -f events.log -aALL
cat events.log&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;seqNum: 0x00000594
Time: Mon Jan 13 07:28:33 2014

Code: 0x0000009b
Class: 0
Locale: 0x08
Event Description: Battery relearn pending: Battery is under charge
Event Data:
===========
None


seqNum: 0x00000595
Time: Mon Jan 13 08:34:38 2014

Code: 0x00000093
Class: 0
Locale: 0x08
Event Description: Battery started charging
Event Data:
===========
None
-----------------------truncated-----------------------&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Use the event log to help understand when did BBU status has changed.&lt;/p&gt;

&lt;p&gt;Here is a &lt;a href=&quot;http://genuxation.com/wiki/index.php/MegaCLI&quot;&gt;list&lt;/a&gt; of other MegaCli command for reference.&lt;/p&gt;

&lt;h2 id=&quot;long-term-solution&quot;&gt;Long Term Solution&lt;/h2&gt;

&lt;h3 id=&quot;disable-bbu-auto-learn-mode&quot;&gt;Disable BBU Auto-Learn Mode&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Show battery learn property:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -AdpBbuCmd -GetBbuProperties -aALL&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Sample output:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;BBU Properties for Adapter: 0

Auto Learn Period: 7776000 Sec
Next Learn time: 455912927 Sec
Learn Delay Interval:0 Hours
Auto-Learn Mode: Enabled&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;From the above output, we can tell that the auto battery relearn is enabled. And the scheduled learn time is in &lt;strong&gt;455912927&lt;/strong&gt; seconds in relation to &lt;code&gt;UTC 2000-01-01&lt;/code&gt;. If you want to find out exactly when the scheduled learn time is going to happen, run the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;date -d &quot;UTC 2000-01-01 455912927 secs&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The result would be &lt;code&gt;Thu Jun 12 11:28:47 PDT 2014&lt;/code&gt;. This is just to give you an idea of when the relearn is going to take place, but our purpose here is to disable the automation entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disable Auto-Learn Mode:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;echo &quot;autoLearnMode=1&quot; &amp;gt; tmp.txt
MegaCli -AdpBbuCmd -SetBbuProperties -f tmp.txt -aALL&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can run the show battery learn property command again to verify if you’ve successfully disable the auto learn.&lt;/p&gt;

&lt;h3 id=&quot;forced-scheduled-bbu-relearn-cycle&quot;&gt;Forced Scheduled BBU Relearn Cycle&lt;/h3&gt;

&lt;p&gt;Obviously, one would want to perform this action during less busy hours to avoid heavy disk I/O:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -AdpBbuCmd -BbuLearn -aALL&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Either put the above in a cron job that runs every 90 days or do scheduled manual maintanence every 90 days. 90 days is the default BBU auto relearn cycle, but I guess you can change the interval accordingly toward your needs. &lt;/p&gt;

&lt;h2 id=&quot;urgent-care&quot;&gt;&lt;i class=&quot;fa fa-ambulance&quot;&gt;&lt;/i&gt; Urgent Care&lt;/h2&gt;

&lt;p&gt;Do a quick check on RAID cache policy:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -LDInfo -Lall -aALL -NoLog&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you found the &lt;code&gt;Current cache Policy&lt;/code&gt; to start with &lt;code&gt;WriteThrough&lt;/code&gt; and end with &lt;code&gt;No Write Cache if Bad BBU&lt;/code&gt;. If the &lt;code&gt;WriteThrough&lt;/code&gt; mode is an artifact of BBU in relearn process, but you need it to be in &lt;code&gt;WriteBack&lt;/code&gt; mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You need to first allow write cache if bad BBU, then change the write cache policy to WriteBack:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -LDSetProp CachedBadBBU -Lall -aALL
MegaCli -LDSetProp WB -Lall -aALL&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Restore original setting once the situation is under control:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MegaCli -LDSetProp NoCachedBadBBU -Lall -aALL&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You also want to consider implementing the &lt;i class=&quot;fa fa-link&quot;&gt;&lt;/i&gt; &lt;a href=&quot;#long-term-solution&quot;&gt;long term solution&lt;/a&gt;.&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/7026563920272861837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/7026563920272861837'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2014/05/cpu-load-spiked-with-no-apparent-reason.html' title='CPU Load Spiked with No Apparent Reason - Check RAID Battery'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTeJjdvgig8TI1RDj_q2Z81S5x_L4At3xcqCGdHGR0JkmEotYn5Ip627xLRymnNPyPqBQ-XKnFFE9lBSM_zU9yhjXOUInLyxjmCm0KZMKFgftqs0Ls03lsni-BafMlcRczI5Gd/s72-c/low%252520battery.jpeg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-352926555227739166</id><published>2014-04-14T00:36:00.001-07:00</published><updated>2021-08-14T17:13:55.808-07:00</updated><title type='text'>HTTP Response Code Metrics with Check_MK (OMD)</title><content type='html'>&lt;h2 id=&quot;you-thought-you-are-ready&quot;&gt;You Thought You are Ready&lt;/h2&gt;

&lt;p&gt;Let’s say your company provide web services or API services that rely on REST. I mean, who doesn’t these days? You’ve got &lt;a href=&quot;http://blog.unicsolution.com/2013/11/best-monitoring-solution-omd-nagios.html&quot;&gt;OMD&lt;/a&gt; monitoring basic server health and maybe even web server(apache) health. Time to kickback and have a good night sleep right? If there is anything, the monitoring system shall alert us. &lt;i class=&quot;fa fa-warning&quot;&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-Ke5YwMduXWf4r6Sg3Plu9cHcEa4gko6ra5K6kY9QdCD4T6B91lHuklOqjCxiwANc-tYx-EAWUrXodpSuHB5AxfM7xNNQurJnvBMcpZD_fanKvfg94551wddzZbBZX-HNCkO_/s0/mint-funny-404-erro-page-and-copy.png&quot; alt=&quot;enter image description here&quot; title=&quot;mint-funny-404-erro-page-and-copy.png&quot;&gt;  &lt;/p&gt;

&lt;p&gt;Not so fast!! Monitoring server health is the least you have to do to provide 99.999% of service uptime. What if people are able to reach your web server but keep getting &lt;strong&gt;404 Page Not Found&lt;/strong&gt; or &lt;strong&gt;503 Service Unavailable&lt;/strong&gt;? Or if there is an &lt;strong&gt;DOS&lt;/strong&gt; attack on web service that happen so fast that brought your server to its knee and you have no idea what hit you? &lt;i class=&quot;fa fa-ambulance&quot;&gt;&lt;/i&gt; &lt;/p&gt;

&lt;h2 id=&quot;you-need-metrics-that-screams&quot;&gt;You Need Metrics that Screams&lt;/h2&gt;

&lt;p&gt;One thing I like about &lt;a href=&quot;http://blog.unicsolution.com/2013/11/best-monitoring-solution-omd-nagios.html&quot;&gt;OMD&lt;/a&gt;(Check_MK) is that it is able to collect metrics into graphical charts via PNP4Nagios. Having historical graph that keeps track of all the different HTTP response codes will give you the ability to &lt;i class=&quot;fa fa-flash&quot;&gt;&lt;/i&gt;&lt;strong&gt;QUICKLY&lt;/strong&gt; diagnose the root causes of your web server issues. Inspired by the &lt;a href=&quot;http://logstash.net/docs/1.1.6/tutorials/metrics-from-logs&quot;&gt;Logstash&lt;/a&gt; project, I have wrote a custom script that will generate graphical chart similar to the following:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpYo2PTAa6HYjPyBcGWEvB1aCibRZtUxgT0IHQErDw6Aw9YJ2o9QMkth2tPpRZ8z-zj8W_3IY6fDM2w2A5ZTLzyOJYCCdEdjoaYRw5d__iOZ1Bz_Q7Sp4F5u50WZLOEb82u0wn/s0/frontend-response-codes.png&quot; alt=&quot;enter image description here&quot; title=&quot;frontend-response-codes.png&quot;&gt;  &lt;/p&gt;

&lt;p&gt;Not only will &lt;a href=&quot;http://blog.unicsolution.com/2013/11/best-monitoring-solution-omd-nagios.html&quot;&gt;OMD&lt;/a&gt; collect HTTP response code counts, you can even tweak the custom script I have open sourced on &lt;i class=&quot;fa fa-github&quot;&gt;&lt;/i&gt; Github to add thresholds to the number of each HTTP response and have the monitoring server send alerts to you.&lt;/p&gt;

&lt;h2 id=&quot;how-to-use-the-script&quot;&gt;How to Use the Script&lt;/h2&gt;

&lt;p&gt;You can find &lt;code&gt;check_http_code_counter&lt;/code&gt; script on &lt;i class=&quot;fa fa-github-alt&quot;&gt;&lt;/i&gt; &lt;a href=&quot;https://github.com/bbhenry/check_mk_local&quot;&gt;Github&lt;/a&gt; or download it directly from &lt;i class=&quot;fa fa-download&quot;&gt;&lt;/i&gt; &lt;a href=&quot;https://raw.githubusercontent.com/bbhenry/check_mk_agent/master/local/check_http_code_counter&quot;&gt;HERE&lt;/a&gt;. The script was written in Bash to collect Apache web server HTTP response code from the access log file. Just move the script to &lt;code&gt;/usr/lib/check_mk_agent/local/check_http_code_counter&lt;/code&gt;. Make sure to make the script executable.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;chmod +x check_http_code_counter&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When the script gets executed, you should get output similar to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;0 Check_HTTP_Code_Counter 200=102|206=3|301=0|304=7|400=0|401=0|403=2|404=0|416=0|500=0|501=0|503=0|504=0 Just collecting status code counts&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you have the OMD server start collecting data from it, you should have graph that looks like the following over time.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKwpV1IwFoTEAoAQycU9EAIyGyxEpEo84qAv_K8_yvC8jXPt62vQbmmBAr_bhTUFOf4m19qnUeTlmeglGpVA5aCCk9c7kwr2dr-4ERMQz0aokuBOO0a1UBW5rQVIs8wy1_7mCM/s0/http%252520response%252520code.png&quot; alt=&quot;enter image description here&quot; title=&quot;http response code.png&quot;&gt;  &lt;/p&gt;

&lt;p&gt;You can modify the beginning of the code for the response codes you would like collect or change the location of your Apache access log. Here is the excerpt of the script:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;#!/bin/bash

STATUSCODES=&quot;200 206 301 304 400 401 403 404 416 500 501 503 504&quot;
ACCESSLOG=&quot;/var/log/apache2/access_log&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let me know your thoughts and leave comments below.&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/352926555227739166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/352926555227739166'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2014/04/http-response-code-metrics-with-checkmk.html' title='HTTP Response Code Metrics with Check_MK (OMD)'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-Ke5YwMduXWf4r6Sg3Plu9cHcEa4gko6ra5K6kY9QdCD4T6B91lHuklOqjCxiwANc-tYx-EAWUrXodpSuHB5AxfM7xNNQurJnvBMcpZD_fanKvfg94551wddzZbBZX-HNCkO_/s72-c/mint-funny-404-erro-page-and-copy.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-4933252854935132635</id><published>2014-02-16T03:37:00.001-08:00</published><updated>2021-08-14T17:14:00.289-07:00</updated><title type='text'>How to Setup OMD in 1 Hour</title><content type='html'>&lt;h2 id=&quot;what-is-omd&quot;&gt;What is OMD&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;OMD bundles Nagios together with many important add-ons and can easily be installed on every major Linux distribution. We provide pre-built packages for all enterprise Linux distributions and also for some other, such as Ubuntu.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Want to learn more about what OMD is about and what it can do for you? Check out my other post - &lt;a href=&quot;http://blog.unicsolution.com/2013/11/best-monitoring-solution-omd-nagios.html&quot;&gt;Best Monitoring Solution - OMD (Nagios + Check_MK)&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeHvMCSDAy_vYTrfret6MARcvc8fbSavAhd_5Cq_T_p4lVNYWERKm8KojMDrCSugA3s5ZujfoPsUfrscK8PnErMa1pSvw3z9pkjn1V6dhYqYaQrXB18cpZ5YQSbBk_QEFoKrdX/s0/Screen%252520Shot%2525202014-02-16%252520at%2525204.02.33%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;Check_MK Dashboard.png&quot;&gt;&lt;/p&gt;



&lt;h2 id=&quot;install-omd-server-on-ubuntu-1204&quot;&gt;Install OMD Server on Ubuntu 12.04&lt;/h2&gt;



&lt;h3 id=&quot;setup-omd-repository&quot;&gt;Setup OMD Repository&lt;/h3&gt;

&lt;p&gt;Run the following on the Ubuntu server command line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stable&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gpg --keyserver keys.gnupg.net --recv-keys F8C1CA08A57B9ED7
gpg --armor --export F8C1CA08A57B9ED7 | apt-key add -
echo &#39;deb http://labs.consol.de/repo/stable/ubuntu precise main&#39; &amp;gt;&amp;gt; /etc/apt/sources.list.d/omd-stable.list
apt-get update&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Testing-Release&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gpg --keyserver keys.gnupg.net --recv-keys F8C1CA08A57B9ED7
gpg --armor --export F8C1CA08A57B9ED7 | apt-key add -
echo &#39;deb http://labs.consol.de/repo/testing/ubuntu precise main&#39; &amp;gt;&amp;gt; /etc/apt/sources.list.d/omd-testing.list
apt-get update&lt;/code&gt;&lt;/pre&gt;



&lt;h3 id=&quot;install-omd&quot;&gt;Install OMD&lt;/h3&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;apt-get install omd&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then just follow the instructions on the screen.&lt;/p&gt;



&lt;h2 id=&quot;setup-checkmk-agent-on-the-monitoring-target&quot;&gt;Setup Check_MK Agent on the Monitoring Target&lt;/h2&gt;

&lt;p&gt;You want to install the Check_MK Linux agent on the server you want to monitor - a remote host. The Check_Mk agent version on the repository is not up to date, so we will just download it from the website.&lt;/p&gt;



&lt;h3 id=&quot;install-checkmk-agent&quot;&gt;Install Check_MK Agent&lt;/h3&gt;

&lt;p&gt;&lt;del&gt;Go to the check_mk &lt;a href=&quot;http://mathias-kettner.de/check_mk_download.html&quot;&gt;download page&lt;/a&gt;.&lt;/del&gt; The Check_MK folks have removed the easy to install Ubuntu/CentOS packages since they also need to make a living. You can get those (and other cool features) by subscribing to their supported service. But for those of us who are just trying it out or staying on the open source version. You can find the agent by appending &lt;code&gt;/agents&lt;/code&gt; at the end of your OMD server URL like so:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;http://OMD-URL/SITE-NAME/check_mk/agents/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is what you will see, and &lt;strong&gt;check_mk_agent.linux&lt;/strong&gt; is what you want to use:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF6h2uibjjDglhi0kbb98A1ZFACZFs1g58rMVy4h3MJ7ALlljdhl7q-T_av76wPPG9RbEtlw0d1cLVfhSO3E504N7WQ0hrcmosFLe3D3QkjCw_UVyj_NEhXEEL2uxfjFVNNh0w/s0/2015-08-27%252520at%2525202.29%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;omd agent files.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;You want to save the &lt;strong&gt;check_mk_agent.linux&lt;/strong&gt; file under &lt;strong&gt;/usr/bin/check_mk_agent&lt;/strong&gt; on the target server. Make it executable by running &lt;code&gt;chmod +x check_mk_agent&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;setup-xinetd-connection&quot;&gt;Setup xinetd Connection&lt;/h3&gt;

&lt;p&gt;First, make sure you have &lt;code&gt;xinetd&lt;/code&gt; service installed on your target host. It is used to open a tcp port 6556 for the OMD server to connect to and execute the Check_MK agent this way. If &lt;code&gt;xinetd&lt;/code&gt; is not yet installed, install it now:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;apt-get install xinetd&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;del&gt;By default, the &lt;code&gt;xinetd&lt;/code&gt; connection configuration will be setup by the package itself and reloaded.&lt;/del&gt; Since the package is no longer available,  We want to download the file from the same &lt;strong&gt;/agents&lt;/strong&gt; page called  &lt;strong&gt;xinetd.conf&lt;/strong&gt; and save it under &lt;strong&gt;/etc/xinetd.d/check_mk&lt;/strong&gt;. Secure the connection to allow only the OMD server to connect to the &lt;code&gt;xinetd&lt;/code&gt; port. Edit &lt;code&gt;/etc/xinetd.d/check_mk&lt;/code&gt;, uncomment the following line and add the OMD server’s IP besides 127.0.0.1&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;only_from      = 127.0.0.1 xx.xx.xx.xx&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now reload &lt;code&gt;xinetd&lt;/code&gt; service&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;service xinetd reload&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;patch-for-megacli-check-optional&quot;&gt;Patch for MegaCli Check (Optional)&lt;/h3&gt;

&lt;p&gt;You want to do this if you are running hardware RAID with LSI raid controller on your servers, otherwise you can skip this step. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;MegaCli&lt;/code&gt; command currently doesn’t work with Linux kernel newer than 2.6 without a fix. Create a bash script using the following example but change the path of the original MegaCli command relative to your environment. Save the script under &lt;code&gt;/usr/local/bin/&lt;/code&gt; and name it &lt;code&gt;MegaCli&lt;/code&gt;. Make it executable and it will work.&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;#!/bin/bash

setarch x86_64 --uname-2.6 /usr/local/sbin/MegaCli $@&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;change the path above to locate your MegaCli command accordingly.&lt;/p&gt;



&lt;h3 id=&quot;setup-firewall-optional&quot;&gt;Setup Firewall (Optional)&lt;/h3&gt;

&lt;p&gt;You can also skip this step if you don’t care about security. The following iptable rules will allow only the OMD server to contact this target host through tcp port 6556 and ping test. And this is assuming you have everything else locked down in the iptable rules, or else this is useless.&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;# Monitoring Agent communication
/sbin/iptables -A INPUT -p tcp -s 1.1.1.1 --dport 6556 -j ACCEPT
/sbin/iptables -A INPUT -p icmp -s 1.1.1.1 --icmp-type 8 -j ACCEPT
/sbin/iptables -A OUTPUT -p icmp -d 1.1.1.1 --icmp-type 0 -j ACCEPT&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Change the &lt;code&gt;1.1.1.1&lt;/code&gt; IP address to your OMD server IP address&lt;/p&gt;

&lt;h2 id=&quot;start-monitoring-target-hosts&quot;&gt;Start Monitoring Target Hosts&lt;/h2&gt;

&lt;p&gt;Now that you have successfully installed and enabled the Check_MK agent on a target host. Let’s start monitoring this little pain in the butt without further ado.&lt;/p&gt;

&lt;p&gt;Log in to Check_MK Multisite interface with admin privilege. Under the &lt;strong&gt;WATO - Configuration&lt;/strong&gt; section on the left hand side panel. Click on &lt;strong&gt;Host &amp;amp; Folders&lt;/strong&gt;, then on the right hand side of the page, click the &lt;strong&gt;New Host&lt;/strong&gt; button. You will see the following:  &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvdcmebArZUYOsq_Upcwz-H2XknnjckxKDU99EGNppovQCiH1aEPZC0he79P0Shn0l1kfWP354TMdezlR3nh-j6eP6NFtQQIF2rGeSAe9_a6So0XL9l6a3X4QwDMKu2gvchJ4B/s0/Screen%252520Shot%2525202013-11-04%252520at%2525209.29.47%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;omd add new host&quot;&gt; &lt;br&gt;
Enter the host name or IP address for the &lt;strong&gt;Hostname&lt;/strong&gt; field. If you entered FQDN instead of IP address, make sure it is able to translate by DNS server to an IP address that is pointing to the host you want to monitor. By default, the &lt;code&gt;Agent Type&lt;/code&gt; for monitoring any new host is using &lt;code&gt;Check_MK Agent (Server)&lt;/code&gt;, so all you need to do is just enter &lt;code&gt;Hostname&lt;/code&gt; information and click the &lt;code&gt;Save &amp;amp; go to Services&lt;/code&gt; button at the end.&lt;/p&gt;

&lt;p&gt;Your OMD server is now connecting to the check_mk agent on the target host. In a few seconds, you will see a list of available services to be monitored on the browser. Click on &lt;code&gt;Activate missing&lt;/code&gt; button and you will see on the top of the page it tells you that you’ve made 1 change to the system.  &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyMSzC8pjvVnsK9dn4pFuHvGYq8_yxi6QOpQnhkPENc_fSJ3nBbPrkhYw3cK60oXoebqtwL3jOoTTwNgZh475Lyc2gyAP1JBLrKtlzgmS4MqT2LhOS1iXm2sofEVerMO70ws7X/s0/Screen%252520Shot%2525202013-11-04%252520at%2525209.41.53%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;1 change&quot;&gt; &lt;br&gt;
You want to click on that button that tells you how many changes you have and then followed up by clicking &lt;code&gt;Activate Changes!&lt;/code&gt; button. Now you should see the host and its services are now being monitored by the OMD server. Give it a few more minutes to populate some monitoring data to give you some visuals in the PNP4Nagios graphs.  &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfgVBDWOCrkgiXDpTAMQDPxOH2uIq2Qxa-v5gRIGxLSXeJw8FCMTaeeQJOfZVj3ccurmrZ59dmwfmz5mr4RyfR0TY_h9z5HsXUkG00tHkg9p95T4lEstSFMDflAq8qCNY4QeJT/s0/Check_MK%252520Demo.png&quot; alt=&quot;enter image description here&quot; title=&quot;Check_MK Demo.gif&quot;&gt; &lt;br&gt;
Look how beautiful it is with all the basic health information you need in nice descriptive format and dynamic historical performance graph at your finger tips. This is just the tip of the iceberg of what OMD can do for you. I will be showing you the more advanced stuff from here on. &lt;/p&gt;

&lt;p&gt;Now you know how to setup agents and add target hosts to be monitored, we are going to move on and find out how can we have the OMD system send notifications when things go south on any of your servers or services.&lt;/p&gt;



&lt;h3 id=&quot;add-custom-monitoring-script&quot;&gt;Add Custom Monitoring Script&lt;/h3&gt;

&lt;p&gt;This is a bigger topic which will be covered in future post. In short, there are 4 types of checks that sits on the target host instead of the OMD server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_localchecks.html&quot;&gt;Check_MK local script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://mathias-kettner.de/checkmk_check_catalogue.html&quot;&gt;Check_MK plug-in script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://mathias-kettner.de/checkmk_logfiles.html&quot;&gt;Logwatch plug-in&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_mrpe.html&quot;&gt;Nagios plug-in via MRPE&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;h2 id=&quot;setup-notification&quot;&gt;Setup Notification&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgK3Yqhb3dLJCHmcUPHWVW1ZNAsKE_8_AKVPkHI999ZMXid00d-qvz-9zjjUNTh0Ay3w8_m3LGxQESiiuJb3NM8hqZvnBWIuyZZKdMiSnrhHyiaDb7ZU2FXp68ttVAgkZt4tczy/s0/alarm.jpg&quot; alt=&quot;enter image description here&quot; title=&quot;alarm.jpg&quot;&gt; &lt;br&gt;
Notifications are important if your company is providing services with 99.999% high availability. You want your system engineers to jump on the issues the moment they happen. The goal is to have incidents resolved before customer even notice it. So having a great notification methodology is vital for establishing a &lt;strong&gt;24 on call framework&lt;/strong&gt;. OMD(Check_MK) has just the right tools to help you acheive that.&lt;/p&gt;



&lt;h3 id=&quot;flexible-notification-from-checkmk&quot;&gt;Flexible Notification from Check_MK&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_flexible_notifications.html&quot;&gt;Source Document&lt;/a&gt; &lt;br&gt;
Require Check_MK version &amp;gt; 1.2.1i2&lt;/p&gt;

&lt;p&gt;Each user can have multiple notification methods with separate filters. That way you can for example send always emails, but SMS only for certain services or in certain time periods - without creating multiple contacts per user which is a huge shortcoming in traditional Nagios! &lt;/p&gt;

&lt;p&gt;For each notification the Nagios core will simply pass them to the Check_MK flexible notification feature while providing all necessary information about the alert. Then Check_MK will process those notification however you want via the configuration in the GUI (&lt;a href=&quot;http://mathias-kettner.de/checkmk_wato.html&quot;&gt;WATO&lt;/a&gt;).&lt;/p&gt;



&lt;h3 id=&quot;preparing-notifications-in-general&quot;&gt;Preparing Notifications in General&lt;/h3&gt;

&lt;p&gt;Setting up the notifications requires some care. If you miss one of the following steps then the most probable case is that simply nothing will happen. You need to do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a contact group. WATO users: this is done with the module Contact Groups.&lt;/li&gt;
&lt;li&gt;Important: put some hosts/services into that contact group. WATO: &lt;strong&gt;Host &amp;amp; Service Parameters&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Grouping&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Assignment of hosts/services to contact groups&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Create a user and put him into that contact group. Enable notifications for that user.&lt;/li&gt;
&lt;li&gt;Enter an email address. WATO: Users &amp;amp; Contacts&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure that your monitoring server is correctly setup so that it can send emails. Test this with:&lt;/p&gt;

&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;root@linux# echo &quot;Mailbody&quot; | mail -s &quot;Testsubject&quot; test@example.com&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Restart your core with &lt;code&gt;cmk -R&lt;/code&gt; in Linux command line or activating changes in WATO.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;testing-and-debugging&quot;&gt;Testing and Debugging&lt;/h3&gt;

&lt;p&gt;When dealing with notifications it’s important to know how to test and debug your setup. A very easy way to send test-notifications is to pick a random service that is contained in the upper contact group, open the Commands dialog and select Custom Notification:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMbakcH205ab74qTuAjpvLc45m8S7P92ZCqlORpU8Sme_zm8DfCtDcg9vgT4vUbZxNL5Xn7Bmy-Px-R6OX1waFmLSd7K0nk-wUWIHcS3GDzTPLIZqvWiNbL6UNOj4GFAXFdLWa/s0/2015-08-27%252520at%2525202.44%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;omd custom notification.png&quot;&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check nagios log &lt;br&gt;
&lt;code&gt;~/var/log/nagios.log&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Check Check_MK notification log &lt;br&gt;
&lt;code&gt;~/var/check_mk/notify/notify.log&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;WATO users find this setting in &lt;strong&gt;Global Settings&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Notifications&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Debug notifications&lt;/strong&gt;. The resulting log file is in the directory notify below Check_MK’s var directory. OMD users find the file in &lt;code&gt;~/var/check_mk/notify/notify.log&lt;/code&gt;. Isn’t it great to have fixed paths in OMD?&lt;/p&gt;

&lt;h3 id=&quot;send-notification-through-email-to-sms-gateway&quot;&gt;Send Notification through Email to SMS Gateway&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNL4gBn1980R5tSR_QISLehfueQZpyopNZ8hw8ScNmU8q2dX6IMKK2Dg4GKlwpDm_rtslO4E_V5SjXwBXr0nE7Gk2pwfG3d3d3HK61H2-D8CHOdEu9tqJ6dM8msgHhPSSRD_nJ/s0/free%252520sms.png&quot; alt=&quot;enter image description here&quot; title=&quot;free sms.png&quot;&gt; &lt;br&gt;
Some countries’ mobile carriers support sending Email to their SMS gateway which will convert that Email message to a SMS(text) message to the destination mobile phone number. For example if you have a 5555555555 T-Mobile phone number in the USA, you can send SMS message to that number with Email using the following Email address:&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;5555555555@tmomail.net&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Having notifications being sent to mobile devices are extremely helpful if you are looking to setup some kind of 24/7 on call monitoring. I wrote a custom notification script that will let you send notification through Email to SMS gateway with the bare minimum information you need from an alert.&lt;/p&gt;

&lt;p&gt;Download the most updated script &lt;code&gt;email-sms-custom.sh&lt;/code&gt; from &lt;i class=&quot;fa fa-download&quot;&gt;&lt;/i&gt; &lt;a href=&quot;https://github.com/bbhenry/check_mk_server&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Save my script into this directory on your OMD server and make it executable: &lt;br&gt;
&lt;code&gt;/omd/site/YOURSITE/local/share/check_mk/notifications/email-sms-custom.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Check_MK will consider every executable file in this directory as a notification script. You can use any programming language you want. If you use a scripting language (Shell, Perl, Python, etc.) then you can use a comment in the second line for giving the script a &lt;strong&gt;name&lt;/strong&gt;. This &lt;strong&gt;name&lt;/strong&gt; will appear in the UI for you to choose in a drop down list of different notification methods. I have named the script on the 2nd line to be &lt;strong&gt;SMS via Email to SMS Gateway&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is a &lt;strong&gt;&lt;a href=&quot;http://www.emailtextmessages.com/&quot;&gt;list&lt;/a&gt; of all the Email to SMS Gateway provider&lt;/strong&gt; in the world. Use them and test them at your own risk. All SMS message fees still applies. &lt;/p&gt;

&lt;h2 id=&quot;omd-maintenance&quot;&gt;OMD Maintenance&lt;/h2&gt;



&lt;h3 id=&quot;omd-upgrade&quot;&gt;OMD Upgrade&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mail-archive.com/checkmk-en@lists.mathias-kettner.de/msg07525.html&quot;&gt;http://www.mail-archive.com/checkmk-en@lists.mathias-kettner.de/msg07525.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://deranfangvomende.wordpress.com/2011/06/07/omd-update-0-42-to-0-49/&quot;&gt;http://deranfangvomende.wordpress.com/2011/06/07/omd-update-0-42-to-0-49/&lt;/a&gt; &lt;br&gt;
- OMD with lastest Check_MK version &lt;br&gt;
- &lt;a href=&quot;http://mathias-kettner.com/check_mk_demo_version.php?HTML=yes&amp;amp;LANG=en&quot;&gt;Download Demo Version&lt;/a&gt;&lt;/p&gt;



&lt;h3 id=&quot;omd-backupmigrate&quot;&gt;OMD Backup/Migrate&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install the same version of OMD package on your new hardware&lt;/li&gt;
&lt;li&gt;Stop omd on the source server&lt;/li&gt;
&lt;li&gt;Copy /omd/sites/ to your new target server.&lt;/li&gt;
&lt;li&gt;Mind the permission! Create the same “Site” user on the target server&lt;/li&gt;
&lt;li&gt;Start OMD on your target server&lt;/li&gt;
&lt;/ol&gt;



&lt;h3 id=&quot;high-resolution-graphing-for-pnp4nagios-for-one-year&quot;&gt;High Resolution Graphing for PNP4Nagios for One Year&lt;/h3&gt;

&lt;p&gt;When you have longer period of graphing data on PNP4Nagios, zooming into year graph down to the day seems to have averaged out greatly. You can’t rely on the graph to dig up any historic event metrics this way. &lt;/p&gt;

&lt;p&gt;To address the issue, edit &lt;code&gt;rra.cfg&lt;/code&gt; in your pnp4nagios config. Documentation is on rrdtool and pnp4nagios websites. &lt;br&gt;
&lt;a href=&quot;http://serverfault.com/questions/534186/how-to-change-the-amount-of-data-stored-in-pnp4nagiosomd&quot;&gt;http://serverfault.com/questions/534186/how-to-change-the-amount-of-data-stored-in-pnp4nagiosomd&lt;/a&gt; &lt;br&gt;
&lt;a href=&quot;http://apfelboymchen.net/gnu/rrd/create/&quot;&gt;http://apfelboymchen.net/gnu/rrd/create/&lt;/a&gt;&lt;/p&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/4933252854935132635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/4933252854935132635'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2014/02/how-to-setup-omd-in-1-hour.html' title='How to Setup OMD in 1 Hour'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeHvMCSDAy_vYTrfret6MARcvc8fbSavAhd_5Cq_T_p4lVNYWERKm8KojMDrCSugA3s5ZujfoPsUfrscK8PnErMa1pSvw3z9pkjn1V6dhYqYaQrXB18cpZ5YQSbBk_QEFoKrdX/s72-c/Screen%252520Shot%2525202014-02-16%252520at%2525204.02.33%252520AM.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-93486632296286477</id><published>2013-11-28T04:29:00.001-08:00</published><updated>2021-08-14T17:14:03.669-07:00</updated><title type='text'>Best Monitoring Solution 2015 - OMD (Open Monitoring Distribution)</title><content type='html'>&lt;h2 id=&quot;why-is-omd-the-best-open-source-monitoring-solution-over-zabbix-zenoss-or-sensu&quot;&gt;Why is OMD the Best Open Source Monitoring Solution  over Zabbix, Zenoss or Sensu&lt;/h2&gt;

&lt;p&gt;I spend about 3 weeks vetting through 20+ open source monitoring solutions and at the end of the process, the choices had boiled down to few major ones - &lt;a href=&quot;http://omdistro.org/&quot;&gt;OMD&lt;/a&gt; (best combination of open source plug-ins put together for Nagios), Zabbix, Sensu, and Zenoss.&lt;/p&gt;

&lt;p&gt;The main components of &lt;a href=&quot;http://omdistro.org/&quot;&gt;OMD&lt;/a&gt; are &lt;a href=&quot;http://mathias-kettner.com/checkmk_monitoring_system.html&quot;&gt;Check_MK&lt;/a&gt;, &lt;a href=&quot;http://omdistro.org/doc/packages/pnp4nagios&quot;&gt;PNP4Nagios&lt;/a&gt;, &lt;a href=&quot;http://www.nagvis.org/screenshots&quot;&gt;Nagvis&lt;/a&gt;, and of course &lt;a href=&quot;http://www.nagios.org/&quot;&gt;Nagios&lt;/a&gt;. Among these projects, Check_MK is the core of OMD that makes Nagios easy to configure, easy to scale, and mashed together all the other popular Nagios plug-ins into one unified user interface. Thus the following comparisons are done using Check_MK as the keyword, but I will also cover how other plug-ins makes OMD project stand out from the competitions.&lt;/p&gt;

&lt;p&gt;Update: 2015.08.29 &lt;br&gt;
I have the opportunity to build a new monitoring platform from scratch again, so I wanted to make sure if there is any better solution than OMD. I have gone though a series of new comers and the Monitorama conferences (2014 ~ 2015). OMD still is the only one that ships with everything you need to do the monitoring job right. Some of the new tools focus on API and scalability (which OMD has both) but doesn’t really give you a easy to use or the lack of GUI to manage your infrastructure with less command line or coding capable people. &lt;/p&gt;



&lt;h3 id=&quot;trend&quot;&gt;Trend&lt;/h3&gt;



&lt;h4 id=&quot;checkmk-vs-zabbix-vs-zenoss-core-trend&quot;&gt;Check_MK vs Zabbix vs Zenoss Core Trend&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGUC3pObwZ0_qln3OTJE9zYv5hKoMmAHix3Gu-e9fTKGU-ZTjR1COsJcWHNmjMoDNCEyDluDo5k8NlwOtNHDGqLMQTgwRUbZWoKaSN2tcA8SPE56mX_CF6PxFbaVwG4Hr_X7YB/s0/Screen%252520Shot%2525202013-11-28%252520at%25252011.53.45%252520PM.png&quot; alt=&quot;enter image description here&quot; title=&quot;Monitoring Tools Trend&quot;&gt; &lt;br&gt;
A quick &lt;a href=&quot;https://www.google.com/trends/explore?q=check_Mk#q=Check_MK,%20Zabbix,%20Zenoss%20Core,%20Nagios&amp;amp;date=1/2013%2012m&amp;amp;cmpt=q&quot;&gt;Google Trend search&lt;/a&gt; will tell you that Check_MK is up and rising. Together with the Nagios’s community size, you can certainly find custom monitoring plug-ins created by community members and save yourself time from reinventing the wheel.&lt;/p&gt;



&lt;h3 id=&quot;project-health&quot;&gt;Project Health&lt;/h3&gt;

&lt;p&gt;Before you pick any open source tool for enterprise projects, you want to make sure that their code is not stale and the community is vibrant for the years to come. Active community and frequent code updates ensure your questions get answered and fast bug fixes. Free service from &lt;a href=&quot;http://www.ohloh.net/&quot;&gt;Ohloh&lt;/a&gt; will give you an overview of those aspects on open source projects. The following comparison charts are created from Ohloh.&lt;/p&gt;



&lt;h4 id=&quot;number-of-code-commits-made-by-each-project&quot;&gt;Number of Code Commits Made by Each Project&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwET8gT1mpiYbslR68f4PD_b6Y9FPMAK978m3noFk0hDoee3G7QFFPU_Glf_luf8qIrEfeEV4ybMrr7H0W92Cr4WTL_NR77NNc3GKEVXcOKlK-ms06LMIwU9r2OGKponezEBHY/s0/Screen%252520Shot%2525202013-11-29%252520at%2525201.00.59%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;monitoring tools trend&quot;&gt; &lt;br&gt;
Check_MK is a clear winner in this chart. It tells you that Check_MK is constantly making more improvement than the other 2 projects.&lt;/p&gt;



&lt;h4 id=&quot;number-of-contributor-of-each-project&quot;&gt;Number of Contributor of Each Project&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLAIc20PxbKFemnZblKDa33EnBbLlCwvmxkiZOlgknIr4yexdTfq6PcNZzJqRbeUeK7TEL12-3Y1c8ZRe7Bod-0mJZyWakSO2nY-DTTlLXrdMEWGzyV9O_Cq3hNQTowk75xdqZ/s0/Screen%252520Shot%2525202013-11-29%252520at%2525201.01.14%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;Monitoring Number of Contributor&quot;&gt; &lt;br&gt;
In this chart, Check_MK’s contributor is increasing and will soon surpass Zabbix. And don’t forget it is standing on giant’s shoulder, the largest monitoring community - Nagios.&lt;/p&gt;



&lt;h3 id=&quot;user-reviews&quot;&gt;User Reviews&lt;/h3&gt;

&lt;p&gt;Don’t just listen to me. Here is one of the blog post that talks about why moving away from Zabbix to Check_MK.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href=&quot;http://paulgraydon.co.uk/blog/2012/09/20/moving-from-zabbix-to-check-mk/&quot;&gt;Moving From Zabbix to Check_MK&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h2 id=&quot;architecture-design-advantage&quot;&gt;Architecture Design Advantage&lt;/h2&gt;



&lt;h3 id=&quot;omd&quot;&gt;&lt;a href=&quot;http://omdistro.org/&quot;&gt;OMD&lt;/a&gt;&lt;/h3&gt;

&lt;dl&gt;
&lt;dt&gt;What is &lt;a href=&quot;http://omdistro.org/&quot;&gt;OMD&lt;/a&gt;:&lt;/dt&gt;
&lt;dd&gt;OMD is a combination of best practices on how Nagios should be setup and integrated. It has incorporated all of the most popular 3rd party Nagios plug-ins in single easy to maintain, easy to install, and easy to upgrade package. Once you have your Linux server running, installing and have your OMD monitoring suite running only takes about 10 minutes with one command.&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;Administrators can really save time on not having to compile Nagios, or other plug-ins, trying to integrate and mess with configurations between plug-ins and Nagios. It really is a no-brainer to setup and start with.&lt;/p&gt;

&lt;dl&gt;
&lt;dt&gt;Why use &lt;a href=&quot;http://omdistro.org/&quot;&gt;OMD&lt;/a&gt; instead of other flavors of Nagios combos, e.g. ?&lt;/dt&gt;
&lt;dd&gt;Founded July, 2010 by a group of well known Nagios community members and Nagios addon developers&lt;/dd&gt;

&lt;dd&gt;e.g. &lt;a href=&quot;http://www.nagvis.org/screenshots&quot;&gt;NagVis&lt;/a&gt;, &lt;a href=&quot;http://mathias-kettner.de/checkmk.html&quot;&gt;Check_MK&lt;/a&gt;, &lt;a href=&quot;http://docs.pnp4nagios.org/pnp-0.6/start&quot;&gt;PNP4Nagios&lt;/a&gt;, and others&lt;/dd&gt;
&lt;/dl&gt;



&lt;h3 id=&quot;checkmk&quot;&gt;Check_MK&lt;/h3&gt;



&lt;h4 id=&quot;what-is-checkmk&quot;&gt;What is Check_MK&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;Check_MK is an extension to the Nagios monitoring system that allows creating rule-based configuration using Python and offloading work from the Nagios core to make it scale better, allowing more systems to be monitored from a single Nagios server.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5Q1N9NJkC6BFRGGj79MJEUWxzLg7jFDeCuLJE-4GITbQPrKAeag-tp7gwudEBOtJzTG7wE1SUjDVgJNM3aIj4X-wv1Cyo9r4nxVSwp-9F7ZNWl8Fic8KyyV7JiWtCKHO2-oyC/s0/bottleneck.png&quot; alt=&quot;enter image description here&quot; title=&quot;bottleneck&quot;&gt; &lt;br&gt;
There are 2 significant modules that Check_MK uses to &lt;strong&gt;improve Nagios performance&lt;/strong&gt;. One is called &lt;strong&gt;Livestatus&lt;/strong&gt; and the other is called &lt;strong&gt;Livecheck&lt;/strong&gt;. &lt;/p&gt;



&lt;h4 id=&quot;livestatus&quot;&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_livestatus.html&quot;&gt;Livestatus&lt;/a&gt;&lt;/h4&gt;



&lt;h5 id=&quot;before-livestatus&quot;&gt;Before Livestatus ☹&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Monitoring results are stores to a single file &lt;code&gt;status.dat&lt;/code&gt;. It becomes a bottleneck on CPU and IO for larger installation.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;status&lt;/code&gt; file status is &lt;strong&gt;not realtime&lt;/strong&gt;, default is to update every 10 seconds.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://exchange.nagios.org/directory/Addons/Database-Backends/NDOUtils/details&quot;&gt;NDOUtils&lt;/a&gt; utilize databases for monitoring results (MySQL or PostgreSQL), but still have some severe shortcomings.&lt;/li&gt;
&lt;li&gt;NDOUtils has &lt;strong&gt;complex setup&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;NDOUtils &lt;strong&gt;needs a databases&lt;/strong&gt; to be administered, a &lt;strong&gt;rapidly growing&lt;/strong&gt; one.&lt;/li&gt;
&lt;li&gt;NDOUtils eats up &lt;strong&gt;significant portion&lt;/strong&gt; of your &lt;strong&gt;CPU resources&lt;/strong&gt; just to keep the database up to date.&lt;/li&gt;
&lt;li&gt;Some similar projects that still uses NDOUtils: &lt;br&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.centreon.com/&quot;&gt;Centreon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.opsview.com/&quot;&gt;Opsview&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Regular housekeeping of the database can &lt;strong&gt;hang your Nagios&lt;/strong&gt; for minutes or even an hour once a day.&lt;/li&gt;
&lt;/ul&gt;



&lt;h5 id=&quot;after-livestatus&quot;&gt;After Livestatus ☺&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Livestatus also uses Nagios Event Broker API like NDO, but it does not actively write out data. Instead, it opens a socket by which data can be &lt;strong&gt;retrieved on demand&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Livestatus imposes &lt;strong&gt;no measurable burden on CPU&lt;/strong&gt; at all.&lt;/li&gt;
&lt;li&gt;Livestatus produces &lt;strong&gt;zero disk IO&lt;/strong&gt; when querying status data.&lt;/li&gt;
&lt;li&gt;No configuration is needed. No database is needed. No administration is necessary.&lt;/li&gt;
&lt;li&gt;Livestatus &lt;strong&gt;scales well&lt;/strong&gt; to large installation even beyond 50,000 services.&lt;/li&gt;
&lt;li&gt;Livestatus give you access to Nagios-specific data that is not available to any other methods.&lt;/li&gt;
&lt;/ul&gt;



&lt;h4 id=&quot;livecheck&quot;&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_livecheck.html&quot;&gt;Livecheck&lt;/a&gt;&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;Before Nagios 4.0, Even a perfectly tuned system rarely manages to execute more then a few thousand checks per minute.&lt;/p&gt;
  
  &lt;p&gt;What make things worse: while your system is getting larger, the maximum check rate is even getting worse. The more hosts and services your system manages, the less checks per second it will be able to perform. Why?&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h5 id=&quot;existing-problems-of-nagios-before-nagios-40&quot;&gt;Existing Problems of Nagios (before Nagios 4.0) ☹&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Each new check creates a new fork&lt;/li&gt;
&lt;li&gt;The new process prepare everything needed to execute the check plug-in, then &lt;strong&gt;fork the second time&lt;/strong&gt; when ready&lt;/li&gt;
&lt;li&gt;Forking is costly even for highly optimized Linux kernel&lt;/li&gt;
&lt;li&gt;The forking of Nagios core (before v.4.0) &lt;strong&gt;does not scale on multiple CPUs (single thread process)&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;you can well run into a situation where your powerful 16-CPU server is limited to 100 Checks per second while most of its CPU cores are idle most of the time.&lt;/li&gt;
&lt;/ul&gt;



&lt;h5 id=&quot;how-does-livecheck-solve-those-bottlenecks&quot;&gt;How does Livecheck solve those bottlenecks ☺&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;It uses a number of helper processes. The core communicate with each helper through a Unix socket (that does not appear in file system).&lt;/li&gt;
&lt;li&gt;Only a small helper program is forked instead of the complete Nagios monitoring core.&lt;/li&gt;
&lt;li&gt;The helper forks distribute over all available CPUs instead of single CPU.&lt;/li&gt;
&lt;li&gt;The total process VM size of Livecheck is about &lt;strong&gt;100KB only&lt;/strong&gt;!&lt;/li&gt;
&lt;li&gt;Inline implementation of check_icmp (PING tests). To give you an idea of how much improvement this has done, here is a benchmark example using &lt;strong&gt;dual core 2800 MHz CPU&lt;/strong&gt;: &lt;br&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Before&lt;/strong&gt; inline check_icmp: &lt;strong&gt;300 ICMP checks per second&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;After&lt;/strong&gt; inline check_icmp: &lt;strong&gt;2600 ICMP checks per second&lt;/strong&gt;. The checks generated an ICMP traffic of 45Mb/s.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h4 id=&quot;nagios-monitoring-core-working-with-the-best-plug-ins-checkmk-nagvis-pnp4nagios-and-etc&quot;&gt;Nagios Monitoring Core working with the best plug-ins (Check_MK, NagVis, PNP4Nagios and etc)&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;http://mathias-kettner.com/bilder/OMD.png&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;



&lt;h3 id=&quot;multisite-an-advance-web-interface-for-nagios&quot;&gt;Multisite - An Advance Web Interface for Nagios&lt;/h3&gt;

&lt;p&gt;Multisite is part of the Check_MK project as a better web UI alternative for Nagios.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A new and innovative GUI for viewing Nagios status information and controlling your monitoring system. It is based on MK Livestatus and aims at replacing the Nagios web GUI (also known as “the CGIs”). Multisite &lt;strong&gt;supports distributed monitoring in a very efficient way&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h4 id=&quot;zero-configuration-files-with-wato&quot;&gt;Zero Configuration Files with WATO&lt;/h4&gt;

&lt;p&gt;This is one of the most brilliant solutions from Check_MK project to tackle the notorious Nagios configuration disaster. Although Nagios is a flexible and powerful monitoring system, having to mess with its multi-level and confusing configuration files scares many people away. Now, there are many web interface plug-ins that try to take a stab at the issue, but &lt;strong&gt;WATO&lt;/strong&gt; is by far the best that simplify the complexity of Nagios configuration while staying very flexible and more flexible by sitting on top of Check_MK.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;WATO is a web based administration tool for Check_MK. It allows you to manage your hosts and services to be monitored and perfectly supports Check_MK’s mechanism of inventory to &lt;strong&gt;autodetect services to be checked on a host&lt;/strong&gt;. WATO allows to move a substantial part of the daily workload from the monitoring administrator to his colleagues.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h4 id=&quot;monitoring-agent-for-both-linux-and-ms-windows&quot;&gt;Monitoring Agent for both Linux and MS Windows&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6B9AcNE_URWBJqhCnHz59kF137d9JAOTWRvW31vsMrtaNU_ifhHwl2nAiaK1TCjaS3bZ29vCFyvhZl5WovhzBe-VjQ4QM3XKyBDsfdpk_hy3J3f_vsa4gfcjHzU-sAl_UR2e/s0/windows-linux.jpg&quot; alt=&quot;enter image description here&quot; title=&quot;windows-linux.jpg&quot;&gt;&lt;/p&gt;



&lt;h4 id=&quot;responsive-ui-for-mobile-client&quot;&gt;Responsive UI for Mobile Client&lt;/h4&gt;



&lt;h4 id=&quot;powerful-search-function&quot;&gt;Powerful Search Function&lt;/h4&gt;



&lt;h4 id=&quot;visual-meters-with-perf-o-meter&quot;&gt;Visual Meters with Perf-O-Meter&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7CBMw1BMTyYgxGkZzVLLS83RkPoWYcgxnWz6_nJnozTFFbjNIJdyAQHrIZkozoY6Eirog_Z7yM3Fu35AEQ6WbpHq6Fd9LGiqnnmHNH9QeRF_rl7IN1xT_LK8DtcOm_v2WjHCH/s0/Screen%252520Shot%2525202014-01-06%252520at%2525201.18.38%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;perf-o-meter.png&quot;&gt;&lt;/p&gt;



&lt;h2 id=&quot;noc-with-dashboards-thanks-to-pnp4nagios-nagvis&quot;&gt;NOC with Dashboards (Thanks to PNP4Nagios &amp;amp; Nagvis)&lt;/h2&gt;



&lt;h3 id=&quot;pnp4nagios&quot;&gt;PNP4Nagios&lt;/h3&gt;



&lt;h3 id=&quot;nagvis&quot;&gt;Nagvis&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;NagVis is a visualization addon for the well known network managment system Nagios. NagVis can be used to visualize Nagios Data, e.g. to display IT processes like a mail system or a network infrastructure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwAv-4ppxjrWQ4ij-jqxSDxwZRAFsvf3BpMkDDFRp3CTdQyUYWZsFp9hgNcHHgiLeLgS_Nx_x7xijUeiG4soNak8zJFAcbqM7oXN3kvKgmQitiS6VHAzJmI9_nezO6-LBJlDPK/s0/Nagvis%252520demo.png&quot; alt=&quot;Sample Navigation in Nagvis&quot; title=&quot;Nagvis demo.gif&quot;&gt;&lt;/p&gt;



&lt;h3 id=&quot;checkmk-omd-api-for-automated-provisioning&quot;&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_multisite_automation.html&quot;&gt;Check_MK (OMD) API&lt;/a&gt; for Automated Provisioning&lt;/h3&gt;

&lt;p&gt;Automation is build into Multisite (Check_MK UI). You can make web service request against the API to automate adding new host, enabling new service checks, or embed any of the host/service check web pages into any other websites. &lt;/p&gt;

&lt;p&gt;This feature makes it very easy to integrate with configuration mangement tools like &lt;a href=&quot;http://puppetlabs.com/&quot;&gt;Puppet&lt;/a&gt; or &lt;a href=&quot;http://www.ansible.com/&quot;&gt;Ansible&lt;/a&gt; for automatically adding new servers(hosts) and services to the monitoring system.&lt;/p&gt;

&lt;h3 id=&quot;247-noc-with-flexible-notification&quot;&gt;24/7 NOC with Flexible Notification&lt;/h3&gt;

&lt;p&gt;With Check_MK abstracting the original Nagio’s notification scheme, it has become possible to send notifications of &lt;strong&gt;any hosts or services&lt;/strong&gt; to &lt;strong&gt;any number of people&lt;/strong&gt; at &lt;strong&gt;any time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can even create custom script to send the notification in some creative ways like having the notification be ☎called via a VoIP server to your cell phone and read you the alert message or have the alert be sent to your ✐instant messenger.&lt;/p&gt;

&lt;p&gt;If you are currently using PagerDuty as your notification service provider, you can check out my other post on &lt;i class=&quot;fa fa-link&quot;&gt;&lt;/i&gt; &lt;a href=&quot;http://blog.unicsolution.com/2015/09/omd-checkmk-alert-notification.html&quot;&gt;OMD (Check_MK) Alert Notification Integration with PagerDuty Done Right&lt;/a&gt;.  &lt;/p&gt;



&lt;h3 id=&quot;custom-icons&quot;&gt;Custom Icons&lt;/h3&gt;

&lt;p&gt;This is really one of the hidden gem &lt;i class=&quot;fa fa-dollar&quot;&gt;&lt;/i&gt; of Check_MK (OMD) feature that will dramatically reduce the MTTR (Mean Time to Repair). I will be writing another post about the things I have implemented to make the NOC team more efficient at troubleshooting and putting out fires. &lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_devel_multisite_icons.html&quot;&gt;http://mathias-kettner.de/checkmk_devel_multisite_icons.html&lt;/a&gt;&lt;/p&gt;



&lt;h2 id=&quot;management-and-maintenance&quot;&gt;Management and Maintenance&lt;/h2&gt;



&lt;h3 id=&quot;scaling-with-distributed-monitoring&quot;&gt;Scaling with Distributed Monitoring&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;Distributed WATO allows you to manage several monitoring sites through a logically centralized WATO.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;1200 Check_MK installations &lt;br&gt;
&lt;ul&gt;&lt;li&gt;Centralized status of all &lt;strong&gt;1200&lt;/strong&gt; stores &lt;strong&gt;per minute&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;&lt;a href=&quot;http://www.nagvis.org/screenshots&quot;&gt;NagVis&lt;/a&gt;&lt;/strong&gt; to show all 1200 stores’ status on the map using the Geomap function&lt;/li&gt;
&lt;li&gt;All stores’ overall status is aggregated through the use of the &lt;strong&gt;&lt;a href=&quot;http://mathias-kettner.com/checkmk_bi.html&quot;&gt;Business Intelligence&lt;/a&gt;&lt;/strong&gt; function&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://mathias-kettner.com/bilder/check_mk-edeka-map-big.png&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;



&lt;h3 id=&quot;backup-of-changes&quot;&gt;Backup of Changes&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Automatic Check_MK configuration backup on every change you make&lt;/li&gt;
&lt;li&gt;Easy restoration with the &lt;strong&gt;Thunder&lt;/strong&gt; icon &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBSXeC3W_uGzRbDoJgi6MPpiTqLzB4y8ztOvgmxsrhghOthXpWYCpD3gfOkw33S8wFAbg47HHbiU67z6rXlMr1hmaRPf2iWuhfOaFY5d3a8ZlNBUCgbi4VgSA5gUF_SqiJ8Qhg/s0/Screen%252520Shot%2525202014-01-06%252520at%2525201.11.20%252520AM.png&quot; alt=&quot;enter image description here&quot; title=&quot;backup and restore.png&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h3 id=&quot;upgrade-omd&quot;&gt;Upgrade OMD&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;OMD upgrade &lt;i class=&quot;fa fa-download&quot;&gt;&lt;/i&gt; &lt;a href=&quot;http://mathias-kettner.com/check_mk_demo_version.php?HTML=yes&amp;amp;LANG=en&quot;&gt;DEMO Version&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;OMD copy a site&lt;/li&gt;
&lt;/ul&gt;



&lt;h3 id=&quot;business-intelligence&quot;&gt;Business Intelligence&lt;/h3&gt;

&lt;p&gt;Available from version &lt;strong&gt;1.2.3&lt;/strong&gt;&lt;/p&gt;



&lt;h3 id=&quot;predictive-monitoring&quot;&gt;&lt;a href=&quot;http://mathias-kettner.de/checkmk_predictive.html&quot;&gt;Predictive Monitoring&lt;/a&gt;&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Smart threshold that detects anomaly from daily operation&lt;/li&gt;
&lt;li&gt;Set warning level based on prediction &lt;br&gt;
&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbUZK5SxIl5bRc2t3HMlkSMKxaVLYSsE3AixYW4nI92Zd-AHZnR8WQuicl4OTf8aoluDWubTbEeCdl5dP6Da9AgUEeAdwR3y5xuwEUqmhBykp3n5I8g07SpZGYorfQZRw4uP0z/s0/prediction-graph.png&quot; alt=&quot;enter image description here&quot; title=&quot;prediction-graph.png&quot;&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Available from check_mk version &lt;strong&gt;1.2.3&lt;/strong&gt;&lt;/p&gt;



&lt;h3 id=&quot;monitor-cronjobs&quot;&gt;Monitor Cronjobs&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;5 0 * * * root /usr/local/bin/backup &amp;gt;/dev/null&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;After&lt;/strong&gt;&lt;/p&gt;



&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;5 0 * * * root mk-job nightly-backup /usr/local/bin/backup &amp;gt;/dev/null&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Available from check_mk version &lt;strong&gt;1.2.3&lt;/strong&gt;&lt;/p&gt;



&lt;h2 id=&quot;dive-in-to-the-omd-world&quot;&gt;Dive in to the OMD World&lt;/h2&gt;

&lt;p&gt;I will be sharing how I install OMD, optimized web interface (Multisite), utilized passive checks, implemented 24/7 on call plan, and integrated with automated business processes. I will add link here once they become available.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://blog.unicsolution.com/2014/02/how-to-setup-omd-in-1-hour.html&quot;&gt;How to Setup OMD in 1 Hour&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;h2 id=&quot;what-monitoring-tool-do-you-use-and-how-do-you-think-its-doing-the-job-for-you-leave-comments-below&quot;&gt;What monitoring tool do you use and how do you think it’s doing the job for you? (leave comments below &lt;i class=&quot;fa fa-arrow-down&quot;&gt;&lt;/i&gt;)&lt;/h2&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/93486632296286477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/93486632296286477'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2013/11/best-monitoring-solution-omd-nagios.html' title='Best Monitoring Solution 2015 - OMD (Open Monitoring Distribution)'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGUC3pObwZ0_qln3OTJE9zYv5hKoMmAHix3Gu-e9fTKGU-ZTjR1COsJcWHNmjMoDNCEyDluDo5k8NlwOtNHDGqLMQTgwRUbZWoKaSN2tcA8SPE56mX_CF6PxFbaVwG4Hr_X7YB/s72-c/Screen%252520Shot%2525202013-11-28%252520at%25252011.53.45%252520PM.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-13480204.post-7968136948508772859</id><published>2013-08-17T20:22:00.001-07:00</published><updated>2021-08-14T17:14:11.853-07:00</updated><title type='text'>Automated Web Testing with Perl and WebDriver</title><content type='html'>&lt;p&gt;What is Automated Web Testing you may ask, and how is it done? If you search this topic on Google, you may be well flooded by confusing and overwhelming information from different websites and blog post. But lucky for you, I have done the homework and consolidated those into an easy to understand presentation for you:&lt;/p&gt;

&lt;div class=&quot;embed-div&quot;&gt;
&lt;iframe src=&quot;//www.slideshare.net/slideshow/embed_code/31229338&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC;border-width:1px 1px 0;margin-bottom:5px&quot; allowfullscreen=&quot;&quot; webkitallowfullscreen=&quot;&quot; mozallowfullscreen=&quot;&quot;&gt; &lt;/iframe&gt;&lt;/div&gt;&lt;div class=&quot;se-section-delimiter&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;selenium&quot;&gt;Selenium&lt;/h2&gt;

&lt;p&gt;Selenium automates browsers. That’s it. What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.&lt;/p&gt;

&lt;p&gt;Here we are using it to automate acceptance test for our web based control panel. We will be triggering those tests periodically and monitor the results. If anything customer facing stops working, we’ll have the first hand and quickly react to issues before they spread or damages company reputation.&lt;/p&gt;

&lt;p&gt;Many documents or blogs you find online regarding Selenium are out dated and are only covering the old Selenium. I will be focusing on Selenium 2 with the WebDriver standard which is adopted by major browsers.&lt;/p&gt;

&lt;h3 id=&quot;selenium-ide-or-selenium-builder&quot;&gt;Selenium IDE or Selenium Builder&lt;/h3&gt;

&lt;hr&gt;

&lt;p&gt;Both Selenium IDE and Selenium Builder are implemented as a Firefox extensions. They allow you to record, edit, and debug your automated test scripts. Selenium Builder was created in the attempt to replace Selenium IDE in the long run and is still in the beta stage as I am writing. Having used both, I prefer to use Selenium IDE because Selenium is crashing a lot. &lt;br&gt;
&lt;img src=&quot;http://docs.seleniumhq.org/projects/ide/selenium-ide.gif&quot; alt=&quot;enter image description here&quot; title=&quot;&quot;&gt;&lt;/p&gt;

&lt;h4 id=&quot;selenium-ide&quot;&gt;Selenium IDE&lt;/h4&gt;

&lt;p&gt;It currently supports both Selenium 1 and 2 (WebDriver) format. It’s able to convert your tests into scripts in the programming languages you use. Here we use Perl and we’ll need to install a &lt;a href=&quot;https://github.com/aivaturi/Selenium-Remote-Driver/blob/master/ide-plugin.js&quot;&gt;plugin&lt;/a&gt; provided by the Selenium::Remote::Driver project in order for Selenium IDE to convert test scripts to Perl. &lt;/p&gt;

&lt;h3 id=&quot;selenium-grid-2&quot;&gt;Selenium Grid 2&lt;/h3&gt;

&lt;p&gt;Don’t be intimidated by the term “Grid”; It simply means a cluster of Selenium servers. The &lt;a href=&quot;https://code.google.com/p/selenium/wiki/Grid2&quot;&gt;Wiki&lt;/a&gt; has full instructions on how to use and configure Selenium Grid 2. Here I am just going to cover what I use on my project. &lt;strong&gt;The Grid is consisted with a hub and multiple nodes&lt;/strong&gt;. The selenium-server-standalone package includes the Hub, WebDriver, and legacy RC needed to run the grid. Ant is not required anymore. You can download the selenium-server-standalone-*.jar from &lt;a href=&quot;http://code.google.com/p/selenium/downloads/list&quot;&gt;here&lt;/a&gt;. This walk-through assumes that you have already installed Java run time on your testing servers.&lt;/p&gt;

&lt;h4 id=&quot;grid-hub&quot;&gt;Grid Hub&lt;/h4&gt;

&lt;p&gt;The Selenium Hub is the central point that will receive all the test requests from your testing script and distribute them the the appropriate Selenium nodes.&lt;/p&gt;

&lt;p&gt;Open a command prompt and navigate to the directory where you copied the selenium-server-standalone file. Type the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;java -jar selenium-server-standalone-2.33.0.jar -role hub&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The hub will automatically start-up using port 4444 by default. To change the default port, you can add the optional parameter -port when you run the command. You can view the status of the hub by opening a browser window and navigating to: &lt;a href=&quot;http://localhost:4444/grid/console&quot;&gt;http://localhost:4444/grid/console&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;grid-node&quot;&gt;Grid Node&lt;/h4&gt;

&lt;p&gt;Regardless on whether you want to run a grid with new WebDriver functionality, or a grid with Selenium 1 RC functionality, or both at the same time, you use the same selenium-server-standalone jar file to start the nodes.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;java -jar selenium-server-standalone-2.33.0.jar -role node  -hub http://localhost:4444/grid/register&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note: The port defaults to 5555 if not specified whenever the “-role” option is provided and is not hub.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;java -jar selenium-server-standalone-2.33.0.jar -role node&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For backwards compatibility “wd” and “rc” roles are still a valid subset of the “node” role. But those roles limit the types of remote connections to their corresponding API, while “node” allows both Selenium RC and Selenium WebDriver remote connections.&lt;/p&gt;

&lt;h3 id=&quot;webdriver&quot;&gt;WebDriver&lt;/h3&gt;

&lt;p&gt;WebDriver is the new Selenium 2. It takes a different approach to solve the same problem as Selenium 1. Rather than being a JavaScript application running within the browser, it uses whichever mechanism is most appropriate to control the browser. For Firefox, this means that WebDriver is implemented as an extension. For IE, WebDriver makes use of IE’s Automation controls.&lt;/p&gt;

&lt;p&gt;By changing the mechanism used to control the browser, we can circumvent the restrictions placed on the browser by the JavaScript security model. In those cases where automation through the browser isn’t enough, WebDriver can make use of facilities offered by the Operating System. For example, on Windows we simulate typing at the OS level, which means we are more closely modeling how the user interacts with the browser, and that we can type into “file” input elements.&lt;/p&gt;

&lt;h4 id=&quot;run-tests&quot;&gt;Run Tests&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;My Environment&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OS: Mac OSX&lt;/li&gt;
&lt;li&gt;Selenium Nodes: &lt;br&gt;
&lt;ol&gt;&lt;li&gt;Ubuntu 12.04&lt;/li&gt;
&lt;li&gt;Mac OSX&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;Selenium Server Version: &lt;strong&gt;WebDriver&lt;/strong&gt; running on Mac OSX&lt;/li&gt;
&lt;li&gt;Test Scripting Language: &lt;strong&gt;Perl&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For Selenium (WebDriver) nodes, you will need to use the RemoteWebDriver and the DesiredCapabilities object to define which browser, version and platform you wish to use. Create the target browser capabilities you want to run the tests against. Examples will be under the “Perl” section.&lt;/p&gt;

&lt;h2 id=&quot;writing-test-script-with-perl&quot;&gt;Writing Test Script with Perl&lt;/h2&gt;

&lt;p&gt;Majority of the examples I found online regarding the use cases of Selenium 2 (WebDriver) are done either in Java or Ruby. Java is out of the question because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No heavy IDEs like Eclipse or Netbeans running on my already suffocating Mac OSX&lt;/li&gt;
&lt;li&gt;The need to compile testing scripts seems like a waste of time&lt;/li&gt;
&lt;li&gt;We are a Perl shop at work, I will get much support using the language people are comfortable with&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Decision has been made. Let’s take a look at what Perl modules we will need to make it work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selenium::Remote::Driver&lt;/li&gt;
&lt;li&gt;Test::More&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;seleniumremotedriver&quot;&gt;Selenium::Remote::Driver&lt;/h3&gt;

&lt;p&gt;Perl Client for Selenium Remote Driver, it is used to connect to Selenium server (Hub/Node) remotely and send command to the WebDriver API. Install this module with &lt;a href=&quot;http://www.cpan.org/&quot;&gt;CPAN&lt;/a&gt; from your Linux or OS X terminal:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cpan -i Selenium::Remote::Driver Test::More
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In your Perl script, load this module at the beginning of the script with the other ones that you would normally use like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Selenium::Remote::Driver;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here is the full documentation on how to initiate and use &lt;a href=&quot;https://metacpan.org/module/Selenium::Remote::Driver&quot;&gt;Selenium::Remote::Driver&lt;/a&gt; module. Use the following in your Perl script to connect to a Selenium hub or node by specifying the server’s IP address, the browser type and/or version you want to test with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $driver = Selenium::Remote::Driver-&amp;gt;new(
    &#39;remote_server_addr&#39; =&amp;gt; &#39;localhost&#39;,
    &#39;browser_name&#39; =&amp;gt; &#39;phantomjs&#39;,
    &#39;port&#39; =&amp;gt; &#39;5555&#39;,
);
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;testmore&quot;&gt;Test::More&lt;/h3&gt;

&lt;p&gt;Yet another framework for writing test scripts. It will generate TAP test results which I can integrate into Jenkins for CI (continues integration) or Nagios for monitoring test results. &lt;br&gt;
&lt;a href=&quot;https://metacpan.org/module/Test::More&quot;&gt;Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;browsers&quot;&gt;Browsers&lt;/h2&gt;

&lt;p&gt;&lt;i class=&quot;icon-search&quot;&gt;&lt;/i&gt; &lt;br&gt;
List of supported browser names that you can use in the Perl script.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iphone&lt;/li&gt;
&lt;li&gt;firefox&lt;/li&gt;
&lt;li&gt;internet explorer&lt;/li&gt;
&lt;li&gt;htmlunit&lt;/li&gt;
&lt;li&gt;iphone&lt;/li&gt;
&lt;li&gt;chrome&lt;/li&gt;
&lt;li&gt;phantomjs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;firefox&quot;&gt;Firefox&lt;/h3&gt;

&lt;p&gt;Supported by default&lt;/p&gt;

&lt;h3 id=&quot;chrome&quot;&gt;Chrome&lt;/h3&gt;

&lt;p&gt;Require you to install &lt;a href=&quot;https://code.google.com/p/selenium/wiki/ChromeDriver&quot;&gt;ChromeDriver&lt;/a&gt;. To use it in conjunction with Selenium server, start your Selenium server with the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;java -Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone-2.33.0.jar&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;chromedriver&lt;/code&gt; is the actual ChromeDriver executable you’ve just downloaded. &lt;/p&gt;

&lt;h3 id=&quot;phantomjs&quot;&gt;PhantomJS&lt;/h3&gt;

&lt;h3 id=&quot;safari&quot;&gt;Safari&lt;/h3&gt;

&lt;h3 id=&quot;internet-explorer&quot;&gt;Internet Explorer&lt;/h3&gt;

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;

&lt;h3 id=&quot;search-google-image-for-me&quot;&gt;Search Google Image for me&lt;/h3&gt;

&lt;h2 id=&quot;tools-for-other-programing-language&quot;&gt;Tools for Other Programing Language&lt;/h2&gt;

&lt;h3 id=&quot;javascript&quot;&gt;Javascript&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://nightwatchjs.org/&quot;&gt;Nightwatch.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/7968136948508772859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/13480204/posts/default/7968136948508772859'/><link rel='alternate' type='text/html' href='http://unicsolution.blogspot.com/2013/08/automated-web-testing-with-perl-and.html' title='Automated Web Testing with Perl and WebDriver'/><author><name>Hank Huang</name><uri>http://www.blogger.com/profile/05378624299866579454</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>