由于领导比较青睐 Prometheus 开源监控,由于鄙人自身也是网络专业出身,因此便但愿能用 prometheus 监控公司的交换机,公司大量的交换机在业务区,比较繁杂,虽然平常监控均可以用 Solarwinds 和 Opmanager 进行平常网络行为监控管理,可是 Solarwinds 界面比较比较有上古世纪的感受,Opmanager 又比较卡,对服务器硬件配置稍微高了点,并且没有比开源 Prometheus 的更方便管理、进行修改配置等操做。何况如今 prometheus 有较多的公司正在使用,可搜集的资料较多,但相对来讲,监控交换机的这方面, snmp_exporter 的发展就相对较为缓慢一点,不过相信咱们愈来愈多的人使用,终究会更加完善。html
Prometheus 监控思科交换机文档完整地址:https://blog.51cto.com/liujingyu/category9.htmlnode
各程序说明linux
使用版本git
官网地址:github
yum install wget yum-utils net-tools vim unzip bash-completion -y yum update -y ulimit -n sed -i "s/* soft nofile 65535/ /g" /etc/security/limits.conf sed -i "s/* hard nofile 65535/ /g" /etc/security/limits.conf echo "* soft nofile 65535" >>/etc/security/limits.conf echo "* hard nofile 65535" >>/etc/security/limits.conf ulimit -n 65535 echo "修改后文件数量" ulimit -n echo "优化内核参数" echo "net.ipv4.ip_local_port_range = 1024 65535" >>/etc/sysctl.conf echo "net.ipv4.tcp_syncookies = 1" >>/etc/sysctl.conf echo "net.ipv4.tcp_tw_reuse = 1" >>/etc/sysctl.conf echo "net.ipv4.tcp_tw_recycle = 1" >>/etc/sysctl.conf echo "net.ipv4.tcp_fin_timeout = 30" >>/etc/sysctl.conf echo "net.core.somaxconn = 20480" >>/etc/sysctl.conf echo "net.core.netdev_max_backlog = 20480" >>/etc/sysctl.conf echo "net.ipv4.tcp_max_syn_backlog = 20480" >>/etc/sysctl.conf echo "net.ipv4.tcp_max_tw_buckets = 800000" >>/etc/sysctl.conf sysctl -p sed -i 's/=enforcing/=disabled/g' /etc/selinux/config setenforce 0 systemctl disabled firewalld systemctl stop firewalld
wget https://github.com/prometheus/prometheus/releases/download/v2.21.0/prometheus-2.21.0.linux-amd64.tar.gz wget https://github.com/prometheus/snmp_exporter/releases/download/v0.19.0/snmp_exporter-0.19.0.linux-amd64.tar.gz wget https://github.com/prometheus/alertmanager/releases/download/v0.21.0/alertmanager-0.21.0.linux-amd64.tar.gz tar -xvf prometheus-2.21.0.linux-amd64.tar.gz mv prometheus-2.21.0.linux-amd64 /opt/prometheus tar -xf snmp_exporter-0.19.0.linux-amd64.tar.gz mv snmp_exporter-0.19.0.linux-amd64 /opt/snmp_exporter tar -xf alertmanager-0.21.0.linux-amd64.tar.gz mv alertmanager-0.21.0.linux-amd64 /opt/alertmanager cat > /etc/systemd/system/prometheus.service <<EOF [Unit] Description=Prometheus After=network.target [Service] ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data User=prometheus [Install] WantedBy=multi-user.target EOF cat > /etc/systemd/system/snmp_exporter.service <<EOF [Unit] Description=node_exporter After=network.target [Service] ExecStart=/opt/snmp_exporter/snmp_exporter --config.file=/opt/snmp_exporter/snmp.yml Restart=on-failure [Install] WantedBy=multi-user.target EOF cat > /etc/systemd/system/snmp_exporter.service <<EOF [Unit] Description=node_exporter After=network.target [Service] ExecStart=/opt/alertmanager/alertmanager --config.file=/opt/alertmanager/alertmanager.yml Restart=on-failure [Install] WantedBy=multi-user.target EOF useradd prometheus chown -R prometheus:prometheus /opt/{snmp_exporter,prometheus,alertmanager} systemctl daemon-reload systemctl enable prometheus && systemctl enable snmp_exporter && systemctl enable alertmanager systemctl start prometheus && systemctl start snmp_exporter && systemctl start alertmanager
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum -y install docker-ce systemctl enable docker && systemctl start docker docker login --username=LOGIN_NAME registry.cn-beijing.aliyuncs.com #登陆阿里云仓库 docker pull registry.cn-beijing.aliyuncs.com/liujingyu/grafana-chinese:7.2.0 docker image ls docker tag registry.cn-beijing.aliyuncs.com/liujingyu/grafana-chinese:7.2.0 grafana-chinese:7.2.0 docker run -tdi --name grafana-server --restart=always -p 3000:3000 grafana-chinese:7.2.0
具体配置调整请查看后续文章shell