1PYNAG(1) pynag PYNAG(1)
2
3
4
6 pynag - command line front for manipulating nagios configuration
7
9 pynag <sub-command> [options] [arguments]
10
12 pynag is a command-line utility that can be used to view or change cur‐
13 rent nagios configuration.
14
16 list
17 print to screen nagios configuration objects as specified by a WHERE
18 clause
19 pynag list [attribute1] [attribute2] [WHERE ...]
20
21
22 update
23 modify specific attributes of nagios objects as specified by a WHERE
24 and SET clause
25 pynag update set attr1=value WHERE attr=value and attr=value
26
27
28 delete
29 Delete objects from nagios configuration as specified by a WHERE
30 clause
31 pynag delete delete <WHERE ...>
32
33
34 add
35 Add a new object definition
36 pynag add <object_type> <attr1=value1> [attr2=value2]
37
38
39 copy
40 Copy objects, specifiying which attributes to change
41 pynag copy <WHERE ...> <SET attr1=value1 [attr2=value2] ...>
42
43
44 execute
45 Executes the currently configured check command for a host or a ser‐
46 vice
47 pynag execute <host_name> [service_description]
48
49
50 config
51 modify values in main nagios configuration file (nagios.cfg)
52 pynag config [--set <attribute=value>] [--old_value=attribute]
53 pynag config [--append <attribute=value>] [--old_value=attribute]
54 pynag config [--remove <attribute>] [--old_value=attribute]
55 pynag config [--get <attribute>]
56
57
59 Some Subcommands use WHERE statements to filter which objects to work
60 with. Where has certain similarity with SQL syntax.
61
62 Syntax:
63 WHERE <attr=value> [AND attr=value] [OR attr=value]
64 [another where statement]
65
66
67 where "attr" is any nagios attribute (i.e. host_name or ser‐
68 vice_description).
69
70 Example:
71 pynag list WHERE host_name=localhost and object_type=service
72 pynag list WHERE object_type=host or object_type=service
73
74
75 Any search attributes have the same syntax as the pynag filter. For
76 example these work just fine:
77 pynag list WHERE host_name__contains=production
78 pynag list WHERE host_name__startswith=prod
79 pynag list WHERE host_name__notcontains=test
80 pynag list host_name address WHERE address__exists=True
81 pynag list host_name WHERE register__isnot=0
82
83
84 The pynag filter supports few parameters that are not just attributes.
85
86 Example:
87
88 · filename -- The filename which the object belongs
89
90 · id -- pynag unique identifier for the object
91
92 · effective_command_line -- command which nagios will execute
93
94 Of course these can be combined with the pynag filter syntax:
95 pynag list where filename__startswith=/etc/nagios/conf.d/
96 pynag list host_name service_description effective_command_line
97
98
99 For detailed description of the filter see pydoc for
100 pynag.Model.ObjectDefintion.filter()
101
103 Subcommands that use SET statements (like update or copy) use them a
104 list of attributes change for a specific object.
105
106 Syntax:
107 SET <attr1=value1> [attr2=value2] [...]
108
109
110 Example:
111 pynag update SET address=127.0.0.1 WHERE host_name=localhost and object_type=host
112
113
115 List all services that have myhost as a host_name
116 pynag list host_name service_description WHERE host_name=myhost and object_type=service
117
118
119 Set check_period to 24x7 on all services that belong to host myhost
120 pynag update set check_period=24x7 WHERE host_name=myhost
121
122
123 list examples
124 pynag list host_name address WHERE object_type=host
125 pynag list host_name service_description WHERE host_name=examplehost and object_type=service
126
127
128 update examples
129 pynag update SET host_name=newhostname WHERE host_name=oldhostname
130 pynag update SET address=127.0.0.1 WHERE host_name='examplehost.example.com' and object_type=host
131
132
133 copy examples
134 pynag copy SET host_name=newhostname WHERE host_name=oldhostname
135 pynag copy SET address=127.0.0.1 WHERE host_name='examplehost.example.com' and object_type=host
136
137
138 add examples
139 pynag add host host_name=examplehost use=generic-host address=127.0.0.1
140 pynag add service service_description="Test Service" use="check_nrpe" host_name="localhost"
141
142
143 delete examples
144 pynag delete where object_type=service and host_name='mydeprecated_host'
145 pynag delete where filename__startswith='/etc/nagios/myoldhosts'
146
147
148 execute examples
149 pynag execute localhost
150 pynag execute localhost "Disk Space
151
152
154 See http://github.com/pynag/pynag.git for more information.
155
157 Pall Sigurdsson and Tomas Edwardsson
158
160 2014, Pall Sigurdsson and Tomas Edwardsson
161
162
163
164
1650.9.1 August 05, 2014 PYNAG(1)