pynag - command line front for manipulating nagios configuration
pynag <sub-command> [options] [arguments]
pynag is a command-line utility that can be used to view or change current nagios configuration.
pynag list [attribute1] [attribute2] [WHERE ...]
pynag update set attr1=value WHERE attr=value and attr=value
pynag delete delete <WHERE ...>
pynag add <object_type> <attr1=value1> [attr2=value2]
pynag copy <WHERE ...> <SET attr1=value1 [attr2=value2] ...>
pynag execute <host_name> [service_description]
pynag config [--set <attribute=value>] [--old_value=attribute] pynag config [--append <attribute=value>] [--old_value=attribute] pynag config [--remove <attribute>] [--old_value=attribute] pynag config [--get <attribute>]
Some Subcommands use WHERE statements to filter which objects to work with. Where has certain similarity with SQL syntax.
Any search attributes have the same syntax as the pynag filter. For example these work just fine:
pynag list WHERE host_name__contains=production pynag list WHERE host_name__startswith=prod pynag list WHERE host_name__notcontains=test pynag list host_name address WHERE address__exists=True pynag list host_name WHERE register__isnot=0
The pynag filter supports few parameters that are not just attributes.
- filename -- The filename which the object belongs
- id -- pynag unique identifier for the object
- effective_command_line -- command which nagios will execute
Of course these can be combined with the pynag filter syntax:
pynag list where filename__startswith=/etc/nagios/conf.d/ pynag list host_name service_description effective_command_line
For detailed description of the filter see pydoc for pynag.Model.ObjectDefintion.filter()
Subcommands that use SET statements (like update or copy) use them a list of attributes change for a specific object.
List all services that have myhost as a host_name¶
pynag list host_name service_description WHERE host_name=myhost and object_type=service
Set check_period to 24x7 on all services that belong to host myhost¶
pynag update set check_period=24x7 WHERE host_name=myhost
pynag list host_name address WHERE object_type=host pynag list host_name service_description WHERE host_name=examplehost and object_type=service
pynag update SET host_name=newhostname WHERE host_name=oldhostname pynag update SET address=127.0.0.1 WHERE host_name='examplehost.example.com' and object_type=host
pynag copy SET host_name=newhostname WHERE host_name=oldhostname pynag copy SET address=127.0.0.1 WHERE host_name='examplehost.example.com' and object_type=host
pynag add host host_name=examplehost use=generic-host address=127.0.0.1 pynag add service service_description="Test Service" use="check_nrpe" host_name="localhost"
pynag delete where object_type=service and host_name='mydeprecated_host' pynag delete where filename__startswith='/etc/nagios/myoldhosts'
pynag execute localhost pynag execute localhost "Disk Space
See http://github.com/pynag/pynag.git for more information.
Pall Sigurdsson and Tomas Edwardsson
2014, Pall Sigurdsson and Tomas Edwardsson
|August 5, 2014||0.9.1|