Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: syslog_parser.sh

Issue 2693001: Cleanup style nits in metrics daemon. (Closed) Base URL: ssh://git@chromiumos-git/metrics.git
Patch Set: Fix more nits from tfarina Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « metrics_library.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /bin/sh 1 #! /bin/sh
2 2
3 # This script parses /var/log/syslog for messages from programs that log 3 # This script parses /var/log/syslog for messages from programs that log
4 # uptime and disk stats (number of sectors read). It then outputs 4 # uptime and disk stats (number of sectors read). It then outputs
5 # these stats in a format usable by the metrics collector, which forwards 5 # these stats in a format usable by the metrics collector, which forwards
6 # them to autotest and UMA. 6 # them to autotest and UMA.
7 7
8 # To add a new metric add a line below, as PROGRAM_NAME METRIC_NAME. 8 # To add a new metric add a line below, as PROGRAM_NAME METRIC_NAME.
9 # PROGRAM_NAME is the name of the job whose start time we 9 # PROGRAM_NAME is the name of the job whose start time we
10 # are interested in. METRIC_NAME is the prefix we want to use for 10 # are interested in. METRIC_NAME is the prefix we want to use for
11 # reporting to UMA and autotest. The script prepends "Time" and 11 # reporting to UMA and autotest. The script prepends "Time" and
12 # "Sectors" to METRIC_NAME for the two available measurements, uptime 12 # "Sectors" to METRIC_NAME for the two available measurements, uptime
13 # and number of sectors read thus far. 13 # and number of sectors read thus far.
14 14
15 # You will need to emit messages similar to the following in order to add a 15 # You will need to emit messages similar to the following in order to add a
16 # a metric using this process. You will need to emit both a start and stop 16 # a metric using this process. You will need to emit both a start and stop
17 # time and the metric reported will be the difference in values 17 # time and the metric reported will be the difference in values
18 18
19 # Nov 15 08:05 localhost PROGRAM_NAME[822]: start METRIC_NAME time 12 sectors 56 19 # Nov 15 08:05 localhost PROGRAM_NAME[822]: start METRIC_NAME time 12 sectors 56
20 # Nov 15 08:05 localhost PROGRAM_NAME[822]: stop METRIC_NAME time 24 sectors 68 20 # Nov 15 08:05 localhost PROGRAM_NAME[822]: stop METRIC_NAME time 24 sectors 68
21 21
22 # If you add metrics without a start, it is assumed you are requesting the 22 # If you add metrics without a start, it is assumed you are requesting the
23 # time differece from system start 23 # time differece from system start
24 24
25 # Metrics we are interested in measuring 25 # Metrics we are interested in measuring
26 METRICS=" 26 METRICS="
27 upstart start_x 27 upstart start_x
28 " 28 "
29 29
30 first=1 30 first=1
31 program="" 31 program=""
32 32
33 # Get the metrics for all things 33 # Get the metrics for all things
34 for m in $METRICS 34 for m in $METRICS
35 do 35 do
36 if [ $first -eq 1 ] 36 if [ $first -eq 1 ]
37 then 37 then
38 first=0 38 first=0
39 program_name=$m 39 program_name=$m
40 else 40 else
41 first=1 41 first=1
42 metrics_name=$m 42 metrics_name=$m
43 43
44 # Example of line from /var/log/messages: 44 # Example of line from /var/log/messages:
45 # Nov 15 08:05:42 localhost connmand[822]: start metric time 12 sectors 56 45 # Nov 15 08:05:42 localhost connmand[822]: start metric time 12 sectors 56
46 # "upstart:" is $5, 1234 is $9, etc. 46 # "upstart:" is $5, 1234 is $9, etc.
47 program="${program}/$program_name([[0-9]+]:|:) start $metrics_name/\ 47 program="${program}/$program_name([[0-9]+]:|:) start $metrics_name/\
48 { 48 {
49 metrics_start[\"${metrics_name}Time\"] = \$9; 49 metrics_start[\"${metrics_name}Time\"] = \$9;
50 metrics_start[\"${metrics_name}Sectors\"] = \$11; 50 metrics_start[\"${metrics_name}Sectors\"] = \$11;
51 }" 51 }"
52 program="${program}/$program_name([[0-9]+]:|:) stop $metrics_name/\ 52 program="${program}/$program_name([[0-9]+]:|:) stop $metrics_name/\
53 { 53 {
54 metrics_stop[\"${metrics_name}Time\"] = \$9; 54 metrics_stop[\"${metrics_name}Time\"] = \$9;
55 metrics_stop[\"${metrics_name}Sectors\"] = \$11; 55 metrics_stop[\"${metrics_name}Sectors\"] = \$11;
56 }" 56 }"
57 fi 57 fi
58 done 58 done
59 59
60 # Do all the differencing here 60 # Do all the differencing here
61 program="${program}\ 61 program="${program}\
62 END{ 62 END{
63 for (i in metrics_stop) { 63 for (i in metrics_stop) {
64 value_time = metrics_stop[i] - metrics_start[i]; 64 value_time = metrics_stop[i] - metrics_start[i];
65 print i \"=\" value_time; 65 print i \"=\" value_time;
66 } 66 }
67 }" 67 }"
68 68
69 exec awk "$program" /var/log/syslog 69 exec awk "$program" /var/log/syslog
OLDNEW
« no previous file with comments | « metrics_library.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698