Cricket on OS X 10.8 Mountain Lion

Andrew Davidoff <[email protected]> Sun, 4 Nov 2012 18:52:10 -0700
Newsgroups gmane.network.cricket.user
Message-ID <CAJLXCZSuxJbcFCbxpnmMtcFi21XuuqwU33AyaV0i7FU6G5geJA@mail.gmail.com>
Hi,

I just got cricket working on OS X 10.8 Mountain Lion and figured I should
share. I think what I did was reasonable, but I'm open to criticism.

Before I get into the specifics of the install, I should note that I ran
into one issue related to targetTypes that don't contain a "view"
dictionary. Whether this is my fault or a bug, I am not sure.

On line 233 of grapher.cgi we have this:

my($view) = lc $gQ->param('view');

Following that assignment, various statements check to see if $view is
defined. It appears as though "lc" is returning an empty string (i.e. $view
is defined) in the case of $gQ->param('view') being undefined, which breaks
display of targets that aren't views. I am currently only using a single
target that does use a targetType that contains a view dictionary, so I
have essentially worked around this (for now).

And here's what I did to get cricket running on OS X 10.8 Mountain Lion.
Oh, I just remembered, the links to SNMP_Session and rrdtool in the
beginner guide are both out of date. Correct links are below in my notes.

Making cricket work:

1. Download cricket source
2. Untar into ~/, symlink cricket to cricket-1.0.5
3. Install RRDTool (http://oss.oetiker.ch/rrdtool/) via macports
   * `sudo port install rrdtool`
4. Install SNMP_Session (http://code.google.com/p/snmp-session/) via
macports
   * `sudo port install p5-snmp_session`
5. Install required modules via *macports* cpan
   * cpan> install MD5
   * cpan> install LWP
   * cpan> install DB_File
   * cpan> install Date::Parse
   * cpan> install Time::HiRes
6. cd to ~/cricket, run util/relocate-perl
   * Should update shebangs to macports perl installation in /opt

Cricket now works (compile/collector).


Making apache/grapher.cgi work:

1. You can no longer enable apache from System Preferences in 10.8.
   * To enable serving of content from ~user/Sites, and enable the options
     necessary for getting cricket's grapher to work, create a file:

     /etc/apache2/users/$username.conf

     That looks like this:

        <Directory "/Users/$username/Sites/">
             Options Indexes MultiViews FollowSymlinks ExecCGI
             AllowOverride All
             Order allow,deny
             Allow from all

            AddHandler cgi-script .cgi
        </Directory>

     The really important stuff is:
        * The path that you want to act as your public_html directory
        * FollowSymlinks
        * ExecCGI
        * AddHandler cgi-script .cgi
2. Uncomment from /etc/apache2/httpd.conf:
   * LoadModule perl_module libexec/apache2/mod_perl.so
3. Start apache with
   * `sudo apachectl start`
   * Logs are in /var/log/apache2
4. To make apache start at boot:
   * sudo launchctl load -w
/System/Library/LaunchDaemons/org.apache.httpd.plist
5. Update cricket's RRD::Format to know about
architecture darwin-thread-multi-2level
   * Get rrdtool source, untar somewhere
   * In cricket/util/
     - Modify getFormat.c (see diff)
       . Without these modifications, I received warnings that rrd_format.h
shouldn't be included directly
     - `gcc -I<path to RRD Tool's src dir> -o getFormat getFormat.c`
     - `./getFormat`
     - add getFormat output to Format.pm, including manually adding the
liveHead3 section (see diff)

Apache/grapher.cgi now work.


diff -wur cricket-1.0.5-orig/lib/RRD/Format.pm
/Users/davidoff/cricket-1.0.5/lib/RRD/Format.pm
--- cricket-1.0.5-orig/lib/RRD/Format.pm    2004-01-20 19:11:09.000000000
-0700
+++ /Users/davidoff/cricket-1.0.5/lib/RRD/Format.pm 2012-11-03
17:18:21.000000000 -0600
@@ -177,7 +177,18 @@
         $self->{'liveHead'} = "Q";
         $self->{'rraPtr'} = "Q";
         $self->{'element'} = "d";
-    } else {
+    } elsif ( $archname eq 'darwin-2level' ) {
+        $self->{'statHead'} = "a4 a5 x7 d Q Q Q x80";
+        $self->{'dsDef'} = "a20 a20 Q d d x56";
+        $self->{'rraDef'} = "a20 x4 Q Q d x72";
+        $self->{'pdpDef'} = "a30 x2 Q d x64";
+        $self->{'cdpDef'} = "d Q x64";
+        $self->{'liveHead'} = "Q";
+        $self->{'liveHead3'} = "Q Q";
+        $self->{'rraPtr'} = "Q";
+        $self->{'element'} = "d";
+    }
+    else {
         return;
     }
 }


diff -wur cricket-1.0.5-orig/util/getFormat.c
/Users/davidoff/cricket-1.0.5/util/getFormat.c
--- cricket-1.0.5-orig/util/getFormat.c 2002-07-02 19:40:14.000000000 -0600
+++ /Users/davidoff/cricket-1.0.5/util/getFormat.c  2012-11-03
17:08:06.000000000 -0600
@@ -15,6 +15,8 @@
  *
  */

+#define _RRD_TOOL_H
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -22,7 +24,7 @@
 #include <time.h>
 #include <ctype.h>

-#include <rrd_format.h>
+#include <rrd.h>

 void format_stat_head (void) {
   stat_head_t h1;



Hope this is helpful in some way.

Andy
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d