Zabbix实现对Memcached的监控

Zabbix对Memcached的监控的主要思路是Memcached自身提供了查询状态的命令stats,通过脚本调用此命令并进行数据抽取完成对Memcached的实时监控。

基本步骤:自定义监控项 → 通过脚本采集监控项数据 → zabbix agent获取监控项数据 → 自定义模板和图形及触发器 → 验证数据

1.准备Memcached服务器

安装Memcached,并配置好Memcached;安装zabbix agent及nmap基本工具包。

Nmap(也就是Network Mapper,最早是Linux下的网络扫描和嗅探工具包)是一个网络连接端扫描软件,用来扫描网上电脑开放的网络连接端。

#### Memcached服务器必须配置memcached服务,还需要安装zabbix agent## 配置zabbix 的yum源并安装zabbix agent[root@CentOS84-IP88 ]#rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm[root@CentOS84-IP88 ]#dnf clean all43 files removed[root@CentOS84-IP88 ]#dnf -y install zabbix-agent ########################################################################## 安装memcached及抽取数据用的 nmap[root@CentOS84-IP88 ]#yum -y install memcached nmap## 配置 memcached[root@CentOS84-IP88 ]#ll /etc/sysconfig/memcached-rw-r--r-- 1 root root 87 Jun 182020 /etc/sysconfig/memcached[root@CentOS84-IP88 ]#vim /etc/sysconfig/memcachedPORT="11211"USER="memcached"MAXCONN="1024"CACHESIZE="64"#OPTIONS="-l 127.0.0.1,::1"## 启动memcached并验证[root@CentOS84-IP88 ]#systemctl enable --now memcachedCreated symlink /etc/systemd/system/multi-user.target.wants/memcached.service → /usr/lib/systemd/system/memcached.service.[root@CentOS84-IP88 ]#ss -tlnState Recv-QSend-Q Local Address:PortPeer Address:PortProcessLISTEN0 1024 0.0.0.0:112110.0.0.0:*LISTEN0 1024[::]:11211 [::]:*[root@CentOS84-IP88 ]#

2.准备监控脚本

########################################################################## 手动命令方式查看memcached的运行状态[root@CentOS84-IP88 ]#telnet IP 11211 【此处IP地址是本机地址】Trying 192.168.250.88...Connected to 192.168.250.88.Escape character is '^]'.statsSTAT pid 165546STAT uptime 4614STAT time 1652964513STAT version 1.5.22STAT libevent 2.1.8-stableSTAT pointer_size 64STAT rusage_user 0.676326STAT rusage_system 0.310024STAT max_connections 1024STAT curr_connections 2STAT total_connections 6STAT rejected_connections 0STAT connection_structures 3STAT reserved_fds 20STAT cmd_get 0STAT cmd_set 0STAT cmd_flush 0STAT cmd_touch 0STAT cmd_meta 0STAT get_hits 0STAT get_misses 0STAT get_expired 0STAT get_flushed 0STAT delete_misses 0STAT delete_hits 0STAT incr_misses 0STAT incr_hits 0STAT decr_misses 0STAT decr_hits 0STAT cas_misses 0STAT cas_hits 0STAT cas_badval 0STAT touch_hits 0STAT touch_misses 0STAT auth_cmds 0STAT auth_errors 0STAT bytes_read 29STAT bytes_written 3813STAT limit_maxbytes 67108864STAT accepting_conns 1STAT listen_disabled_num 0STAT time_in_listen_disabled_us 0STAT threads 4STAT conn_yields 0STAT hash_power_level 16STAT hash_bytes 524288STAT hash_is_expanding 0STAT slab_reassign_rescues 0STAT slab_reassign_chunk_rescues 0STAT slab_reassign_evictions_nomem 0STAT slab_reassign_inline_reclaim 0STAT slab_reassign_busy_items 0STAT slab_reassign_busy_deletes 0STAT slab_reassign_running 0STAT slabs_moved 0STAT lru_crawler_running 0STAT lru_crawler_starts 3060STAT lru_maintainer_juggles 4662STAT malloc_fails 0STAT log_worker_dropped 0STAT log_worker_written 0STAT log_watcher_skipped 0STAT log_watcher_sent 0STAT bytes 0STAT curr_items 0STAT total_items 0STAT slab_global_page_pool 0STAT expired_unfetched 0STAT evicted_unfetched 0STAT evicted_active 0STAT evictions 0STAT reclaimed 0STAT crawler_reclaimed 0STAT crawler_items_checked 0STAT lrutail_reflocked 0STAT moves_to_cold 0STAT moves_to_warm 0STAT moves_within_lru 0STAT direct_reclaims 0STAT lru_bumps_dropped 0END## 命令行方式先完成需要抽取数据的验证工作[root@CentOS84-IP88 ]# echo -e "stats\nquit" | ncat127.0.0.1 11211 | grep "STAT curr_connections"STAT curr_connections 2[root@CentOS84-IP88 ]#[root@CentOS84-IP88 ]# echo -e "stats\nquit" | ncat127.0.0.1 11211 | grep "STAT curr_connections" | awk '{print $3}'2[root@CentOS84-IP88 ]########################################################################### 按照说明的命令行思路完成脚本的编写[root@CentOS84-IP88 ]#vim memcache_monitor.sh #!/bin/bashmemcached_status(){M_PORT=$1M_COMMAND=$2echo -e "stats\nquit" | ncat127.0.0.1 "$M_PORT" | grep "STAT $M_COMMAND" | awk '{print $3}'}main(){case $1 inmemcached_status)memcached_status $2 $3;;esac}main $1 $2 $3## 授权并测试运行[root@CentOS84-IP88 ]#chmod a+x memcache_monitor.sh [root@CentOS84-IP88 ]#bash memcache_monitor.sh memcached_status 11211 curr_connections2[root@CentOS84-IP88 ]#

