I used below plugin for creating easy services in Nagios. Main idea behind this without adding new commands for everycheck i just use same command for many service definition
check_command_big!find /var/ | grep test |wc -l!5 . Here you can change only OS commands and check anything you want greater than 5 or any value you state. another example of check can be check_command_big!ps -ef | grep aprocess | wc -l !5
check_command_big!find /var/ | grep test |wc -l!5 . Here you can change only OS commands and check anything you want greater than 5 or any value you state. another example of check can be check_command_big!ps -ef | grep aprocess | wc -l !5
cat check_command_big.py #!/usr/bin/python #import sys, os, base64, getpass, socket, traceback, termios, tty, select import paramiko, getpass import os,sys,re import signal userName="user" userPass="pass" server=sys.argv[1] command=sys.argv[2] maxcount=int(sys.argv[3]) t = paramiko.Transport((server,22)) try: t.connect(username=userName,password=userPass,hostkey=None) except: print server + ": Bad password or login!" t.close() else: ch = t.open_channel(kind = "session") ch.exec_command(command) if (ch.recv_ready): x=int(ch.recv(1000)) if x <= maxcount: print "OK " + str(x) + " command=" + re.sub(r'\|', "",sys.argv[2]) + " | " + str(x) t.close() sys.exit(0) else: print "NOK " + str(x) + " command=" + re.sub(r'\|', "",sys.argv[2]) + " | " + str(x) t.close() sys.exit(1) define command{ command_name check_command_big command_line $USER1$/check_command_big.py $HOSTADDRESS$ '$ARG1$' $ARG2$ } define service{ hostgroup_name testservers use generic-service check_interval 10 service_description TEST check_command check_command_big!find /var/ | grep test |wc -l!5 }
No comments:
Post a Comment