PluginPortrait/coldfusion-traffic: coldfusion_traffic

File coldfusion_traffic, 2.4 KB (added by jemtallon@…, at 2006-06-22T18:51:59+02:00)

Coldfusion plugin to monitor ColdFusion? traffic

Line 
1#!/usr/bin/perl
2#
3# Plugin to monitor the traffic to the Coldfusion server on the machine
4#
5# By Jem Tallon
6#
7#
8# Requirements:
9#       - Needs access to the cfstat utility (definable in the munin-node file)
10#
11#
12# Tip: To see if it's already set up correctly, just run this plugin
13# with the parameter "autoconf". If you get a "yes", everything should
14# work like a charm already.
15#
16# Parameters supported:
17#
18#       config
19#       autoconf
20#
21# Configurable variables
22#
23#       cfdir    - The full path to the Coldfusion directory (default: /opt/coldfusionmx7)
24#
25#
26# To configure, edit /etc/munin/plugin-conf.d/munin-node to include the following lines
27#
28#       [coldfusion*]
29#           env.cfdir /opt/coldfusionmx7
30#
31#
32#
33# Magic markers:
34#%# family=auto
35#%# capabilities=autoconf
36
37use strict;
38
39## Make the local variables either from the environment or from defaults
40my $CFDIR = exists $ENV{'cfdir'} ? $ENV{'cfdir'} : "/opt/coldfusionmx7";
41my $CFBIN = "$CFDIR/bin";
42my $CFSTAT = "$CFBIN/cfstat";
43
44## If an "autoconf" argument was supplied, check to see if cfstat exists and report the results
45if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
46{
47        if( -e "$CFSTAT" )
48        {
49                print "yes\n";
50                exit 0;
51        }
52        else
53        {
54                print "no (cfstat not found)\n";
55                exit 1;
56        }
57}
58
59## If a "config" argument was supplied, show the config stuff and exit
60if ( exists $ARGV[0] and $ARGV[0] eq "config" )
61{
62        print "graph_title Coldfusion I/O\n";
63        print "graph_args -l 0 --base 1024\n";
64        print "graph_vlabel bytes per second in (-) / out (+)\n";
65        print "graph_category coldfusion\n";
66        print "graph_period second\n";
67        print "graph_info This graph shows the I/O to and from a Coldfusion server.\n";
68        print "cf_in.label In\n";
69        print "cf_in.type GAUGE\n";
70        print "cf_in.max 500000\n";
71        print "cf_in.min 0\n";
72        print "cf_in.info Bytes in to Coldfusion server\n";
73        print "cf_out.label Out\n";
74        print "cf_out.info Bytes out to Coldfusion server\n";
75        print "cf_out.type GAUGE\n";
76        print "cf_out.max 500000\n";
77        print "cf_out.min 0\n";
78        exit 0;
79}
80
81## I know this is a mess but it was the easiest way for me to do it. If anyone can improve on it, please do
82my $cfstatresult = `cd $CFBIN; $CFSTAT|sed -e 's/#.*//;/^\$/d'|sed -e 's/  */ /g'|tail -1`;
83my $inbytes = `echo "$cfstatresult" | cut -d" " -f13` + 0;
84my $outbytes = `echo "$cfstatresult" | cut -d" " -f14` + 0;
85
86## Print out the in and out values
87print "cf_in.value $inbytes\n";
88print "cf_out.value $outbytes\n";
89