西维蜀黍

【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
    
  ...


【Ubuntu】Install Kvm

  ...


【Performance】性能测试(Performance Testing)

Software Performance Testing

In software quality assurance, performance testing is in general a testing practice performed to determine how a system performs in terms of responsiveness and stability under a particular workload. It can also serve to investigate, measure, validate or verify other quality attributes of the system, such as scalability, reliability and resource usage.

Performance testing, a subset of performance engineering, is a computer science practice which strives to build performance standards into the implementation, design and architecture of a system.

  ...


【Performance】性能

Computer Performance

In computing, computer performance is the amount of useful work accomplished by a computer system. Outside of specific contexts, computer performance is estimated in terms of accuracy, efficiency and speed of executing computer program instructions. When it comes to high computer performance, one or more of the following factors might be involved:

  • Short response time for a given piece of work.
  • High throughput (rate of processing work).
  • Low utilization of computing resource(s).
  • Fast (or highly compact) data compression and decompression.
  • High availability of the computing system or application.
  • High bandwidth.
  • Short data transmission time.
  ...


【Network】localhost

Localhost

In computer networking, localhost is a hostname that refers to the current computer used to access it. It is used to access the network services that are running on the host via the loopback network interface. Using the loopback interface bypasses any local network interface hardware.

Question

I have seen 127.0.0.1 is local host address. But what is it and what is the differences between this and my local adapter like LAN IP address or WLAN IP address. Is there any connection between this l27.0.0.1 and my LAN or WLAN Network card?

  ...


【Golang】Dependency Injection in Golang

Without frameworks

Dependency injection is passing a dependency to another object or structure. We do this as it allows the creation of dependencies outside the dependant object. This is useful as we can decouple dependency creation from the object being created. Lets look at an example of dependency injection in Go:

type DataStore interface {}

type PersonResource struct {
	Store DataStore
}

func New(store DataStore) *PersonResource {
	return &PersonResource{Store: store}
}
  ...