3.添加zabbix agent自定义监控项

#### 前面已经安装好zabbix_agent,修改并配置好zabbix_agent## 抽取出的yum方式默认安装zabbix_agent的配置行[root@CentOS84-IP88 ]#grep "^[a-Z]" /etc/zabbix/zabbix_agentd.confPidFile=/run/zabbix/zabbix_agentd.pidLogFile=/var/log/zabbix/zabbix_agentd.logLogFileSize=0Server=127.0.0.1ServerActive=127.0.0.1Hostname=Zabbix serverInclude=/etc/zabbix/zabbix_agentd.d/*.conf[root@CentOS84-IP88 ]#vim /etc/zabbix/zabbix_agentd.conf ## 修改 zabbix_agentd.conf,并抽取出修改后的配置行[root@CentOS84-IP88 ]#vim /etc/zabbix/zabbix_agentd.conf[root@CentOS84-IP88 ]#grep "^[a-Z]" /etc/zabbix/zabbix_agentd.confPidFile=/run/zabbix/zabbix_agentd.pidLogFile=/var/log/zabbix/zabbix_agentd.logLogFileSize=0Server=192.168.250.18ListenPort=10050ServerActive=127.0.0.1Hostname=192.168.250.88Include=/etc/zabbix/zabbix_agentd.d/*.confUserParameter=memcache_status[*],/etc/zabbix/zabbix_agentd.d/memcache_monitor.sh "$1" "$2" "$3"[root@CentOS84-IP88 ]### 验证配置[root@CentOS84-IP88 ]#ss -tlnState Recv-Q Send-Q Local Address:PortPeer Address:PortProcessLISTEN01024 0.0.0.0:112110.0.0.0:*LISTEN01280.0.0.0:1110.0.0.0:*LISTEN01280.0.0.0:22 0.0.0.0:*LISTEN05127.0.0.1:6310.0.0.0:*LISTEN01024[::]:11211 [::]:*LISTEN0128 [::]:111 [::]:*LISTEN0128 [::]:22[::]:*LISTEN05[::1]:631 [::]:*[root@CentOS84-IP88 ]#systemctl restart zabbix-agent.service [root@CentOS84-IP88 ]#systemctl restart zabbix-agent[root@CentOS84-IP88 ]#ss -tlnState Recv-Q Send-Q Local Address:PortPeer Address:PortProcessLISTEN01024 0.0.0.0:112110.0.0.0:*LISTEN01280.0.0.0:1110.0.0.0:*LISTEN01280.0.0.0:22 0.0.0.0:*LISTEN05127.0.0.1:6310.0.0.0:*LISTEN01280.0.0.0:100500.0.0.0:*LISTEN01024[::]:11211 [::]:*LISTEN0128 [::]:111 [::]:*LISTEN0128 [::]:22[::]:*LISTEN05[::1]:631 [::]:*LISTEN0128 [::]:10050 [::]:*[root@CentOS84-IP88 ]#

4.zabbix server测试监控项数据

## 安装 zabbix-get 工具[root@CentOS84-IP18 ]#yum install zabbix-get.x86_64[root@CentOS84-IP18 ]#find / -name zabbix_get/usr/bin/zabbix_get[root@CentOS84-IP18 ]#[root@CentOS84-IP18 ]#/usr/bin/zabbix_get -s 192.168.250.88 -p 10050 -k "memcache_status["memcached_status","11211","curr_connections"]" 2[root@CentOS84-IP18 ]#

5.编制Memcached模板

编制zabbix的模板分四个大的步骤:创建模板 → 在模板内创建监控项 → 创建触发器 → 创建监控图形

5.1创建模板

登录zabbix server,配置→模板→创建模板

实战案例:Zabbix对Memcached的监控_memcached

实战案例:Zabbix对Memcached的监控_Zabbix_02

5.2创建监控项

配置→模板→shone-memcached→ 监控项 → 创建监控项:

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_03

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_04

实战案例:Zabbix对Memcached的监控_centos_05

实战案例:Zabbix对Memcached的监控_centos_06

5.3创建触发器

配置→模板→shone-memcached→触发器→创建触发器

实战案例:Zabbix对Memcached的监控_centos_07

实战案例:Zabbix对Memcached的监控_Zabbix_08

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_09

5.4创建图形

配置→模板→shone-memcached→图形→创建图形

实战案例:Zabbix对Memcached的监控_Zabbix_10

实战案例:Zabbix对Memcached的监控_memcached_11

6.添加主机及关联模板

配置 → 主机 → 创建主机 → 关联模板

实战案例:Zabbix对Memcached的监控_memcached_12

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_13

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_14

7.验证Memcached监控

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_15

实战案例:Zabbix对Memcached的监控_Zabbix对Memcached的监控_16

使用CSS实现六边形的图片效果 网站建设

使用CSS实现六边形的图片效果

这篇文章主要介绍了使用CSS实现六边形的图片效果,这个效果的难点在于六边形的绘制, 那么接下来我们就一起来看下是怎么实现的吧! 前言 在CodePen上看到一个有意思的效果: 这个效...