Discussion:
[cricket-users] Cricket on OS X 10.8 Mountain Lion
Andrew Davidoff
2012-11-05 01:52:10 UTC
Permalink
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
Andrew Davidoff
2012-11-10 04:11:18 UTC
Permalink
Just a follow up here. While working on getting mtargets working (still not
sure if it's just me using it incorrectly...) I found another part of
grapher.cgi that is handling an undefined 'view' correctly (see quoted
email below). It looks like this is what needs to happen to line 233:

--- /Users/davidoff/Downloads/cricket-1.0.5/grapher.cgi 2004-02-06
09:27:34.000000000 -0700
+++ ./grapher.cgi 2012-11-09 21:10:02.000000000 -0700
@@ -230,7 +230,8 @@

# put the view into the target dict, so it's
# there if they want to use it.
- my($view) = lc $gQ->param('view');
+ my($view) = $gQ->param('view');
+ $view = lc $view if defined $view;
if (defined($view)) {
$targRef->{'auto-view'} = $view;
}

Refer to line 1363 for where I saw how this was being handled correctly
elsewhere.

Andy
Post by Andrew Davidoff
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.
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).
Continue reading on narkive:
Loading...