Projet

Général

Profil

Révision f6d7cf59

IDf6d7cf5965c849e8d00cb9dbe6cdaf8927c66e51
Parent d33fcd55
Enfant e109323f

Ajouté par Jasper Lievisse Adriaanse il y a plus de 11 ans

Add plugin to retrieve the time puppet agent took to apply the catalog

Voir les différences:

plugins/puppet/puppet_runtime
1
#!/usr/bin/ruby
2

  
3
# This plugin reports the duration of the most recent puppet agent run.
4
# It requires read access to the puppet logfile (defaults to /var/log/messages).
5
#
6
# CONFIGURATION
7
#
8
# [puppet*]
9
# env.puppet_logfile /var/log/message
10
# env.puppet_logformat "^%b %d"
11
#
12
# The logfile is where the puppet agent is expected to log its run time statistics.
13
# The format is the format of the date syslog writes to the file, which may vary
14
# according to locale and configuration.
15

  
16
# reports how long the puppet agent took to apply the catalog
17
def get_runtime
18
  logfile = ENV['puppet_logfile'] || '/var/log/messages'
19
  t = Time.now
20
  dateformat = ENV['puppet_logformat'] || "^%b %d"
21
  today = t.strftime(dateformat)
22
  File.open(logfile).grep(/#{today}/).grep(/Finished catalog run in/).reverse_each do |line|
23
    if line =~ /in (.*) seconds/
24
      puts "runtime.value #{$1}"
25
      exit 0
26
    end
27
  end
28
end
29

  
30
case ARGV[0]
31
	when 'config'
32
  		puts "graph_category puppet"
33
                puts "graph_args --base 1000 -l 0"
34
                puts "graph_scale no"
35
  		puts "graph_title puppet catalog run time"
36
  		puts "graph_vlabel Seconds"
37
  		puts "runtime.label Catalog application time"
38
		exit 0
39
	when 'autoconf'
40
		puts "yes"
41
		exit 0
42
	else
43
  		get_runtime
44
end
45

  

Formats disponibles : Unified diff