~ubuntu-branches/ubuntu/saucy/nagios3/saucy-proposed

« back to all changes in this revision

Viewing changes to html/docs/customobjectvars.html

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2009-08-16 14:14:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090816141423-efjzq1r3jekwd7l7
Tags: 3.2.0-1
* New upstream release (Closes: #542957)
  - Timeperiods should work as expected now (Closes: #539882)
  - Recovery notifications fixed (Closes: #543657)
* Update standards version 
  - Add README.source
* Manpage errors fixed (Closes: #540554)
* Split up the webfrontend into its own package (Closes: #479338, #485466)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
 
 
3
 
<html>
4
 
<head>
5
 
<title>Custom Object Variables</title>
6
 
 
7
 
<STYLE type="text/css">
8
 
<!--
9
 
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
10
 
        .PageTitle { font-family: verdana,arial,serif; font-size: 16pt; font-weight: bold; }
11
 
-->      
12
 
</STYLE>
13
 
 
14
 
</head>
15
 
 
16
 
<body bgcolor="#FFFFFF" text="black" class="Default">
17
 
 
18
 
<div align="center">
19
 
<img src="images/nagios.jpg" border="0" alt="Nagios" title="Nagios">
20
 
<h1 class="PageTitle">Custom Object Variables</h1>
21
 
</div>
22
 
 
23
 
<hr>
24
 
 
25
 
<p>
26
 
<img src="images/upto.gif" border="0" align="middle" alt="Up To" title="Up To">Up To: <a href="toc.html">Contents</a><br>
27
 
<img src="images/seealso.gif" border="0" align="middle" alt="See Also" title="See Also"> See Also: <a href="objectdefinitions.html">Object Configuration</a>, <a href="objectinheritance.html">Object Inheritance</a>, <a href="macros.html">Macros</a>
28
 
</p>
29
 
 
30
 
<p>
31
 
<strong><u>Introduction</u></strong>
32
 
</p>
33
 
 
34
 
<p>
35
 
Users often request that new variables be added to host, service, and contact definitions.  These include variables for SNMP community, MAC address, AIM username, Skype number, and street address.  The list is endless.  The problem that I see with doing this is that it makes Nagios less generic and more infrastructure-specific.  Nagios was intended to be flexible, which meant things needed to be designed in a generic manner.  Host definitions in Nagios, for example, have a generic "address" variable that can contain anything from an IP address to human-readable driving directions - whatever is appropriate for the user's setup.  
36
 
</p>
37
 
<p>
38
 
Still, there needs to be a method for admins to store information about their infrastructure components in their Nagios configuration without imposing a set of specific variables on others.  Nagios attempts to solve this problem by allowing users to define custom variables in their object definitions.  Custom variables allow users to define additional properties in their host, service, and contact definitions, and use their values in notifications, event handlers, and host and service checks.
39
 
</p>
40
 
 
41
 
<p>
42
 
<strong><u>Custom Variable Basics</u></strong>
43
 
</p>
44
 
 
45
 
<p>
46
 
There are a few important things that you should note about custom variables:
47
 
</p>
48
 
 
49
 
<ul>
50
 
<li>Custom variable names must begin with an underscore (_) to prevent name collision with standard variables
51
 
<li>Custom variable names are case-insensitive
52
 
<li>Custom variables are <a href="objectinheritance.html">inherited</a> from object templates like normal variables
53
 
<li>Scripts can reference custom variable values with <a href="macros.html">macros and environment variables</a>
54
 
</ul>
55
 
 
56
 
<p>
57
 
<strong><u>Examples</u></strong>
58
 
</p>
59
 
 
60
 
<p>
61
 
Here's an example of how custom variables can be defined in different types of object definitions:
62
 
</p>
63
 
 
64
 
<pre>
65
 
define host{
66
 
        host_name       linuxserver
67
 
        _mac_address    00:06:5B:A6:AD:AA       ; <-- Custom MAC_ADDRESS variable
68
 
        _rack_number    R32             ; <-- Custom RACK_NUMBER variable
69
 
        ...
70
 
        }
71
 
 
72
 
define service{
73
 
        host_name       linuxserver
74
 
        description     Memory Usage
75
 
        _SNMP_community public          ; <-- Custom SNMP_COMMUNITY variable
76
 
        _TechContact    Jane Doe                ; <-- Custom TECHCONTACT variable
77
 
        ....
78
 
        }
79
 
 
80
 
define contact{
81
 
        contact_name    john
82
 
        _AIM_username   john16          ; <-- Custom AIM_USERNAME variable
83
 
        _YahooID        john32                  ; <-- Custom YAHOOID variable
84
 
        ...
85
 
        }
86
 
</pre>
87
 
 
88
 
<p>
89
 
<strong><u>Custom Variables As Macros</u></strong>
90
 
</p>
91
 
 
92
 
<p>
93
 
Custom variable values can be referenced in scripts and executables that Nagios runs for checks, notifications, etc. by using <a href="macros.html">macros</a> or environment variables.
94
 
</p>
95
 
<p>
96
 
In order to prevent name collision among custom variables from different object types, Nagios prepends "_HOST", "_SERVICE", or "_CONTACT" to the beginning of custom host, service, or contact variables, respectively, in macro and environment variable names.  The table below shows the corresponding macro and environment variable names for the custom variables that were defined in the example above.
97
 
</p>
98
 
 
99
 
<p>
100
 
<table border="1" class="Default">
101
 
<tr><th>Object Type</th><th>Variable Name</th><th>Macro Name</th><th>Environment Variable</th></tr>
102
 
<tr><td>Host</td><td>MAC_ADDRESS</td><td>$_HOSTMAC_ADDRESS$</td><td>NAGIOS__HOSTMAC_ADDRESS</td></tr>
103
 
<tr><td>Host</td><td>RACK_NUMBER</td><td>$_HOSTRACK_NUMBER$</td><td>NAGIOS__HOSTRACK_NUMBER</td></tr>
104
 
<tr><td>Service</td><td>SNMP_COMMUNITY</td><td>$_SERVICESNMP_COMMUNITY$</td><td>NAGIOS__SERVICESNMP_COMMUNITY</td></tr>
105
 
<tr><td>Service</td><td>TECHCONTACT</td><td>$_SERVICETECHCONTACT$</td><td>NAGIOS__SERVICETECHCONTACT</td></tr>
106
 
<tr><td>Contact</td><td>AIM_USERNAME</td><td>$_CONTACTAIM_USERNAME$</td><td>NAGIOS__CONTACTAIM_USERNAME</td></tr>
107
 
<tr><td>Contact</td><td>YAHOOID</td><td>$_CONTACTYAHOOID$</td><td>NAGIOS__CONTACTYAHOOID</td></tr>
108
 
</table>
109
 
</p>
110
 
 
111
 
<p>
112
 
<strong><u>Custom Variables And Inheritance</u></strong>
113
 
</p>
114
 
 
115
 
<p>
116
 
Custom object variables are <a href="objectinheritance.html">inherited</a> just like standard host, service, or contact variables.
117
 
</p>
118
 
 
119
 
 
120
 
<hr>
121
 
 
122
 
</body>
123
 
</html>
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
 
 
3
 
 
4
 
 
5
<html>
 
6
 
 
7
<head>
 
8
 
 
9
<title>Custom Object Variables</title>
 
10
 
 
11
 
 
12
 
 
13
<STYLE type="text/css">
 
14
 
 
15
<!--
 
16
 
 
17
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
 
18
 
 
19
        .PageTitle { font-family: verdana,arial,serif; font-size: 16pt; font-weight: bold; }
 
20
 
 
21
-->      
 
22
 
 
23
</STYLE>
 
24
 
 
25
 
 
26
 
 
27
</head>
 
28
 
 
29
 
 
30
 
 
31
<body bgcolor="#FFFFFF" text="black" class="Default">
 
32
 
 
33
 
 
34
 
 
35
<div align="center">
 
36
 
 
37
<img src="images/nagios.jpg" border="0" alt="Nagios" title="Nagios">
 
38
 
 
39
<h1 class="PageTitle">Custom Object Variables</h1>
 
40
 
 
41
</div>
 
42
 
 
43
 
 
44
 
 
45
<hr>
 
46
 
 
47
 
 
48
 
 
49
<p>
 
50
 
 
51
<img src="images/upto.gif" border="0" align="middle" alt="Up To" title="Up To">Up To: <a href="toc.html">Contents</a><br>
 
52
 
 
53
<img src="images/seealso.gif" border="0" align="middle" alt="See Also" title="See Also"> See Also: <a href="objectdefinitions.html">Object Configuration</a>, <a href="objectinheritance.html">Object Inheritance</a>, <a href="macros.html">Macros</a>
 
54
 
 
55
</p>
 
56
 
 
57
 
 
58
 
 
59
<p>
 
60
 
 
61
<strong><u>Introduction</u></strong>
 
62
 
 
63
</p>
 
64
 
 
65
 
 
66
 
 
67
<p>
 
68
 
 
69
Users often request that new variables be added to host, service, and contact definitions.  These include variables for SNMP community, MAC address, AIM username, Skype number, and street address.  The list is endless.  The problem that I see with doing this is that it makes Nagios less generic and more infrastructure-specific.  Nagios was intended to be flexible, which meant things needed to be designed in a generic manner.  Host definitions in Nagios, for example, have a generic "address" variable that can contain anything from an IP address to human-readable driving directions - whatever is appropriate for the user's setup.  
 
70
 
 
71
</p>
 
72
 
 
73
<p>
 
74
 
 
75
Still, there needs to be a method for admins to store information about their infrastructure components in their Nagios configuration without imposing a set of specific variables on others.  Nagios attempts to solve this problem by allowing users to define custom variables in their object definitions.  Custom variables allow users to define additional properties in their host, service, and contact definitions, and use their values in notifications, event handlers, and host and service checks.
 
76
 
 
77
</p>
 
78
 
 
79
 
 
80
 
 
81
<p>
 
82
 
 
83
<strong><u>Custom Variable Basics</u></strong>
 
84
 
 
85
</p>
 
86
 
 
87
 
 
88
 
 
89
<p>
 
90
 
 
91
There are a few important things that you should note about custom variables:
 
92
 
 
93
</p>
 
94
 
 
95
 
 
96
 
 
97
<ul>
 
98
 
 
99
<li>Custom variable names must begin with an underscore (_) to prevent name collision with standard variables
 
100
 
 
101
<li>Custom variable names are case-insensitive
 
102
 
 
103
<li>Custom variables are <a href="objectinheritance.html">inherited</a> from object templates like normal variables
 
104
 
 
105
<li>Scripts can reference custom variable values with <a href="macros.html">macros and environment variables</a>
 
106
 
 
107
</ul>
 
108
 
 
109
 
 
110
 
 
111
<p>
 
112
 
 
113
<strong><u>Examples</u></strong>
 
114
 
 
115
</p>
 
116
 
 
117
 
 
118
 
 
119
<p>
 
120
 
 
121
Here's an example of how custom variables can be defined in different types of object definitions:
 
122
 
 
123
</p>
 
124
 
 
125
 
 
126
 
 
127
<pre>
 
128
 
 
129
define host{
 
130
 
 
131
        host_name       linuxserver
 
132
 
 
133
        _mac_address    00:06:5B:A6:AD:AA       ; <-- Custom MAC_ADDRESS variable
 
134
 
 
135
        _rack_number    R32             ; <-- Custom RACK_NUMBER variable
 
136
 
 
137
        ...
 
138
 
 
139
        }
 
140
 
 
141
 
 
142
 
 
143
define service{
 
144
 
 
145
        host_name       linuxserver
 
146
 
 
147
        description     Memory Usage
 
148
 
 
149
        _SNMP_community public          ; <-- Custom SNMP_COMMUNITY variable
 
150
 
 
151
        _TechContact    Jane Doe                ; <-- Custom TECHCONTACT variable
 
152
 
 
153
        ....
 
154
 
 
155
        }
 
156
 
 
157
 
 
158
 
 
159
define contact{
 
160
 
 
161
        contact_name    john
 
162
 
 
163
        _AIM_username   john16          ; <-- Custom AIM_USERNAME variable
 
164
 
 
165
        _YahooID        john32                  ; <-- Custom YAHOOID variable
 
166
 
 
167
        ...
 
168
 
 
169
        }
 
170
 
 
171
</pre>
 
172
 
 
173
 
 
174
 
 
175
<p>
 
176
 
 
177
<strong><u>Custom Variables As Macros</u></strong>
 
178
 
 
179
</p>
 
180
 
 
181
 
 
182
 
 
183
<p>
 
184
 
 
185
Custom variable values can be referenced in scripts and executables that Nagios runs for checks, notifications, etc. by using <a href="macros.html">macros</a> or environment variables.
 
186
 
 
187
</p>
 
188
 
 
189
<p>
 
190
 
 
191
In order to prevent name collision among custom variables from different object types, Nagios prepends "_HOST", "_SERVICE", or "_CONTACT" to the beginning of custom host, service, or contact variables, respectively, in macro and environment variable names.  The table below shows the corresponding macro and environment variable names for the custom variables that were defined in the example above.
 
192
 
 
193
</p>
 
194
 
 
195
 
 
196
 
 
197
<p>
 
198
 
 
199
<table border="1" class="Default">
 
200
 
 
201
<tr><th>Object Type</th><th>Variable Name</th><th>Macro Name</th><th>Environment Variable</th></tr>
 
202
 
 
203
<tr><td>Host</td><td>MAC_ADDRESS</td><td>$_HOSTMAC_ADDRESS$</td><td>NAGIOS__HOSTMAC_ADDRESS</td></tr>
 
204
 
 
205
<tr><td>Host</td><td>RACK_NUMBER</td><td>$_HOSTRACK_NUMBER$</td><td>NAGIOS__HOSTRACK_NUMBER</td></tr>
 
206
 
 
207
<tr><td>Service</td><td>SNMP_COMMUNITY</td><td>$_SERVICESNMP_COMMUNITY$</td><td>NAGIOS__SERVICESNMP_COMMUNITY</td></tr>
 
208
 
 
209
<tr><td>Service</td><td>TECHCONTACT</td><td>$_SERVICETECHCONTACT$</td><td>NAGIOS__SERVICETECHCONTACT</td></tr>
 
210
 
 
211
<tr><td>Contact</td><td>AIM_USERNAME</td><td>$_CONTACTAIM_USERNAME$</td><td>NAGIOS__CONTACTAIM_USERNAME</td></tr>
 
212
 
 
213
<tr><td>Contact</td><td>YAHOOID</td><td>$_CONTACTYAHOOID$</td><td>NAGIOS__CONTACTYAHOOID</td></tr>
 
214
 
 
215
</table>
 
216
 
 
217
</p>
 
218
 
 
219
 
 
220
 
 
221
<p>
 
222
 
 
223
<strong><u>Custom Variables And Inheritance</u></strong>
 
224
 
 
225
</p>
 
226
 
 
227
 
 
228
 
 
229
<p>
 
230
 
 
231
Custom object variables are <a href="objectinheritance.html">inherited</a> just like standard host, service, or contact variables.
 
232
 
 
233
</p>
 
234
 
 
235
 
 
236
 
 
237
 
 
238
 
 
239
<hr>
 
240
 
 
241
 
 
242
 
 
243
</body>
 
244
 
 
245
</html>
 
246