#!/usr/bin/env python
import argparse
import sys
import urllib
import html
from xml.dom.minidom import parseString
from urllib.request import FancyURLopener
from urllib.parse import urlencode
from urllib.request import *
class send_nrdp:
def run(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-u', '--url', action="store",
dest="url", help="\
** REQUIRED ** The URL used to access the remote NRDP agent.")
parser.add_argument('-t', '--token', action="store",
dest="token", help="\
** REQUIRED ** The authentication token used to access the\n\
remote NRDP agent.")
parser.add_argument('-H', '--hostname', action="store",
dest="hostname", help="\
The name of the host associated with the passive host/service\n\
check result.")
parser.add_argument('-s', '--service', action="store",
dest="service", help="\
For service checks, the name of the service associated with the\n\
passive check result.")
parser.add_argument('-S', '--state', action="store",
dest="state", help="\
An integer indicating the current state of the host or service.")
parser.add_argument('-o', '--output', action="store",
dest="output", help="\
Text output to be sent as the passive check result.\n\
Newlines should be encoded with encoded newlines (\\n).")
parser.add_argument('-f', '--file', action="store",
dest="file", help="\
This file will be sent to the NRDP server specified in -u\n\
The file should be an XML file in the following format:\n\
##################################################\n\
\n\
\n\
\n\
YOUR_HOSTNAME\n\
0\n\
\n\
\n\
\n\
YOUR_HOSTNAME\n\
YOUR_SERVICENAME\n\
0\n\
\n\
\n\
\n\
##################################################")
parser.add_argument('-d', '--delim', action="store",
dest="delim", help="\
With only the required parameters send_nrdp.py is capable of\n\
processing data piped to it either from a file or other process.\n\
By default, we use t (\\t) as the delimiter however this may be\n\
specified with the -d option data should be in the following\n\
formats of one entry per line:\n\
printf \"\\t\\t