initial commit
This commit is contained in:
		
						commit
						d96fb7afa4
					
				
					 9 changed files with 58 additions and 0 deletions
				
			
		
							
								
								
									
										26
									
								
								procio.cr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								procio.cr
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					dir = ENV.fetch("PROCIO_DIR", "/proc")
 | 
				
			||||||
 | 
					hostname = ENV.fetch("PROCIO_HOSTNAME", "/proc")
 | 
				
			||||||
 | 
					result = {} of String => Hash(Symbol, UInt64)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Dir.entries(dir).each do |entry|
 | 
				
			||||||
 | 
					  entry =~ /^\d+$/ || next 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  comm = File.read("#{dir}/#{entry}/comm").chomp
 | 
				
			||||||
 | 
					  result[comm] ||= {r: 0.to_u64, w: 0.to_u64}.to_h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  File.read_lines("#{dir}/#{entry}/io").each do |line|
 | 
				
			||||||
 | 
					    if line.starts_with?("read_bytes: ")
 | 
				
			||||||
 | 
					      result[comm][:r] += line.split(" ").last.to_u64
 | 
				
			||||||
 | 
					    elsif line.starts_with?("write_bytes: ")
 | 
				
			||||||
 | 
					      result[comm][:w] += line.split(" ").last.to_u64
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					time = Time.local.to_s("%s%9N")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					result.each do |comm, v|
 | 
				
			||||||
 | 
					  if v[:r] + v[:w] > 0
 | 
				
			||||||
 | 
					    puts %(procio comm="#{comm}" read_bytes=#{v[:r]},write_bytes=#{v[:w]} #{time})
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/12/comm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/12/comm
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					multi
 | 
				
			||||||
							
								
								
									
										7
									
								
								test/12/io
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								test/12/io
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					rchar: 0
 | 
				
			||||||
 | 
					wchar: 0
 | 
				
			||||||
 | 
					syscr: 0
 | 
				
			||||||
 | 
					syscw: 0
 | 
				
			||||||
 | 
					read_bytes: 100000
 | 
				
			||||||
 | 
					write_bytes: 0
 | 
				
			||||||
 | 
					cancelled_write_bytes: 0
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/13/comm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/13/comm
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					multi
 | 
				
			||||||
							
								
								
									
										7
									
								
								test/13/io
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								test/13/io
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					rchar: 0
 | 
				
			||||||
 | 
					wchar: 0
 | 
				
			||||||
 | 
					syscr: 0
 | 
				
			||||||
 | 
					syscw: 0
 | 
				
			||||||
 | 
					read_bytes: 100000
 | 
				
			||||||
 | 
					write_bytes: 100000
 | 
				
			||||||
 | 
					cancelled_write_bytes: 0
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/3/comm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/3/comm
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					nothinghere
 | 
				
			||||||
							
								
								
									
										7
									
								
								test/3/io
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								test/3/io
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					rchar: 0
 | 
				
			||||||
 | 
					wchar: 0
 | 
				
			||||||
 | 
					syscr: 0
 | 
				
			||||||
 | 
					syscw: 0
 | 
				
			||||||
 | 
					read_bytes: 0
 | 
				
			||||||
 | 
					write_bytes: 0
 | 
				
			||||||
 | 
					cancelled_write_bytes: 0
 | 
				
			||||||
							
								
								
									
										1
									
								
								test/452/comm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/452/comm
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					alotgoingon
 | 
				
			||||||
							
								
								
									
										7
									
								
								test/452/io
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								test/452/io
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					rchar: 0
 | 
				
			||||||
 | 
					wchar: 0
 | 
				
			||||||
 | 
					syscr: 0
 | 
				
			||||||
 | 
					syscw: 0
 | 
				
			||||||
 | 
					read_bytes: 82546474
 | 
				
			||||||
 | 
					write_bytes: 34637376
 | 
				
			||||||
 | 
					cancelled_write_bytes: 0
 | 
				
			||||||
		Loading…
	
		Reference in a new issue