Projet

Général

Profil

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

root / plugins / requesttracker / rt_ticket_loadtime @ 63351ab5

Historique | Voir | Annoter | Télécharger (2,69 ko)

1
#!/bin/sh
2
# -*- sh -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
rt_ticket_loadtime - Plugin to monitor the RT ticket loadtime
9

    
10
=head1 CONFIGURATION
11

    
12
The following environment variables are used by this plugin:
13

    
14
=over 4
15

    
16
=item web_url
17

    
18
The RT WebURL configuration parameter
19

    
20
=item username
21

    
22
The RT username
23

    
24
=item password
25

    
26
The RT password
27

    
28
=item ticket_id
29

    
30
The RT ticket id to test
31

    
32
=back
33

    
34
This configuration section shows the defaults of the plugin:
35

    
36
 [rt_ticket_loadtime]
37
     env.web_url https://localhost/
38
     env.username root
39
     env.password password
40
     env.ticket 1
41

    
42
To test the plungin run:
43
 munin-run --debug rt_ticket_loadtime
44

    
45
An appropriate test ticket should have 30 transactions or more
46
of type Create, Correspond or Comment and should load in about
47
1-10 seconds in the WebUI to have reproducible results.
48

    
49
If the test ticket needs more than 10 seconds to load (both WebUI
50
and REST values together), you have to add an appropriate timeout
51
value to your plugin configuration to override the munin default
52
timeout value of 10 seconds.
53

    
54
=head1 AUTHOR
55

    
56
Christian Loos <cloos@netsandbox.de>
57

    
58
=head1 LICENSE
59

    
60
GPLv2
61

    
62
=head1 MAGIC MARKERS
63

    
64
 #%# family=auto
65
 #%# capabilities=autoconf
66

    
67
=cut
68

    
69
web_url=${web_url:-"http://localhost/"}
70
username=${username:-"root"}
71
password=${password:-"password"}
72
ticket_id=${ticket_id:-"1"}
73

    
74
time=$(which time)
75
wget=$(which wget)
76

    
77
wget_opts="--page-requisites --no-cache --no-check-certificate --delete-after --quiet"
78

    
79
if [ "$1" = "autoconf" ]; then
80
    if [ "x$time" = "x" -o "x$wget" = "x" ]; then
81
        echo "no (need time and wget programs)"
82
    else
83
        echo yes
84
    fi
85
    exit 0
86
fi
87

    
88
if [ "$1" = "config" ]; then
89
    echo "graph_title RT ticket loadtime"
90
    echo "graph_args --base 1000 -l 0"
91
    echo "graph_vlabel Loadtime in seconds"
92
    echo "graph_category other"
93
    echo "graph_info This graph shows the loadtime in seconds of RT ticket $ticket_id"
94
    echo "webui.label loadtime WebUI"
95
    echo "webui.max 300"
96
    echo "webui.min 0"
97
    echo "webui.info Ticket loadtime with WebUI"
98
    echo "rest.label loadtime REST"
99
    echo "rest.max 300"
100
    echo "rest.min 0"
101
    echo "rest.info Ticket loadtime with REST API"
102
    exit 0
103
fi
104

    
105
tmpdir=$(mktemp -d) || exit 1
106
trap "rm -rf $tmpdir" 0
107

    
108
url_webui="${web_url}Ticket/Display.html?id=${ticket_id}&user=${username}&pass=${password}"
109
url_rest="${web_url}REST/1.0/ticket/${ticket_id}/history?format=l&user=${username}&pass=${password}"
110

    
111
cd $tmpdir || exit1
112
loadtime_webui=$($time --portability $wget $wget_opts --header='Accept-Encoding: gzip,deflate' $url_webui 2>&1 | awk '/^real / {print $2}')
113
loadtime_rest=$($time --portability $wget $wget_opts $url_rest 2>&1 | awk '/^real / {print $2}')
114
cd ..
115

    
116
echo "webui.value $loadtime_webui"
117
echo "rest.value $loadtime_rest"