zoukankan      html  css  js  c++  java
  • Zabbix 安装

    安装文档

     1 rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
     2 cd /etc/yum.repos.d/
     3 ls
     4 vim zabbix.repo 
     5 vi zabbix.repo
     6 yum install zabbix-server-mysql zabbix-web-mysql -y
     7 cd
     8 yum install mariadb-server -y
     9 systemctl start mariadb
    10 systemctl enable mariadb
    11 netstat -lntup
    12 mysql_secure_installation 
    13 mysql
    14 mysql -uzabbix -pzabbix zabbix
    15 rpm -ql zabbix-server-mysql
    16 cd /usr/share/doc/zabbix-server-mysql-3.0.20/
    17 ls
    18 zcat create.sql.gz 
    19 zcat create.sql.gz |mysql -uzabbix -pzabbix zabbix
    20 mysql -uzabbix -p123456 zabbix -e "show tables;"
    21 vi /etc/zabbix/zabbix_server.conf 
    22 systemctl start zabbix-server
    23 systemctl status zabbix-server
    24 systemctl start httpd
    25 systemctl enable httpd
    26 vi /etc/httpd/conf.d/zabbix.conf 
    27 systemctl restart httpd

    在数据库中进行配置

    mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
    
    mysql -e "grant all on zabbix.* to zabbix@localhost identified by 'zabbix';"

    #部分内容调整
    sed -i 's## php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g' /etc/httpd/conf.d/zabbix.conf
    
    root@db01 create]# sed -i 's## php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g' /etc/httpd/conf.d/zabbix.conf
    
    
    root@db01 create]# grep Shanghai /etc/httpd/conf.d/zabbix.conf
            php_value date.timezone Asia/Shanghai
    
            
    1  初始化zabbix
    
    root@db01 create]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.oldboy.ori
    
    root@db01 create]# sed -i 's@# DBPassword=@DBPassword=zabbix@g' /etc/zabbix/zabbix_server.conf
    
    [root@db01 create]# grep DBPassword= /etc/zabbix/zabbix_server.conf
    
    
    [root@db01 create]# sed -i 's@# DBHost=localhost@DBHost=localhost@g' /etc/zabbix/zabbix_server.conf

    zabbix.repo有部分内容要修改

    请参照

     1 [zabbix]
     2 name=Zabbix Official Repository - $basearch
     3 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/
     4 enabled=1
     5 gpgcheck=1
     6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
     7 
     8 [zabbix-non-supported]
     9 name=Zabbix Official Repository non-supported - $basearch 
    10 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/x86_64/
    11 enabled=1
    12 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
    13 gpgcheck=1
    View Code

    修改完毕的配置文件

      1 # This is a configuration file for Zabbix server daemon
      2 # To get more information about Zabbix, visit http://www.zabbix.com
      3 
      4 ############ GENERAL PARAMETERS #################
      5 
      6 ### Option: ListenPort
      7 #    Listen port for trapper.
      8 #
      9 # Mandatory: no
     10 # Range: 1024-32767
     11 # Default:
     12 # ListenPort=10051
     13 
     14 ### Option: SourceIP
     15 #    Source IP address for outgoing connections.
     16 #
     17 # Mandatory: no
     18 # Default:
     19 # SourceIP=
     20 
     21 ### Option: LogType
     22 #    Specifies where log messages are written to:
     23 #        system  - syslog
     24 #        file    - file specified with LogFile parameter
     25 #        console - standard output
     26 #
     27 # Mandatory: no
     28 # Default:
     29 # LogType=file
     30 
     31 ### Option: LogFile
     32 #    Log file name for LogType 'file' parameter.
     33 #
     34 # Mandatory: no
     35 # Default:
     36 # LogFile=
     37 
     38 LogFile=/var/log/zabbix/zabbix_server.log
     39 
     40 ### Option: LogFileSize
     41 #    Maximum size of log file in MB.
     42 #    0 - disable automatic log rotation.
     43 #
     44 # Mandatory: no
     45 # Range: 0-1024
     46 # Default:
     47 # LogFileSize=1
     48 
     49 LogFileSize=0
     50 
     51 ### Option: DebugLevel
     52 #    Specifies debug level:
     53 #    0 - basic information about starting and stopping of Zabbix processes
     54 #    1 - critical information
     55 #    2 - error information
     56 #    3 - warnings
     57 #    4 - for debugging (produces lots of information)
     58 #    5 - extended debugging (produces even more information)
     59 #
     60 # Mandatory: no
     61 # Range: 0-5
     62 # Default:
     63 # DebugLevel=3
     64 
     65 ### Option: PidFile
     66 #    Name of PID file.
     67 #
     68 # Mandatory: no
     69 # Default:
     70 # PidFile=/tmp/zabbix_server.pid
     71 
     72 PidFile=/var/run/zabbix/zabbix_server.pid
     73 
     74 ### Option: DBHost
     75 #    Database host name.
     76 #    If set to localhost, socket is used for MySQL.
     77 #    If set to empty string, socket is used for PostgreSQL.
     78 #
     79 # Mandatory: no
     80 # Default:
     81 DBHost=localhost
     82 
     83 ### Option: DBName
     84 #    Database name.
     85 #    For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
     86 #
     87 # Mandatory: yes
     88 # Default:
     89 # DBName=
     90 
     91 DBName=zabbix
     92 
     93 ### Option: DBSchema
     94 #    Schema name. Used for IBM DB2 and PostgreSQL.
     95 #
     96 # Mandatory: no
     97 # Default:
     98 # DBSchema=
     99 
    100 ### Option: DBUser
    101 #    Database user. Ignored for SQLite.
    102 #
    103 # Mandatory: no
    104 # Default:
    105 # DBUser=
    106 
    107 DBUser=zabbix
    108 
    109 ### Option: DBPassword
    110 #    Database password. Ignored for SQLite.
    111 #    Comment this line if no password is used.
    112 #
    113 # Mandatory: no
    114 # Default:
    115 DBPassword=zabbix
    116 
    117 ### Option: DBSocket
    118 #    Path to MySQL socket.
    119 #
    120 # Mandatory: no
    121 # Default:
    122 # DBSocket=/tmp/mysql.sock
    123 
    124 ### Option: DBPort
    125 #    Database port when not using local socket. Ignored for SQLite.
    126 #
    127 # Mandatory: no
    128 # Range: 1024-65535
    129 # Default (for MySQL):
    130 # DBPort=3306
    131 
    132 ############ ADVANCED PARAMETERS ################
    133 
    134 ### Option: StartPollers
    135 #    Number of pre-forked instances of pollers.
    136 #
    137 # Mandatory: no
    138 # Range: 0-1000
    139 # Default:
    140 # StartPollers=5
    141 
    142 ### Option: StartIPMIPollers
    143 #    Number of pre-forked instances of IPMI pollers.
    144 #
    145 # Mandatory: no
    146 # Range: 0-1000
    147 # Default:
    148 # StartIPMIPollers=0
    149 
    150 ### Option: StartPollersUnreachable
    151 #    Number of pre-forked instances of pollers for unreachable hosts (including IPMI and Java).
    152 #    At least one poller for unreachable hosts must be running if regular, IPMI or Java pollers
    153 #    are started.
    154 #
    155 # Mandatory: no
    156 # Range: 0-1000
    157 # Default:
    158 # StartPollersUnreachable=1
    159 
    160 ### Option: StartTrappers
    161 #    Number of pre-forked instances of trappers.
    162 #    Trappers accept incoming connections from Zabbix sender, active agents and active proxies.
    163 #    At least one trapper process must be running to display server availability and view queue
    164 #    in the frontend.
    165 #
    166 # Mandatory: no
    167 # Range: 0-1000
    168 # Default:
    169 # StartTrappers=5
    170 
    171 ### Option: StartPingers
    172 #    Number of pre-forked instances of ICMP pingers.
    173 #
    174 # Mandatory: no
    175 # Range: 0-1000
    176 # Default:
    177 # StartPingers=1
    178 
    179 ### Option: StartDiscoverers
    180 #    Number of pre-forked instances of discoverers.
    181 #
    182 # Mandatory: no
    183 # Range: 0-250
    184 # Default:
    185 # StartDiscoverers=1
    186 
    187 ### Option: StartHTTPPollers
    188 #    Number of pre-forked instances of HTTP pollers.
    189 #
    190 # Mandatory: no
    191 # Range: 0-1000
    192 # Default:
    193 # StartHTTPPollers=1
    194 
    195 ### Option: StartTimers
    196 #    Number of pre-forked instances of timers.
    197 #    Timers process time-based trigger functions and maintenance periods.
    198 #    Only the first timer process handles the maintenance periods.
    199 #
    200 # Mandatory: no
    201 # Range: 1-1000
    202 # Default:
    203 # StartTimers=1
    204 
    205 ### Option: StartEscalators
    206 #    Number of pre-forked instances of escalators.
    207 #
    208 # Mandatory: no
    209 # Range: 0-100
    210 # Default:
    211 # StartEscalators=1
    212 
    213 ### Option: JavaGateway
    214 #    IP address (or hostname) of Zabbix Java gateway.
    215 #    Only required if Java pollers are started.
    216 #
    217 # Mandatory: no
    218 # Default:
    219 # JavaGateway=
    220 
    221 ### Option: JavaGatewayPort
    222 #    Port that Zabbix Java gateway listens on.
    223 #
    224 # Mandatory: no
    225 # Range: 1024-32767
    226 # Default:
    227 # JavaGatewayPort=10052
    228 
    229 ### Option: StartJavaPollers
    230 #    Number of pre-forked instances of Java pollers.
    231 #
    232 # Mandatory: no
    233 # Range: 0-1000
    234 # Default:
    235 # StartJavaPollers=0
    236 
    237 ### Option: StartVMwareCollectors
    238 #    Number of pre-forked vmware collector instances.
    239 #
    240 # Mandatory: no
    241 # Range: 0-250
    242 # Default:
    243 # StartVMwareCollectors=0
    244 
    245 ### Option: VMwareFrequency
    246 #    How often Zabbix will connect to VMware service to obtain a new data.
    247 #
    248 # Mandatory: no
    249 # Range: 10-86400
    250 # Default:
    251 # VMwareFrequency=60
    252 
    253 ### Option: VMwarePerfFrequency
    254 #    How often Zabbix will connect to VMware service to obtain performance data.
    255 #
    256 # Mandatory: no
    257 # Range: 10-86400
    258 # Default:
    259 # VMwarePerfFrequency=60
    260 
    261 ### Option: VMwareCacheSize
    262 #    Size of VMware cache, in bytes.
    263 #    Shared memory size for storing VMware data.
    264 #    Only used if VMware collectors are started.
    265 #
    266 # Mandatory: no
    267 # Range: 256K-2G
    268 # Default:
    269 # VMwareCacheSize=8M
    270 
    271 ### Option: VMwareTimeout
    272 #    Specifies how many seconds vmware collector waits for response from VMware service.
    273 #
    274 # Mandatory: no
    275 # Range: 1-300
    276 # Default:
    277 # VMwareTimeout=10
    278 
    279 ### Option: SNMPTrapperFile
    280 #    Temporary file used for passing data from SNMP trap daemon to the server.
    281 #    Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file.
    282 #
    283 # Mandatory: no
    284 # Default:
    285 # SNMPTrapperFile=/tmp/zabbix_traps.tmp
    286 
    287 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
    288 
    289 ### Option: StartSNMPTrapper
    290 #    If 1, SNMP trapper process is started.
    291 #
    292 # Mandatory: no
    293 # Range: 0-1
    294 # Default:
    295 # StartSNMPTrapper=0
    296 
    297 ### Option: ListenIP
    298 #    List of comma delimited IP addresses that the trapper should listen on.
    299 #    Trapper will listen on all network interfaces if this parameter is missing.
    300 #
    301 # Mandatory: no
    302 # Default:
    303 # ListenIP=0.0.0.0
    304 
    305 # ListenIP=127.0.0.1
    306 
    307 ### Option: HousekeepingFrequency
    308 #    How often Zabbix will perform housekeeping procedure (in hours).
    309 #    Housekeeping is removing outdated information from the database.
    310 #    To prevent Housekeeper from being overloaded, no more than 4 times HousekeepingFrequency
    311 #    hours of outdated information are deleted in one housekeeping cycle, for each item.
    312 #    To lower load on server startup housekeeping is postponed for 30 minutes after server start.
    313 #    With HousekeepingFrequency=0 the housekeeper can be only executed using the runtime control option.
    314 #    In this case the period of outdated information deleted in one housekeeping cycle is 4 times the
    315 #    period since the last housekeeping cycle, but not less than 4 hours and not greater than 4 days.
    316 #
    317 # Mandatory: no
    318 # Range: 0-24
    319 # Default:
    320 # HousekeepingFrequency=1
    321 
    322 ### Option: MaxHousekeeperDelete
    323 #    The table "housekeeper" contains "tasks" for housekeeping procedure in the format:
    324 #    [housekeeperid], [tablename], [field], [value].
    325 #    No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value])
    326 #    will be deleted per one task in one housekeeping cycle.
    327 #    SQLite3 does not use this parameter, deletes all corresponding rows without a limit.
    328 #    If set to 0 then no limit is used at all. In this case you must know what you are doing!
    329 #
    330 # Mandatory: no
    331 # Range: 0-1000000
    332 # Default:
    333 # MaxHousekeeperDelete=5000
    334 
    335 ### Option: SenderFrequency
    336 #    How often Zabbix will try to send unsent alerts (in seconds).
    337 #
    338 # Mandatory: no
    339 # Range: 5-3600
    340 # Default:
    341 # SenderFrequency=30
    342 
    343 ### Option: CacheSize
    344 #    Size of configuration cache, in bytes.
    345 #    Shared memory size for storing host, item and trigger data.
    346 #
    347 # Mandatory: no
    348 # Range: 128K-8G
    349 # Default:
    350 # CacheSize=8M
    351 
    352 ### Option: CacheUpdateFrequency
    353 #    How often Zabbix will perform update of configuration cache, in seconds.
    354 #
    355 # Mandatory: no
    356 # Range: 1-3600
    357 # Default:
    358 # CacheUpdateFrequency=60
    359 
    360 ### Option: StartDBSyncers
    361 #    Number of pre-forked instances of DB Syncers.
    362 #
    363 # Mandatory: no
    364 # Range: 1-100
    365 # Default:
    366 # StartDBSyncers=4
    367 
    368 ### Option: HistoryCacheSize
    369 #    Size of history cache, in bytes.
    370 #    Shared memory size for storing history data.
    371 #
    372 # Mandatory: no
    373 # Range: 128K-2G
    374 # Default:
    375 # HistoryCacheSize=16M
    376 
    377 ### Option: HistoryIndexCacheSize
    378 #    Size of history index cache, in bytes.
    379 #    Shared memory size for indexing history cache.
    380 #
    381 # Mandatory: no
    382 # Range: 128K-2G
    383 # Default:
    384 # HistoryIndexCacheSize=4M
    385 
    386 ### Option: TrendCacheSize
    387 #    Size of trend cache, in bytes.
    388 #    Shared memory size for storing trends data.
    389 #
    390 # Mandatory: no
    391 # Range: 128K-2G
    392 # Default:
    393 # TrendCacheSize=4M
    394 
    395 ### Option: ValueCacheSize
    396 #    Size of history value cache, in bytes.
    397 #    Shared memory size for caching item history data requests.
    398 #    Setting to 0 disables value cache.
    399 #
    400 # Mandatory: no
    401 # Range: 0,128K-64G
    402 # Default:
    403 # ValueCacheSize=8M
    404 
    405 ### Option: Timeout
    406 #    Specifies how long we wait for agent, SNMP device or external check (in seconds).
    407 #
    408 # Mandatory: no
    409 # Range: 1-30
    410 # Default:
    411 # Timeout=3
    412 
    413 Timeout=4
    414 
    415 ### Option: TrapperTimeout
    416 #    Specifies how many seconds trapper may spend processing new data.
    417 #
    418 # Mandatory: no
    419 # Range: 1-300
    420 # Default:
    421 # TrapperTimeout=300
    422 
    423 ### Option: UnreachablePeriod
    424 #    After how many seconds of unreachability treat a host as unavailable.
    425 #
    426 # Mandatory: no
    427 # Range: 1-3600
    428 # Default:
    429 # UnreachablePeriod=45
    430 
    431 ### Option: UnavailableDelay
    432 #    How often host is checked for availability during the unavailability period, in seconds.
    433 #
    434 # Mandatory: no
    435 # Range: 1-3600
    436 # Default:
    437 # UnavailableDelay=60
    438 
    439 ### Option: UnreachableDelay
    440 #    How often host is checked for availability during the unreachability period, in seconds.
    441 #
    442 # Mandatory: no
    443 # Range: 1-3600
    444 # Default:
    445 # UnreachableDelay=15
    446 
    447 ### Option: AlertScriptsPath
    448 #    Full path to location of custom alert scripts.
    449 #    Default depends on compilation options.
    450 #
    451 # Mandatory: no
    452 # Default:
    453 # AlertScriptsPath=${datadir}/zabbix/alertscripts
    454 
    455 AlertScriptsPath=/usr/lib/zabbix/alertscripts
    456 
    457 ### Option: ExternalScripts
    458 #    Full path to location of external scripts.
    459 #    Default depends on compilation options.
    460 #
    461 # Mandatory: no
    462 # Default:
    463 # ExternalScripts=${datadir}/zabbix/externalscripts
    464 
    465 ExternalScripts=/usr/lib/zabbix/externalscripts
    466 
    467 ### Option: FpingLocation
    468 #    Location of fping.
    469 #    Make sure that fping binary has root ownership and SUID flag set.
    470 #
    471 # Mandatory: no
    472 # Default:
    473 # FpingLocation=/usr/sbin/fping
    474 
    475 ### Option: Fping6Location
    476 #    Location of fping6.
    477 #    Make sure that fping6 binary has root ownership and SUID flag set.
    478 #    Make empty if your fping utility is capable to process IPv6 addresses.
    479 #
    480 # Mandatory: no
    481 # Default:
    482 # Fping6Location=/usr/sbin/fping6
    483 
    484 ### Option: SSHKeyLocation
    485 #    Location of public and private keys for SSH checks and actions.
    486 #
    487 # Mandatory: no
    488 # Default:
    489 # SSHKeyLocation=
    490 
    491 ### Option: LogSlowQueries
    492 #    How long a database query may take before being logged (in milliseconds).
    493 #    Only works if DebugLevel set to 3, 4 or 5.
    494 #    0 - don't log slow queries.
    495 #
    496 # Mandatory: no
    497 # Range: 1-3600000
    498 # Default:
    499 # LogSlowQueries=0
    500 
    501 LogSlowQueries=3000
    502 
    503 ### Option: TmpDir
    504 #    Temporary directory.
    505 #
    506 # Mandatory: no
    507 # Default:
    508 # TmpDir=/tmp
    509 
    510 ### Option: StartProxyPollers
    511 #    Number of pre-forked instances of pollers for passive proxies.
    512 #
    513 # Mandatory: no
    514 # Range: 0-250
    515 # Default:
    516 # StartProxyPollers=1
    517 
    518 ### Option: ProxyConfigFrequency
    519 #    How often Zabbix Server sends configuration data to a Zabbix Proxy in seconds.
    520 #    This parameter is used only for proxies in the passive mode.
    521 #
    522 # Mandatory: no
    523 # Range: 1-3600*24*7
    524 # Default:
    525 # ProxyConfigFrequency=3600
    526 
    527 ### Option: ProxyDataFrequency
    528 #    How often Zabbix Server requests history data from a Zabbix Proxy in seconds.
    529 #    This parameter is used only for proxies in the passive mode.
    530 #
    531 # Mandatory: no
    532 # Range: 1-3600
    533 # Default:
    534 # ProxyDataFrequency=1
    535 
    536 ### Option: AllowRoot
    537 #    Allow the server to run as 'root'. If disabled and the server is started by 'root', the server
    538 #    will try to switch to the user specified by the User configuration option instead.
    539 #    Has no effect if started under a regular user.
    540 #    0 - do not allow
    541 #    1 - allow
    542 #
    543 # Mandatory: no
    544 # Default:
    545 # AllowRoot=0
    546 
    547 ### Option: User
    548 #    Drop privileges to a specific, existing user on the system.
    549 #    Only has effect if run as 'root' and AllowRoot is disabled.
    550 #
    551 # Mandatory: no
    552 # Default:
    553 # User=zabbix
    554 
    555 ### Option: Include
    556 #    You may include individual files or all files in a directory in the configuration file.
    557 #    Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
    558 #
    559 # Mandatory: no
    560 # Default:
    561 # Include=
    562 
    563 # Include=/usr/local/etc/zabbix_server.general.conf
    564 # Include=/usr/local/etc/zabbix_server.conf.d/
    565 # Include=/usr/local/etc/zabbix_server.conf.d/*.conf
    566 
    567 ### Option: SSLCertLocation
    568 #    Location of SSL client certificates.
    569 #    This parameter is used only in web monitoring.
    570 #
    571 # Mandatory: no
    572 # Default:
    573 # SSLCertLocation=${datadir}/zabbix/ssl/certs
    574 
    575 ### Option: SSLKeyLocation
    576 #    Location of private keys for SSL client certificates.
    577 #    This parameter is used only in web monitoring.
    578 #
    579 # Mandatory: no
    580 # Default:
    581 # SSLKeyLocation=${datadir}/zabbix/ssl/keys
    582 
    583 ### Option: SSLCALocation
    584 #    Override the location of certificate authority (CA) files for SSL server certificate verification.
    585 #    If not set, system-wide directory will be used.
    586 #    This parameter is used only in web monitoring and SMTP authentication.
    587 #
    588 # Mandatory: no
    589 # Default:
    590 # SSLCALocation=
    591 
    592 ####### LOADABLE MODULES #######
    593 
    594 ### Option: LoadModulePath
    595 #    Full path to location of server modules.
    596 #    Default depends on compilation options.
    597 #
    598 # Mandatory: no
    599 # Default:
    600 # LoadModulePath=${libdir}/modules
    601 
    602 ### Option: LoadModule
    603 #    Module to load at server startup. Modules are used to extend functionality of the server.
    604 #    Format: LoadModule=<module.so>
    605 #    The modules must be located in directory specified by LoadModulePath.
    606 #    It is allowed to include multiple LoadModule parameters.
    607 #
    608 # Mandatory: no
    609 # Default:
    610 # LoadModule=
    611 
    612 ####### TLS-RELATED PARAMETERS #######
    613 
    614 ### Option: TLSCAFile
    615 #    Full pathname of a file containing the top-level CA(s) certificates for
    616 #    peer certificate verification.
    617 #
    618 # Mandatory: no
    619 # Default:
    620 # TLSCAFile=
    621 
    622 ### Option: TLSCRLFile
    623 #    Full pathname of a file containing revoked certificates.
    624 #
    625 # Mandatory: no
    626 # Default:
    627 # TLSCRLFile=
    628 
    629 ### Option: TLSCertFile
    630 #    Full pathname of a file containing the server certificate or certificate chain.
    631 #
    632 # Mandatory: no
    633 # Default:
    634 # TLSCertFile=
    635 
    636 ### Option: TLSKeyFile
    637 #    Full pathname of a file containing the server private key.
    638 #
    639 # Mandatory: no
    640 # Default:
    641 # TLSKeyFile=
    View Code

    注意要检查httpd服务有没有开启  语句 systemctl start httpd

    如果开启在浏览器地址输入:10.0.0.34显示

     #至此进入网页界面进行配置

    http://10.0.0.34/zabbix/setup.php

    #压测 ab命令需要安装httpd后可以使用
    ab -n 10000 -c 300 http://10.0.0.34/zabbix/index.php

    #iostat 需要安装yum -y install sysstat


    */1 * * * * /usr/bin/sh /server/scripts/zabbix.sh >/dev/null 2>&1

    脚本zabbix.sh

    #!/bin/bash
    ##############################################################
    # File Name: 7_2.sh
    # Version: V1.0
    # Author: nod
    # Description:
    ##############################################################
    #获取当前的空闲内存
    FreeMem=`free -m | awk 'NR==2 {print $NF}'`
    #输出当前的字段
    CHARS="CURRENT MEMORY IS $FreeMem"
    if [ $FreeMem -lt 150 ]  #为方便测试此处写为2000 低于2000发送报警,实际生产场景可以进行调整
    then
        echo $CHARS | tee /tmp/messages.txt #输出到屏幕和写入指定文件
        mail -s "`date +%F-%T` $CHARS" 312051952@qq.com </tmp/messages.txt  #发送邮件到指定邮箱
    fi

    #agent安装

    #安装agent
    rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.20-1.el7.x86_64.rpm

    #修改配置文件
    vim /etc/zabbix/zabbix_agentd.conf
    Server=10.0.0.34   #此处修改你的zabbix-server地址


    #检查状态
    systemctl start zabbix-agent
    setenforce 0
    systemctl stop firewalld
    systemctl start zabbix-agent
    systemctl status zabbix-agent

     #补充假定监控的为centos6的主机

    rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.20-1.el6.x86_64.rpm

    #zabbix服务端配置文件位置

     1 [root@nod02 web]# cat zabbix.conf.php 
     2 <?php
     3 // Zabbix GUI configuration file.
     4 global $DB;
     5 
     6 $DB['TYPE']     = 'MYSQL';
     7 $DB['SERVER']   = 'localhost';
     8 $DB['PORT']     = '0';
     9 $DB['DATABASE'] = 'zabbix';
    10 $DB['USER']     = 'zabbix';
    11 $DB['PASSWORD'] = 'zabbix';
    12 
    13 // Schema name. Used for IBM DB2 and PostgreSQL.
    14 $DB['SCHEMA'] = '';
    15 
    16 $ZBX_SERVER      = 'localhost';
    17 $ZBX_SERVER_PORT = '10051';
    18 $ZBX_SERVER_NAME = '';
    19 
    20 $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
    21 [root@nod02 web]# pwd
    22 /etc/zabbix/web
    View Code
  • 相关阅读:
    冒泡排序算法。
    深入浅出UML类图(一)转
    树形结构的处理—组合模式(五)
    树形结构的处理—组合模式(四)
    树形结构的处理—组合模式(三)
    树形结构的处理—组合模式(二)
    树形结构的处理—组合模式(一)
    如何成为优秀的软件模型设计者? 转
    软件架构与架构师 转
    深入浅出外观模式(三)
  • 原文地址:https://www.cnblogs.com/nodchen/p/9432360.html
Copyright © 2011-2022 走看看