<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Stackify on Ideas on Software Engineering</title>
    <link>https://john.leacox.com/tags/stackify/</link>
    <description>Recent content in Stackify on Ideas on Software Engineering</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="https://john.leacox.com/tags/stackify/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Differentiate Java Processes by Working Directory</title>
      <link>https://john.leacox.com/posts/differentiate-java-processes-by-working-directory/</link>
      <pubDate>Sun, 17 Feb 2013 00:00:00 +0000</pubDate>
      <guid>https://john.leacox.com/posts/differentiate-java-processes-by-working-directory/</guid>
      <description>&lt;p&gt;A lot of server software runs on Java, but the different Java processes are listed as simply &lt;code&gt;Java&lt;/code&gt; via commands like &lt;code&gt;top&lt;/code&gt; or &lt;code&gt;ps -ef&lt;/code&gt;. One feature of the &lt;a href=&#34;http://www.stackify.com&#34;&gt;Stackify&lt;/a&gt; agent is tracking the running processes on a server. I needed a way to identify what each Java process really was in a fairly simple and concise way, but there isn’t a clear winner in the output of the top or ps commands.&lt;/p&gt;&#xA;&lt;p&gt;Running &lt;code&gt;ps -ef | grep java&lt;/code&gt; will output something nasty, similar to what follows. You can likely figure out what the Java process is actually running from the args — the example below obviously being tomcat — however, it’s not the most readable and doesn’t give a clear and concise value to display to a user in the Stackify web site. The user of the process below also indicates that it is running tomcat, but that won’t be the case for all Java processes.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;tomcat7 41298 1 5 18:05 ? 00:00:03 /usr/lib/jvm/default-java/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I decided it might work to differentiate the Java processes by working directory, but I wasn’t sure if there was a good way to find the working directory. Through some Google searches I discovered the &lt;code&gt;pwdx&lt;/code&gt; command. The &lt;code&gt;pwdx&lt;/code&gt; command takes a list of pids as parameters and outputs a row with the pid and the working directory for each pid. The working directory doesn’t work for all situations, but I’ve found it generally gives a concise way of determining what a Java process is actually running. I’m certainly open to suggestions if anyone has a better idea.&lt;/p&gt;&#xA;&lt;p&gt;Running the pwdx command for the output above — &lt;code&gt;sudo pwdx 41298&lt;/code&gt; — leads to the following output. By combining this with the process name I can give the Java processes a more informative name when displayed in the Stackify website. This Java process would be displayed as &lt;code&gt;Java (/var/lib/tomcat7)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;41298: /var/lib/tomcat7&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Writing a Good Linux Init Script</title>
      <link>https://john.leacox.com/posts/writing-a-good-linux-init-script/</link>
      <pubDate>Fri, 28 Dec 2012 16:18:45 +0000</pubDate>
      <guid>https://john.leacox.com/posts/writing-a-good-linux-init-script/</guid>
      <description>&lt;p&gt;A good Linux init script that works across multiple distros is hard to find.  Most distros have a sample/skeleton init script to base your own init scripts on, but that requires having a separate init script for each distro.  For the &lt;a href=&#34;http://www.stackify.com&#34;&gt;Stackify&lt;/a&gt; Linux agent I wanted to have  a single init script that would work on all common Linux distros.  I had a decent init script that worked pretty well for &amp;lsquo;start&amp;rsquo; and &amp;lsquo;stop&amp;rsquo; commands, but not so much for &amp;lsquo;status&amp;rsquo;.  The &amp;lsquo;status&amp;rsquo; command worked on my development machine (&lt;a href=&#34;http://www.ubuntu.com&#34;&gt;Ubuntu&lt;/a&gt;) but didn&amp;rsquo;t work on the other distros I was testing on (&lt;a href=&#34;http://www.centos.org/&#34;&gt;CentOS&lt;/a&gt;/&lt;a href=&#34;http://www.redhat.com/&#34;&gt;Redhat&lt;/a&gt;/&lt;a href=&#34;https://aws.amazon.com/amis?platform=Amazon+Linux&amp;amp;selection=platform&#34;&gt;Amazon&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Since one of the things the Stackify Linux agent does is provide information on the different installed services and their statuses, it is important that the status of our own service is correct.  As we prepare for the first beta release of the Linux agent, I decided it was time to rewrite the init script.  I started with some Google searches on how to create a cross-distro init script, but they mostly led me back to the skeleton init scripts.  While having lunch with a former coworker at &lt;a href=&#34;http://www.fuzzystacoshop.com/&#34;&gt;Fuzzy&amp;rsquo;s Taco Shop&lt;/a&gt; &amp;ndash; which I highly recommend &amp;ndash; we got to discussing init scripts and he mentioned seeing an &amp;ldquo;init script to rule them all.&amp;rdquo;&lt;/p&gt;&#xA;&lt;p&gt;After lunch, I promptly searched for this legendary script.  My search lead me to the &lt;a href=&#34;http://blog.rimuhosting.com/2009/09/30/one-java-init-script/&#34;&gt;One Java init script to rule them all&lt;/a&gt;, which is an init script for Java application servers (e.g. Tomcat and JBoss) that will work on most Linux distros.  Turns out this script was really close to what I needed since the Stackify Linux agent is a Java application.  Many Linux distros have started implementing the &lt;a href=&#34;http://en.wikipedia.org/wiki/Linux_Standard_Base&#34;&gt;Linux Standard Base&lt;/a&gt; (LSB) which provides logging methods and a standard way to implement init script statuses.  However, since not all versions support LSB, I cannot use those logging methods for my init script.&lt;/p&gt;&#xA;&lt;p&gt;The nice thing about the Java init script to rule them all is that it checks for the existence of the LSB methods and if they do not exist it provides its own implementation.  I was able to base the Stackify agent init script largely on this existing script.  The script now works on all of the distros previously mentioned and should also work on most other distros.  The status returns the correct status on these distros and returns the correct status code for systems that do support LSB.&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
