[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

david hannequin david.hannequin at gmail.com
Tue Feb 28 22:08:02 UTC 2012


The following commit has been merged in the debian/master branch:
commit 9b03e1045dad41ffe31c0e5eff0c9136e279c11b
Author: david hannequin <david.hannequin at gmail.com>
Date:   Tue Dec 6 22:55:00 2011 +0100

    Add shinken plugin to check unix load

diff --git a/libexec/check_shinken_load.py b/libexec/check_shinken_load.py
new file mode 100755
index 0000000..e4653e2
--- /dev/null
+++ b/libexec/check_shinken_load.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+#   Autor : David Hannequin <david.hannequin at gmail.com>
+#   Date : 29 Nov 2011
+
+#
+# Script init
+#
+
+import sys
+import os
+import argparse
+import getopt 
+
+#
+# Usage 
+#
+
+def usage():
+    print 'Usage :'
+    print sys.argv[0] + ' -w <load1,load5,load15> -c <load1,load5,load15>'
+    print '-p --port : snmp port by default 161' 
+    print '   -c (--critical)      Three critical tresholds (defaults : 2,4,6)\n';
+    print '   -w (--warning)       Three warning tresholds (defaults : 1,3,5)\n';
+    print '   -h (--help)          Usage help\n';
+#
+# Main
+#
+
+def main():
+
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "hwc:v", ["help", "warning", "critical"])
+    except getopt.GetoptError, err:
+        # print help information and exit:
+        print str(err) 
+        usage()
+        sys.exit(2)
+    output = None
+    verbose = False
+
+    for o, a in opts:
+        if o == "-v":
+            verbose = True
+        elif o in ("-h", "--help"):
+            usage()
+            sys.exit()
+        elif o in ("-w", "--warning"):
+            notification = a
+        elif o in ("-c", "--critical"):
+            notification = a
+	else :
+	    assert False , "unknown options"
+
+if __name__ == "__main__":
+    main()
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-w', '--warning', default = '3,2,1')
+    parser.add_argument('-c', '--critical', default = '4,3,2' )
+    args = parser.parse_args()
+    critical = args.critical
+    warning = args.warning
+    
+    (d1, d2, d3) = os.getloadavg()
+
+    load1 = str(d1)
+    load5 = str(d2)
+    load15 = str(d3)
+    
+    listcritical = critical.split(',') 
+    listwarning = warning.split(',') 
+	
+    cload1 = str(listcritical[0]) 
+    cload5 = str(listcritical[1]) 
+    cload15 = str(listcritical[2]) 
+
+    wload1 = str(listwarning[0])
+    wload5 = str(listwarning[1])
+    wload15 = str(listwarning[2])
+    
+
+    if load1 >= cload1 or load5 >= cload5 or load15 >= cload15 : 
+       print 'CRITICAL - Load average : '+load1+','+load5+','+load15+'|load1='+load1+'; load5='+load5+'; load15='+load15    
+       sys.exit(2)
+    elif load1 >= wload1 or load5 >= wload5 or load15 >= wload15 :  
+       print 'WARNING - Load average : '+load1+','+load5+','+load15+'|load1='+load1+'; load5='+load5+'; load15='+load15    
+       sys.exit(1)
+    else :
+       print 'OK - Load average : '+load1+','+load5+','+load15+'|load1='+load1+'; load5='+load5+'; load15='+load15    
+       sys.exit(0)
+
diff --git a/libexec/check_snmp_load.py b/libexec/check_snmp_load.py
deleted file mode 100755
index 916e4c1..0000000
--- a/libexec/check_snmp_load.py
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/env python
-#   Autor : David Hannequin <david.hannequin at gmail.com>
-#   Date : 29 Nov 2011
-
-#
-# Script init
-#
-
-import sys
-import os
-import argparse
-import getopt 
-
-# SET Command Generator 
-from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher
-from pysnmp.carrier.asynsock.dgram import udp
-from pyasn1.codec.ber import encoder, decoder
-from pysnmp.proto import api
-from time import time
-
-#
-# Usage 
-#
-
-def usage():
-    print 'Usage :'
-    print sys.argv[0] + ' -H <hostaddress> -C <community> -w <load1,load5,load15> -c <load1,load5,load15>'
-    print '-p --port : snmp port by default 161' 
-#
-# Main
-#
-
-def main():
-
-    try:
-        opts, args = getopt.getopt(sys.argv[1:], "hHCwcpt:v", ["help", "hostaddress", "community", "warning", "critical", "port", "timeout" ])
-    except getopt.GetoptError, err:
-        # print help information and exit:
-        print str(err) 
-        usage()
-        sys.exit(2)
-    output = None
-    verbose = False
-
-    for o, a in opts:
-        if o == "-v":
-            verbose = True
-        elif o in ("-h", "--help"):
-            usage()
-            sys.exit()
-        elif o in ("-H", "--hostaddress"):
-            notification = a
-        elif o in ("-C", "--community"):
-            notification = a
-        elif o in ("-w", "--warning"):
-            notification = a
-        elif o in ("-c", "--critical"):
-            notification = a
-        elif o in ("-p", "--port"):
-            notification = a
-        elif o in ("-t", "--timeout"):
-            notification = a
-	else :
-	    assert False , "unknown options"
-
-if __name__ == "__main__":
-    main()
-    parser = argparse.ArgumentParser()
-    parser.add_argument('-H', '--hostaddress')
-    parser.add_argument('-C', '--community')
-    parser.add_argument('-w', '--warning')
-    parser.add_argument('-c', '--critical')
-    parser.add_argument('-p', '--port', default = 161)
-    parser.add_argument('-t', '--timeout', default = 5)
-    args = parser.parse_args()
-
-    hostaddress = args.hostaddress
-    community = args.community
-    warning = args.warning
-    critical = args.critical
-
-    port = int(args.port)
-    timeout = int(args.timeout)
-    	 
-    # Protocol version to use
-    pMod = api.protoModules[api.protoVersion1]
-    
-    # Build PDU
-    reqPDU =  pMod.GetRequestPDU()
-    pMod.apiPDU.setDefaults(reqPDU)
-    pMod.apiPDU.setVarBinds(
-        reqPDU, (((1,3,6,1,4,1,2021,10,1,3,1), pMod.Null()),
-                 ((1,3,6,1,4,1,2021,10,1,3,2), pMod.Null()),
-                 ((1,3,6,1,4,1,2021,10,1,3,3), pMod.Null()))
-        )
-
-    # Build message
-    reqMsg = pMod.Message()
-    pMod.apiMessage.setDefaults(reqMsg)
-    pMod.apiMessage.setCommunity(reqMsg, community)
-    pMod.apiMessage.setPDU(reqMsg, reqPDU)
-    
-    def cbTimerFun(timeNow, startedAt=time()):
-        if timeNow - startedAt > timeout :
-            raise "Request timed out"
-        
-    def cbRecvFun(transportDispatcher, transportDomain, transportAddress,
-                  wholeMsg, reqPDU=reqPDU):
-        while wholeMsg:
-            rspMsg, wholeMsg = decoder.decode(wholeMsg, asn1Spec=pMod.Message())
-            rspPDU = pMod.apiMessage.getPDU(rspMsg)
-            # Match response to request
-            if pMod.apiPDU.getRequestID(reqPDU)==pMod.apiPDU.getRequestID(rspPDU):
-                # Check for SNMP errors reported
-                errorStatus = pMod.apiPDU.getErrorStatus(rspPDU)
-                if errorStatus:
-                    print errorStatus.prettyPrint()
-                else:
-                    #for oid, val in pMod.apiPDU.getVarBinds(rspPDU):
-                    #    print 'Load : %s' % (val.prettyPrint()) 
-                    for oid, val in pMod.apiPDU.getVarBinds(rspPDU):
-                        print 'Load : %s' % (val.prettyPrint()) 
-			
-                transportDispatcher.jobFinished(1)
-        return wholeMsg 
-    
-
-    transportDispatcher = AsynsockDispatcher()
-    transportDispatcher.registerTransport(
-        udp.domainName, udp.UdpSocketTransport().openClientMode()
-        )
-    transportDispatcher.registerRecvCbFun(cbRecvFun)
-    transportDispatcher.registerTimerCbFun(cbTimerFun)
-    transportDispatcher.sendMessage(
-        encoder.encode(reqMsg), udp.domainName, (hostaddress, port)
-        )
-    transportDispatcher.jobStarted(1)
-    transportDispatcher.runDispatcher()
-    transportDispatcher.closeDispatcher()
-    

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list