一、配置文件创建文件夹

1、编辑/etc/salt/master

file_roots:
  base:
    - /srv/salt/base/

2、创建

mkdir -p /srv/salt/base

二、状态文件和客户端配置文件

1、创建状态文件

[root@saltstack zabbix]# cat zabbix.sls
zabbix_file:
   file.managed:
    - name: /usr/local/src/zabbix-2.4.7.tar.gz
    - source: salt://zabbix/file/zabbix-2.4.7.tar.gz

zabbix_sh:
   file.managed:
    - name: /usr/local/src/zabbix_agent.sh
    - source: salt://zabbix/file/zabbix_agent.sh
   cmd.run:
    - name: cd /usr/local/src && sh zabbix_agent.sh

zabbix-config:
  file.managed:
    - name: /etc/zabbix/zabbix_agentd.conf
    - source: salt://zabbix/file/zabbix_agentd.conf
    - template: jinja
    - defaults:
      IPV4: {{ grains['ipv4'][0] }}

2、创建客户端配置文件(可以从安装好的配置文件稍作更改)

  1 [root@saltstack file]# cat zabbix_agentd.conf
  2 # This is a config file for the Zabbix agent daemon (Unix)
  3 # To get more information about Zabbix, visit http://www.zabbix.com
  4 
  5 ############ GENERAL PARAMETERS #################
  6 
  7 ### Option: PidFile
  8 #    Name of PID file.
  9 #
 10 # Mandatory: no
 11 # Default:
 12 # PidFile=/tmp/zabbix_agentd.pid
 13 
 14 ### Option: LogFile
 15 #    Name of log file.
 16 #    If not set, syslog is used.
 17 #
 18 # Mandatory: no
 19 # Default:
 20 # LogFile=
 21 
 22 LogFile=/var/log/zabbix/zabbix_agentd.log
 23 
 24 ### Option: LogFileSize
 25 #    Maximum size of log file in MB.
 26 #    0 - disable automatic log rotation.
 27 #
 28 # Mandatory: no
 29 # Range: 0-1024
 30 # Default:
 31 # LogFileSize=1
 32  33 ### Option: DebugLevel
 34 #    Specifies debug level
 35 #    0 - basic information about starting and stopping of Zabbix processes
 36 #    1 - critical information
 37 #    2 - error information
 38 #    3 - warnings
 39 #    4 - for debugging (produces lots of information)
 40 #
 41 # Mandatory: no
 42 # Range: 0-4
 43 # Default:
 44 # DebugLevel=3
 45 
 46 ### Option: SourceIP
 47 #    Source IP address for outgoing connections.
 48 #
 49 # Mandatory: no
 50 # Default:
 51 # SourceIP=
 52 
 53 ### Option: EnableRemoteCommands
 54 #    Whether remote commands from Zabbix server are allowed.
 55 #    0 - not allowed
 56 #    1 - allowed
 57 #
 58 # Mandatory: no
 59 # Default:
 60 # EnableRemoteCommands=0
 61 EnableRemoteCommands=1
 62 
 63 ### Option: LogRemoteCommands
 64 #    Enable logging of executed shell commands as warnings.
 65 #    0 - disabled
 66 #    1 - enabled
 67 #
 68 # Mandatory: no
 69 # Default:
 70 # LogRemoteCommands=0
 71 
 72 ##### Passive checks related
 73 
 74 ### Option: Server
 75 #    List of comma delimited IP addresses (or hostnames) of Zabbix servers.
 76 #    Incoming connections will be accepted only from the hosts listed here.
 77 #    If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
 78 #
 79 # Mandatory: no
 80 # Default:
 81 # Server=
 82 
 83 Server=192.168.0.188
 84 
 85 ### Option: ListenPort
 86 #    Agent will listen on this port for connections from the server.
 87 #
 88 # Mandatory: no
 89 # Range: 1024-32767
 90 # Default:
 91 # ListenPort=10050
 92 
 93 ### Option: ListenIP
 94 #    List of comma delimited IP addresses that the agent should listen on.
 95 #    First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks.
 96 #
 97 # Mandatory: no
 98 # Default:
 99 # ListenIP=0.0.0.0
