西维蜀黍

【Linux】命令 - smartctl

smartctl controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into many ATA-3 and later ATA, IDE and SCSI-3 hard drives. The purpose of SMART is to monitor the reliability of the hard drive and predict drive failures, and to carry out different types of drive self-tests.

Install

Ubuntu

$ sudo apt-get install smartmontools
  ...


【Prometheus】Troubleshooting

Error on ingesting samples that are too old or are too far into the futur

  • Logs:
Jan  4 20:32:46 box prometheus: level=warn ts=2020-01-04T19:32:46.888Z caller=scrape.go:1170 component="scrape manager" scrape_pool=cpanel target=http://target_host:2089/metrics msg="Error on ingesting samples that are too old or are too far into the future" num_dropped=7
Jan  4 20:32:46 box prometheus: level=warn ts=2020-01-04T19:32:46.889Z caller=scrape.go:945 component="scrape manager" scrape_pool=cpanel target=http://target_host:2089/metrics msg="appending scrape report failed" err="out of bounds"
  ...


【Grafana】Grafana安装

安装

Ubuntu

$ sudo apt-get install -y apt-transport-https
$ sudo apt-get install -y software-properties-common wget
$ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

Add this repository for stable releases:

$ echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list 

After you add the repository:

$ sudo apt-get update
$ sudo apt-get install grafana
  ...


【Prometheus】Prometheus 安装

安装 Prometheus Server

macOS

$ export VERSION=2.19.2
$ curl -LO  https://github.com/prometheus/prometheus/releases/download/v$VERSION/prometheus-$VERSION.darwin-amd64.tar.gz
$ tar -xzf prometheus-${VERSION}.darwin-amd64.tar.gz
$ cd prometheus-${VERSION}.darwin-amd64

Linux

$ curl -LO https://github.com/prometheus/prometheus/releases/download/v2.19.2/prometheus-2.19.2.linux-amd64.tar.gz
$ tar -xzf prometheus-2.19.2.linux-amd64.tar.gz
$ cd prometheus-2.19.2.linux-amd64/

Via Docker

# Run by background mode
$ docker run -d -p 9090:9090 prom/prometheus

# create the config file
$ mkdir prometheus_config; cd prometheus_config; touch prometheus.yml

# 如果希望设置为在宿主机开机后,这个 prometheus Docker instance 也一直运行
$ docker run -d \
--name prometheus \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone \
--restart unless-stopped \
-p 9090:9090 \
-v /home/sw/prometheus_config:/etc/prometheus \
prom/prometheus
  ...


【Linux】设置程序开机启动

修改开机启动文件 - /etc/rc.local

  • 或者/etc/rc.d/rc.local

  • 修改rc.local文件,在 exit 0 前面加入以下命令

    # mysql开机启动
    /etc/init.d/mysqld start                                         
    /bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null
    
  • 最后修改rc.local文件的执行权限

    [root@localhost ~]# chmod +x  /etc/rc.local
    [root@localhost ~]# chmod 755 /etc/rc.local
    
  ...