Révision b0b39b01
Ruby plugins: apply style changes as suggested by "rubocop --fix-layout"
| plugins/moblock/moblock_connections | ||
|---|---|---|
| 1 | 1 |
#!/usr/bin/env ruby |
| 2 |
# |
|
| 3 |
# Plugin to monitor the number of connections blocked by moblock. |
|
| 4 |
# |
|
| 5 |
# Requirements: |
|
| 6 |
# |
|
| 7 |
# Moblock up and running with generated log files going to /var/log/moblock |
|
| 8 |
# |
|
| 9 |
# Parameters supported: |
|
| 10 |
# |
|
| 11 |
# config |
|
| 12 |
# autoconf |
|
| 13 |
# |
|
| 14 |
# Configurable variables |
|
| 15 |
# |
|
| 16 |
# logfile - Override default moblock logfile |
|
| 17 |
# |
|
| 18 |
# Magic markers |
|
| 19 |
# |
|
| 2 |
|
|
| 3 |
=begin |
|
| 4 |
|
|
| 5 |
Plugin to monitor the number of connections blocked by moblock. |
|
| 6 |
|
|
| 7 |
Requirements: |
|
| 8 |
|
|
| 9 |
Moblock up and running with generated log files going to /var/log/moblock |
|
| 10 |
|
|
| 11 |
Parameters supported: |
|
| 12 |
|
|
| 13 |
config |
|
| 14 |
autoconf |
|
| 15 |
|
|
| 16 |
Configurable variables |
|
| 17 |
|
|
| 18 |
logfile - Override default moblock logfile |
|
| 19 |
|
|
| 20 |
Magic markers |
|
| 21 |
|
|
| 20 | 22 |
#%# family=auto |
| 21 | 23 |
#%# capabilities=autoconf |
| 22 | 24 |
|
| 25 |
=end |
|
| 26 |
|
|
| 27 |
|
|
| 23 | 28 |
# |
| 24 | 29 |
# Initialize vars |
| 25 | 30 |
# |
| ... | ... | |
| 54 | 59 |
# |
| 55 | 60 |
# Grep moblock logs for stats |
| 56 | 61 |
# |
| 57 |
def fetch(debug=false)
|
|
| 62 |
def fetch(debug = false)
|
|
| 58 | 63 |
num_in = %x{cat #{$logfile} | grep --extended-regexp 'IN: ' | wc -l}
|
| 59 | 64 |
num_out = %x{cat #{$logfile} | grep --extended-regexp 'OUT: ' | wc -l}
|
| 60 | 65 |
num_total = num_in.to_i + num_out.to_i |
| ... | ... | |
| 80 | 85 |
# Handle command line args |
| 81 | 86 |
# |
| 82 | 87 |
case ARGV.first |
| 83 |
when 'config'
|
|
| 84 |
config
|
|
| 85 |
when 'debug'
|
|
| 86 |
fetch true
|
|
| 87 |
when 'autoconf'
|
|
| 88 |
autoconf
|
|
| 89 |
else
|
|
| 90 |
fetch
|
|
| 88 |
when 'config' |
|
| 89 |
config |
|
| 90 |
when 'debug' |
|
| 91 |
fetch true |
|
| 92 |
when 'autoconf' |
|
| 93 |
autoconf |
|
| 94 |
else |
|
| 95 |
fetch |
|
| 91 | 96 |
end |
Formats disponibles : Unified diff