100 ListenIP={{ IPV4 }}
101 
102 ### Option: StartAgents
103 #    Number of pre-forked instances of zabbix_agentd that process passive checks.
104 #    If set to 0, disables passive checks and the agent will not listen on any TCP port.
105 #
106 # Mandatory: no
107 # Range: 0-100
108 # Default:
109 # StartAgents=3
110 
111 ##### Active checks related
112 
113 ### Option: ServerActive
114 #    List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks.
115 #    If port is not specified, default port is used.
116 #    IPv6 addresses must be enclosed in square brackets if port for that host is specified.
117 #    If port is not specified, square brackets for IPv6 addresses are optional.
118 #    If this parameter is not specified, active checks are disabled.
119 #    Example: ServerActive=172.168.20.201:10051:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
120 #
121 # Mandatory: no
122 # Default:
123 # ServerActive=
124 
125 ServerActive=192.168.0.188:10051
126 
127 ### Option: Hostname
128 #    Unique, case sensitive hostname.
129 #    Required for active checks and must match hostname as configured on the server.
130 #    Value is acquired from HostnameItem if undefined.
131 #
132 # Mandatory: no
133 # Default:
134 # Hostname=
135 
136 Hostname={{ IPV4 }}
137 
138 ### Option: HostnameItem
139 #    Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
140 #    Does not support UserParameters or aliases.
141 #
142 # Mandatory: no
143 # Default:
144 # HostnameItem=system.hostname
145 
146 ### Option: HostMetadata
147 #    Optional parameter that defines host metadata.
148 #    Host metadata is used at host auto-registration process.
149 #    An agent will issue an error and not start if the value is over limit of 255 characters.
150 #    If not defined, value will be acquired from HostMetadataItem.
151 #
152 # Mandatory: no
153 # Range: 0-255 characters
154 # Default:
155 # HostMetadata=
156 
157 ### Option: HostMetadataItem
158 #    Optional parameter that defines an item used for getting host metadata.
159 #    Host metadata is used at host auto-registration process.
160 #    During an auto-registration request an agent will log a warning message if
161 #    the value returned by specified item is over limit of 255 characters.
162 #    This option is only used when HostMetadata is not defined.
163 #
164 # Mandatory: no
165 # Default:
166 # HostMetadataItem=
167 
168 ### Option: RefreshActiveChecks
169 #    How often list of active checks is refreshed, in seconds.
170 #
171 # Mandatory: no
172 # Range: 60-3600
173 # Default:
174 # RefreshActiveChecks=120
175 
176 ### Option: BufferSend
177 #    Do not keep data longer than N seconds in buffer.
178 #
179 # Mandatory: no
180 # Range: 1-3600
181 # Default:
182 # BufferSend=5
183 
184 ### Option: BufferSize
185 #    Maximum number of values in a memory buffer. The agent will send
186 #    all collected data to Zabbix Server or Proxy if the buffer is full.
187 #
188 # Mandatory: no
189 # Range: 2-65535
190 # Default:
191 # BufferSize=100
192 
193 ### Option: MaxLinesPerSecond
194 #    Maximum number of new lines the agent will send per second to Zabbix Server
195 #    or Proxy processing 'log' and 'logrt' active checks.
196 #    The provided value will be overridden by the parameter 'maxlines',
197 #    provided in 'log' or 'logrt' item keys.
198 #
199 # Mandatory: no
200 # Range: 1-1000
201 # Default:
202 # MaxLinesPerSecond=100
203 
204 ############ ADVANCED PARAMETERS #################
205 
206 ### Option: Alias
207 #    Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one.
208 #    Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed.
209 #    Different Alias keys may reference the same item key.
210 #    For example, to retrieve the ID of user 'zabbix':
211 #    Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1]
212 #    Now shorthand key zabbix.userid may be used to retrieve data.
213 #    Aliases can be used in HostMetadataItem but not in HostnameItem parameters.
214 #
215 # Mandatory: no
216 # Range:
217 # Default:
218 
219 ### Option: Timeout
220 #    Spend no more than Timeout seconds on processing
221 #
222 # Mandatory: no
223 # Range: 1-30
224 # Default:
225 # Timeout=3
226 
227 ### Option: AllowRoot
228 #    Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent
229 #    will try to switch to the user specified by the User configuration option instead.
230 #    Has no effect if started under a regular user.
231 #    0 - do not allow
232 #    1 - allow
233 #
234 # Mandatory: no
235 # Default:
236 # AllowRoot=0
237 
238 ### Option: User
239 #    Drop privileges to a specific, existing user on the system.
240 #    Only has effect if run as 'root' and AllowRoot is disabled.
241 #
242 # Mandatory: no
243 # Default:
244 # User=zabbix
245 
246 ### Option: Include
247 #    You may include individual files or all files in a directory in the configuration file.
248 #    Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
249 #
250 # Mandatory: no
251 # Default:
252 # Include=
253 
254 # Include=/usr/local/etc/zabbix_agentd.userparams.conf
255 # Include=/usr/local/etc/zabbix_agentd.conf.d/
256 # Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
257 
258 ####### USER-DEFINED MONITORED PARAMETERS #######
259 
260 ### Option: UnsafeUserParameters
261 #    Allow all characters to be passed in arguments to user-defined parameters.
262 #    0 - do not allow
263 #    1 - allow
264 #
265 # Mandatory: no
266 # Range: 0-1
267 # Default:
268 UnsafeUserParameters=1
269 
270 
271 ### Option: UserParameter
272 #    User-defined parameter to monitor. There can be several user-defined parameters.
273 #    Format: UserParameter=<key>,<shell command>
274 #    See 'zabbix_agentd' directory for examples.
275 #
276 # Mandatory: no
277 # Default:
278 # UserParameter=
279 
280 
281 ####### LOADABLE MODULES #######
282 
283 ### Option: LoadModulePath
284 #    Full path to location of agent modules.
285 #    Default depends on compilation options.
286 #
287 # Mandatory: no
288 # Default:
289 # LoadModulePath=${libdir}/modules
290 
291 ### Option: LoadModule
292 #    Module to load at agent startup. Modules are used to extend functionality of the agent.
293 #    Format: LoadModule=<module.so>
294 #    The modules must be located in directory specified by LoadModulePath.
295 #    It is allowed to include multiple LoadModule parameters.
296 #
297 # Mandatory: no
298 # Default:
299 # LoadModule=
zabbix_agentd.conf

相关文章: