#!/usr/bin/env python # # niclient.py - Netinfo client example # # (c) 2016,2017 Todd Shadburn # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # import sys import netinfo # Initiate a connection to the host running netinfoevtd c = netinfo.NetinfoClient(host='localhost', key='./client.key', cert='./client.cert') # Create a couple of test events and send them e = netinfo.NetinfoEvent(object='pytest', data='This is a test event from python') c.send_event(e) e = netinfo.NetinfoEvent(flags=1, object='pytest', data='This is a test oneshot event from python') c.send_event(e) e = netinfo.NetinfoEvent(flags=0, rc=2, object='pytest', data='This is a test critical event from python') c.send_event(e) c.close() sys.exit(0)