----- Mail original -----
> De: "nap" <napar...@gmail.com>
> À: shinken-devel@lists.sourceforge.net
> Envoyé: Lundi 24 Janvier 2011 13:26:14
> Objet: Re: [Shinken-devel] 2 more ideas
> Hi,
>
>
> 2011/1/24 Grégory Starck <g.sta...@gmail.com>
>
> >
> >
> > 1) possibility to have nagios plugins in python and import them
> > instead of
> > subprocess:
> >
> > so that the pollers/workers( or at action level ?) could simply
> > import the
> > plugin (and only once at startup) and run the check/plugin without
> > having to
> > subprocess every time so a quite big win in efficiency/performance
> > no ? or
> > am I missing something about how it's going on ??
> > already if only the ping/host checks were done like this then
> > would'nt this
> > bring a "noticable" good impact in performance ??
> >
> > and what about the same for the most common services ??
> >
>
> Yes, ti's a good thing, especially for pople that do mostly nrpe for
> example. there is the idea
> http://shinken.ideascale.com/a/dtd/Use-builtin-plugin-for-eavily-used-plugin-instead-of-fork/99531-10373for
> this :) (there also a ticket in the trac).
>
This one is somewhere in my todo list. In case someone is faster that me to
implement it, here is some python code to run nrpe query.
Regards,
Nicolas
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
'''
Created on 21 juil. 2010
@author: a2683
'''
import socket
import struct
import binascii
from ctypes import create_string_buffer
class NRPE:
def build_query(self,command):
'''
Build a query packet
00-01 : NRPE protocol version
02-03 : packet type (01 : query, 02 : response)
04-07 : CRC32
08-09 : return code of the check if packet type is response
10-1034 : command (nul terminated)
1035-1036 : reserved
'''
query=create_string_buffer(1036)
query.raw=struct.pack(">2hih1024scc",02,01,00,0,command,'N','D')
crc = binascii.crc32(query)
struct.pack_into(">i", query, 4, crc)
return query
def query(self,host,port,command):
query=self.build_query(command)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
s.send(query)
data = s.recv(1034)
s.close()
# TODO : check crc
response = struct.unpack(">2hih1024s",data)
rc = response[3]
message = response[4]
crc = response[2]
return (rc,message)
if __name__ == '__main__':
nrpe = NRPE()
(rc, message) = nrpe.query("XXXXX",5666,"check_apache")
print "rc = %s" % rc
print "message = %s" % message
(rc, message) = nrpe.query("XXXXX",5666,"_NRPE_CHECK")
print "rc = %s" % rc
print "message = %s" % message
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel