rendered paste body#!/bin/env pythonfrom twisted.spread import pbimport timeclass CommandFile: def write_result(self,hostname,service,status,message): location_file = open("/usr/local/nagios/var/rw/nagios.cmd","w") location_file.write("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%s;%s" % (time.time(), hostname, service, status, message))class NagiosServer(pb.Root): def remote_hello(self): print "Hello world!" return "Hello World!" def remote_report_load(self,hostname,load): print "Hostname is %s and Load is %s " % (hostname, load) file.write_result(hostname,"check_load",0,load)if __name__ == "__main__": from twisted.internet import reactor file = CommandFile() server = NagiosServer() reactor.listenTCP(8789, pb.PBServerFactory(server)) reactor.run()