Projet

Général

Profil

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

root / plugins / smf / smf_errors @ 17f78427

Historique | Voir | Annoter | Télécharger (1,86 ko)

1 361e9f2e realdigger
#!/usr/bin/perl
2
#
3 24bd2f7c realdigger
# Munin plugin for erorrs count over a SMF forum database
4 361e9f2e realdigger
#
5
# Copyright (C) 2013 - digger (http://simplemachines.ru)
6
# Based on Rowdy Schwachfer (http://rowdy.nl) 's Spotweb plugin
7
#
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
#
22
#
23
# Configuration example
24
#
25
#[smf*]
26
#env.mysql               /usr/bin/mysql           # MySQL binary (optional)
27
#env.db                  smf                      # SMF database (required)
28 a7ef9301 realdigger
#env.db_prefix           smf_                     # SMF database prefix(required)
29 361e9f2e realdigger
#env.db_user             myuser                   # SMF database user (required)
30
#env.db_password         mypassword               # SMF database password (required)
31
32
use strict;
33
34
my $MYSQL = $ENV{'mysql'} || "/usr/bin/mysql";
35
my $MYSQLOPTS = "-u " . $ENV{'db_user'} . " -p" . $ENV{'db_password'};
36
my $DATABASE = $ENV{'db'} || "smf";
37
my $PREFIX = $ENV{'db_prefix'} || "smf_";
38
39
# Output for config
40
if(defined $ARGV[0] && $ARGV[0] eq 'config') {
41
    print <<EOC
42
graph_title SMF Errors Log
43
graph_vlabel Number of errors
44 63351ab5 dipohl
graph_category forum
45 361e9f2e realdigger
errors.label Errors
46
graph_scale no
47
errors.warning 10000
48
errors.critical 100000
49
EOC
50
;
51
    exit 0;
52
}
53
54
#Errors count
55
my $errors = `$MYSQL $MYSQLOPTS -e 'SELECT COUNT(*) FROM ${DATABASE}.${PREFIX}log_errors'`;
56 17f78427 Lars Kruse
$errors =~ /(\d+)/;
57 361e9f2e realdigger
print "errors.value ".$1."\n";