Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions check_cpu_stats_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import os
import sys
import optparse

# Ok try to load our directory to load the plugin utils.
my_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -103,27 +102,10 @@ def get_mpstat(client):



parser = optparse.OptionParser(
"%prog [options]", version="%prog " + VERSION)
parser.add_option('-H', '--hostname',
dest="hostname", help='Hostname to connect to')
parser.add_option('-p', '--port',
dest="port", type="int", default=22,
help='SSH port to connect to. Default : 22')
parser.add_option('-i', '--ssh-key',
dest="ssh_key_file",
help='SSH key file to use. By default will take ~/.ssh/id_rsa.')
parser.add_option('-u', '--user',
dest="user", help='remote use to use. By default shinken.')
parser.add_option('-P', '--passphrase',
dest="passphrase", help='SSH key passphrase. By default will use void')

parser = schecks.get_parser()

if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
if args:
parser.error("Does not accept any argument.")
opts = parser.parse_args()

port = opts.port
hostname = opts.hostname or ''
Expand All @@ -133,7 +115,7 @@ def get_mpstat(client):
passphrase = opts.passphrase or ''

# Ok now connect, and try to get values for memory
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user)
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user, ssh_auth=opts.ssh_auth)
stats = get_mpstat(client)

# Maybe we failed at getting data
Expand Down
11 changes: 5 additions & 6 deletions check_disks_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,23 @@ def get_df(client):

