-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmarket
executable file
·112 lines (73 loc) · 2.22 KB
/
market
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
market - plugin to graph some statistical info from YML-file for yandex.market
=head1 APPLICABLE SYSTEMS
Any system wich generates correct YML file
=head1 CONFIGURATION
The configuration variables are:
ymlfile - path to the yml file
The default configuration is:
[market]
env.ymlfile /var/www/upload/market.xml
=head1 AUTHOR
# Copyright Dmitry V. <savraz@gmail.com>
# Nov 01, 2013
=head1 LICENSE
Licensed under the CC0 1.0: http://creativecommons.org/publicdomain/zero/1.0/
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
# Set the location of market YML file
YML=${ymlfile:-/var/www/upload/market.xml}
if [ "$1" = "autoconf" ]; then
if [ -r ${YML} ]; then
echo yes
exit 0
else
echo no
exit 0
fi
fi
# If run with the "config"-parameter, give out information of how the
# graphs should look.
if [ "$1" = "config" ]; then
# The title of the graph
echo 'graph_title YML information - General'
# Arguments to "rrdtool graph". In this case, tell it that the
# lower limit of the graph is '0', and that 1k=1000 (not 1024)
echo 'graph_args --base 1000 -A'
# The Y-axis label
echo 'graph_vlabel offers'
# Graph category
echo 'graph_category ecommerce'
# Graph information
echo 'graph_info This graph show some offers metrics'
echo 'total.info Total offers count'
echo 'avail.info Count of available for delivery/pickup offers'
echo 'picku.info Count of offers that is available for pickup'
# Labels is required subfield and used in the legend
echo 'total.label Total'
echo 'avail.label Available'
echo 'picku.label Pickup'
# Specify type. GAUGE type is default type, but we specify it anyway
echo 'total.type GAUGE'
echo 'avail.type GAUGE'
echo 'picku.type GAUGE'
# Thickness
echo 'total.draw LINE2'
print_warning total
print_critical total
print_warning avail
print_critical avail
print_warning picku
print_critical picku
# If run as 'config', we quit. No info diplayed.
exit 0
fi
# Actual work
echo "total.value "`grep -i -E '\<offer>' ${YML} | wc -l`
echo "avail.value "`grep -i -E 'offer(.*)available="true' ${YML} | wc -l`
echo "picku.value "`grep -i -E 'pickup(.*)true' ${YML} | wc -l`