Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / openfire / openfire_ @ 09b88141

Historique | Voir | Annoter | Télécharger (5,54 ko)

1 f912045d phl
#!/usr/bin/env perl
2
# -*- perl -*-
3
4
=head1 NAME
5
6
openfire_ a Plugin for displaying Openfire Stats
7
8
=head1 INTERPRETATION
9
10
This plugin displays the following charts:
11
12
1) db 				Displaying DB Connections Stats.
13
2) threads 			Displaying Stats about Openfire Stats.
14
3) tasks 			Displaying Stats about Openfire Background Tasks.
15
4) sessions 		Displaying the Number of current Jabber Sessions.
16
5) nio 				Displaying some Network I/O Stats.
17
6) queue	Displaying the Number of queued Events
18
7) timestamp 		Displaying the Log Timestamp (should be increasing - for Debugging)
19
20
You can set the modes with naming the softlink:
21
22
1) openfire_db
23
2) openfire_threads
24
3) openfire_tasks
25
4) openfire_sessions
26
5) openfire_nio
27
6) openfire_queue
28
7) openfire_timestamp
29
30
=head1 CONFIGURATION
31
32
You need to have the Openfire "Load Statistic" Plugin-installed!
33
34
This plugin is configurable environment variables.
35
36 09b88141 Lars Kruse
 user root 		must be root user
37
 env.statsfile 	path to stats.txt file
38 f912045d phl
39
Example:
40
41 09b88141 Lars Kruse
 [openfire_*]
42
 user root
43
 env.statsfile /var/log/openfire/stats.txt
44 f912045d phl
45
46
=head1 AUTHOR
47
48 09b88141 Lars Kruse
Philipp Haussleiter <philipp@haussleiter.de>
49 f912045d phl
50
=head1 LICENSE
51
52
GPLv2
53
54
=cut
55
56
# MAIN
57
use warnings;
58
use strict;
59
use File::Basename;
60
61
my $statsfile = ($ENV{'statsfile'} || '/usr/share/openfire/logs/stats.txt');
62
63
my $tailBin = "/usr/bin/tail";
64
65
# db,threads,tasks,sessions,nio,timestamp
66
my $type = basename($0);
67
$type =~ s/openfire_//;
68
69
70
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
71
	if( $type eq "db" ) {
72
		print "graph_args --base 1000 -l 0\n";
73
		print "graph_title Openfire DB Usage\n";
74
		print "graph_vlabel Number of Connections\n";
75 3ad41d6a dipohl
		print "graph_category chat\n";
76 f912045d phl
		print "graph_info The Graph shows Number of DB Connections\n";
77
		print "db_used.draw AREA\ndb_used.label used\ndb_used.type GAUGE\n";
78
		print "db_current.draw STACK\ndb_current.label current\ndb_current.type GAUGE\n";
79
		print "db_min.draw STACK\ndb_min.label min\ndb_min.type GAUGE\n";
80
		print "db_max.draw STACK\ndb_max.label max\ndb_max.type GAUGE\n";
81
	}
82
	if( $type eq "threads" ) {
83
		print "graph_args --base 1000 -l 0\n";
84
		print "graph_scale no\n";
85
		print "graph_title Openfire Threads\n";
86
		print "graph_vlabel Number of Threads\n";
87 3ad41d6a dipohl
		print "graph_category chat\n";
88 f912045d phl
		print "graph_info The Graph shows Number of Threads\n";
89
		print "thread_core.draw AREA\nthread_core.label Core Threads\nthread_core.type GAUGE\n";
90
		print "thread_active.draw STACK\nthread_active.label active Threads\nthread_active.type GAUGE\n";
91
	}
92
	if( $type eq "tasks" ) {
93
		print "graph_args --base 1000 -l 0\n";
94
		print "graph_scale no\n";
95
		print "graph_title Openfire Tasks\n";
96
		print "graph_vlabel Number of Tasks\n";
97 3ad41d6a dipohl
		print "graph_category chat\n";
98 f912045d phl
		print "graph_info The Graph shows Number of Tasks\n";
99
		print "task_queue.draw AREA\ntask_queue.label queued Tasks\ntask_queue.type GAUGE\n";
100
		print "task_completed.draw STACK\ntask_completed.label completed Tasks\ntask_completed.type DERIVE\n";
101
	}
102
	if( $type eq "sessions" ) {
103
		print "graph_args --base 1000 -l 0\n";
104
		print "graph_scale no\n";
105
		print "graph_title Openfire Sessions\n";
106
		print "graph_vlabel Number of Sessions\n";
107 3ad41d6a dipohl
		print "graph_category chat\n";
108 f912045d phl
		print "graph_info The Graph shows Number of Jabber Sessions\n";
109
		print "sessions.label Jabber Sessions\nsessions.type GAUGE\n";
110
	}
111
	if( $type eq "nio" ) {
112
		print "graph_args --base 1000 -l 0\n";
113
		print "graph_title Openfire I/O (NIO)\n";
114
		print "graph_vlabel Reads/Writes per \${graph_period} in (-) / out (+)\n";
115 3ad41d6a dipohl
		print "graph_category chat\n";
116 f912045d phl
		print "graph_info The Graph shows Number of Stanzas\n";
117
       		print "nio_written.label nio\nnio_written.draw LINE1\nnio_written.max 10000\nnio_written.min 0\nnio_written.graph no\n";
118
        	print "nio_read.label nio\nnio_read.draw LINE1\nnio_read.max 10000\nnio_read.min 0\nnio_read.negative nio_written\nnio_read.type DERIVE\n";
119
	}
120
    	if( $type eq "queue" ) {
121
		print "graph_args --base 1000 -l 0\n";
122
		print "graph_title Openfire Queue\n";
123
		print "graph_vlabel Number of queued Stanzas\n";
124 3ad41d6a dipohl
		print "graph_category chat\n";
125 f912045d phl
		print "graph_info The Graph shows Number of queued Stanzas\n";
126
		print "nio_queued_events.draw AREA\nnio_queued_events.label queued Events\nnio_queued_events.type GAUGE\n";
127
		print "nio_queued_writes.draw STACK\nnio_queued_writes.label queued Writes\nnio_queued_writes.type GAUGE\n";
128
	}
129
	if( $type eq "timestamp" ) {
130
		print "graph_args --base 1000 -l 0\n";
131
		print "graph_title Openfire Log Timestamp\n";
132
		print "graph_vlabel Timestamp\n";
133 3ad41d6a dipohl
		print "graph_category chat\n";
134 f912045d phl
		print "graph_info The Graph shows the Timestamp of the Log\n";
135
		print "timestamp.draw AREA\ntimestamp.label Log Timestamp\ntimestamp.type GAUGE\n";
136
	}
137
} else {
138
	my $cmd = "$tailBin -1 $statsfile";
139
	my $result = `$cmd`;
140
	my @array=split(/,/,$result);
141
	my $count = scalar @array;
142
	my $diff = 0;
143
	if($count < 14) {
144
		$diff = 4;
145
	}
146
147
	if( $type eq "timestamp" ) {
148
		print "timestamp.value $array[0]\n";
149
	}
150
	if( $count == 14 && $type eq "db" ) {
151
		print "db_min.value $array[1]\n";
152
		print "db_max.value $array[2]\n";
153
		print "db_current.value $array[3]\n";
154
		print "db_used.value $array[4]\n";
155
	}
156
	if( $type eq "threads" ) {
157
		print "thread_core.value $array[5-$diff]\n";
158
		print "thread_active.value $array[6-$diff]\n";
159
	}
160
	if( $type eq "tasks" ) {
161
		print "task_queue.value $array[7-$diff]\n";
162
		print "task_completed.value $array[8-$diff]\n";
163
	}
164
	if( $type eq "sessions" ) {
165
		print "sessions.value $array[9-$diff]\n";
166
	}
167
	if( $type eq "nio" ) {
168
		print "nio_read.value $array[10-$diff]\n";
169
		print "nio_written.value $array[11-$diff]\n";
170
	}
171
	if( $type eq "queue" ) {
172
		print "nio_queued_events.value $array[12-$diff]\n";
173
		print "nio_queued_writes.value $array[13-$diff]";
174
	}
175 3ad41d6a dipohl
}