parser = schecks.get_parser()
## Specific options
parser.add_option('-w', '--warning',
parser.add_argument('-w', '--warning',
dest="warning",
help='Warning value for physical used memory. In percent. Default : 75%')
parser.add_option('-c', '--critical',
parser.add_argument('-c', '--critical',
dest="critical",
help='Critical value for physical used memory. In percent. Must be '
'superior to warning value. Default : 90%')
parser.add_option('-m', '--mount-points',
parser.add_argument('-m', '--mount-points',
dest="mounts",
help='comma separated list of mountpoints to check. Default all mount '
'points except if mounted in /dev, /sys and /run')
parser.add_option('-U', '--unit',
parser.add_argument('-U', '--unit',
dest="unit", help='Unit of Disk Space. B, KB, GB, TB. Default : B')


if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
opts = parser.parse_args()

if opts.mounts:
mounts = opts.mounts.split(',')
Expand Down
4 changes: 1 addition & 3 deletions check_disks_stats_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
'''
import os
import sys
import optparse

# Ok try to load our directory to load the plugin utils.
my_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -125,8 +124,7 @@ def get_disks_stats(client):
parser = schecks.get_parser()

if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
opts = parser.parse_args()

# Ok now got an object that link to our destination
client = schecks.get_client(opts)
Expand Down
28 changes: 3 additions & 25 deletions check_kernel_stats_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
'''
import os
import sys
import optparse

# Ok try to load our directory to load the plugin utils.
my_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -121,31 +120,10 @@ def get_kernel_stats(client):

return diff, stats





parser = optparse.OptionParser(
"%prog [options]", version="%prog " + VERSION)
parser.add_option('-H', '--hostname',
dest="hostname", help='Hostname to connect to')
parser.add_option('-p', '--port',
dest="port", type="int", default=22,
help='SSH port to connect to. Default : 22')
parser.add_option('-i', '--ssh-key',
dest="ssh_key_file",
help='SSH key file to use. By default will take ~/.ssh/id_rsa.')
parser.add_option('-u', '--user',
dest="user", help='remote use to use. By default shinken.')
parser.add_option('-P', '--passphrase',
dest="passphrase", help='SSH key passphrase. By default will use void')

parser = schecks.get_parser()

if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
if args:
parser.error("Does not accept any argument.")
opts = parser.parse_args()

port = opts.port
hostname = opts.hostname or ''
Expand All @@ -155,7 +133,7 @@ def get_kernel_stats(client):
passphrase = opts.passphrase or ''

# Ok now connect, and try to get values for memory
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user)
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user, ssh_auth=opts.ssh_auth)
diff, stats = get_kernel_stats(client)

# Maybe we failed at getting data
Expand Down
2 changes: 0 additions & 2 deletions check_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

VERSION = "0.1"

import optparse

if __name__ == '__main__':

modname = ''
Expand Down
29 changes: 6 additions & 23 deletions check_load_average_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'''
import os
import sys
import optparse

# Ok try to load our directory to load the plugin utils.
my_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -70,38 +69,22 @@ def get_load(client):



parser = optparse.OptionParser(
"%prog [options]", version="%prog " + VERSION)
parser.add_option('-H', '--hostname',
dest="hostname", help='Hostname to connect to')
parser.add_option('-p', '--port',
dest="port", type="int", default=22,
help='SSH port to connect to. Default : 22')
parser.add_option('-i', '--ssh-key',
dest="ssh_key_file",
help='SSH key file to use. By default will take ~/.ssh/id_rsa.')
parser.add_option('-u', '--user',
dest="user", help='remote use to use. By default shinken.')
parser.add_option('-P', '--passphrase',
dest="passphrase", help='SSH key passphrase. By default will use void')
parser.add_option('-w', '--warning',
parser = schecks.get_parser()
parser.add_argument('-w', '--warning',
dest="warning",
help='Warning value for load average, as 3 values, for 1m,5m,15m. Default : 1,1,1')
parser.add_option('-c', '--critical',
parser.add_argument('-c', '--critical',
dest="critical",
help='Critical value for load average, as 3 values, for 1m,5m,15m. Default : 2,2,2')
parser.add_option('-C', '--cpu-based', action='store_true',
parser.add_argument('-C', '--cpu-based', action='store_true',
dest="cpu_based",
help='Set the warning/critical number of cpu based values. For example '
'1,1,1 will warn if the load if over the number of CPUs. '
'Default : False')


if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
if args:
parser.error("Does not accept any argument.")
opts = parser.parse_args()

port = opts.port
hostname = opts.hostname or ''
Expand All @@ -123,7 +106,7 @@ def get_load(client):
critical = [float(v) for v in s_critical.split(',')]

# Ok now connect, and try to get values for memory
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user)
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user, ssh_auth=opts.ssh_auth)
load1, load5, load15, nb_cpus = get_load(client)

# Two cases : cpu_based_load or not. For CPU the real warning is based on warning*nb_cpu
Expand Down
4 changes: 1 addition & 3 deletions check_mdadm_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'''
import os
import sys
import optparse

# Ok try to load our directory to load the plugin utils.
my_dir = os.path.dirname(__file__)
Expand Down Expand Up @@ -118,8 +117,7 @@ def get_raid_status(client):
parser = schecks.get_parser()

if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
opts = parser.parse_args()

# Ok now got an object that link to our destination
client = schecks.get_client(opts)
Expand Down
31 changes: 7 additions & 24 deletions check_memory_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
'''
import os
import sys
import optparse
import base64
import subprocess

Expand Down Expand Up @@ -80,42 +79,26 @@ def get_meminfo(client):



parser = optparse.OptionParser(
"%prog [options]", version="%prog " + VERSION)
parser.add_option('-H', '--hostname',
dest="hostname", help='Hostname to connect to')
parser.add_option('-p', '--port',
dest="port", type="int", default=22,
help='SSH port to connect to. Default : 22')
parser.add_option('-i', '--ssh-key',
dest="ssh_key_file",
help='SSH key file to use. By default will take ~/.ssh/id_rsa.')
parser.add_option('-u', '--user',
dest="user", help='remote use to use. By default shinken.')
parser.add_option('-P', '--passphrase',
dest="passphrase", help='SSH key passphrase. By default will use void')
parser.add_option('-m', '--measurement',
parser = schecks.get_parser()
parser.add_argument('-m', '--measurement',
dest="measurement",action="store_true",default=False,
help='Measurement in absolute value of the memory behavior. Absolute value '
'currently can not be used as a check')
parser.add_option('-s', '--swap',
parser.add_argument('-s', '--swap',
dest="swap",action="store_true",default=False,
help='Enable swap value measurement. Swap value currently can not be used '
'as a check')
parser.add_option('-w', '--warning',
parser.add_argument('-w', '--warning',
dest="warning",
help='Warning value for physical used memory. In percent. Default : 75%')
parser.add_option('-c', '--critical',
parser.add_argument('-c', '--critical',
dest="critical",
help='Critical value for physical used memory. In percent. Must be '
'superior to warning value. Default : 90%')


if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
if args:
parser.error("Does not accept any argument.")
opts = parser.parse_args()

port = opts.port
hostname = opts.hostname or ''
Expand All @@ -130,7 +113,7 @@ def get_meminfo(client):
warning, critical = schecks.get_warn_crit(s_warning, s_critical)

# Ok now connect, and try to get values for memory
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user)
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user, ssh_auth=opts.ssh_auth)
total, used, free, shared, buffed, cached, swap_total, swap_used, swap_free = get_meminfo(client)

# Maybe we failed at getting data
Expand Down
30 changes: 6 additions & 24 deletions check_net_stats_by_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'''
import os
import sys
import optparse
import base64
import subprocess

Expand Down Expand Up @@ -127,39 +126,22 @@ def get_net_stats(client):



parser = optparse.OptionParser(
"%prog [options]", version="%prog " + VERSION)
parser.add_option('-H', '--hostname',
dest="hostname", help='Hostname to connect to')
parser.add_option('-p', '--port',
dest="port", type="int", default=22,
help='SSH port to connect to. Default : 22')
parser.add_option('-i', '--ssh-key',
dest="ssh_key_file",
help='SSH key file to use. By default will take ~/.ssh/id_rsa.')
parser.add_option('-u', '--user',
dest="user", help='remote use to use. By default shinken.')
parser.add_option('-P', '--passphrase',
dest="passphrase",
help='SSH key passphrase. By default will use void')
parser.add_option('-w', '--warning',
parser = schecks.get_parser()
parser.add_argument('-w', '--warning',
dest="warning",
help='Warning value for physical used memory. In percent. Default : 75%')
parser.add_option('-c', '--critical',
parser.add_argument('-c', '--critical',
dest="critical",
help='Critical value for physical used memory. In percent. Must be '
'superior to warning value. Default : 90%')
parser.add_option('-e', '--exclude',
parser.add_argument('-e', '--exclude',
action="append",
dest="exclude",
help='Interfaces to exclude. Can appear several time.')


if __name__ == '__main__':
# Ok first job : parse args
opts, args = parser.parse_args()
if args:
parser.error("Does not accept any argument.")
opts = parser.parse_args()

port = opts.port
hostname = opts.hostname or ''
Expand All @@ -177,7 +159,7 @@ def get_net_stats(client):
excluded_interfaces = opts.exclude

# Ok now connect, and try to get values for memory
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user)
client = schecks.connect(hostname, port, ssh_key_file, passphrase, user, ssh_auth=opts.ssh_auth)
diff, stats = get_net_stats(client)

# Maybe we failed at getting data
Expand Down
Loading