年轻了三岁
要63退休了,就是不知道能不能活到那天。
现在的较高的预期寿命都是我们的父辈们创造的。他们在无污染公害的环境中成长,他们每天体力劳动(锻炼身体)而不是象我们一样一坐就是一天,他们有国家养老而不是象我们一样吃了上顿忧下顿,他们带娃活着就行我们为娃呕心沥血。。。新闻里天天看到40-50就挂了的那么多名人,不就是我们的预言么。
做为在海外混日子的自由职业者,退休和社保其实和我没任何关系。我只是想到了预期寿命有感而发,毕竟上面说的伤身的问题我一样不落。
要63退休了,就是不知道能不能活到那天。
现在的较高的预期寿命都是我们的父辈们创造的。他们在无污染公害的环境中成长,他们每天体力劳动(锻炼身体)而不是象我们一样一坐就是一天,他们有国家养老而不是象我们一样吃了上顿忧下顿,他们带娃活着就行我们为娃呕心沥血。。。新闻里天天看到40-50就挂了的那么多名人,不就是我们的预言么。
做为在海外混日子的自由职业者,退休和社保其实和我没任何关系。我只是想到了预期寿命有感而发,毕竟上面说的伤身的问题我一样不落。
刚在ns看到这图。
闹了半天,阿里也只不过是vps?云?那是浮云?
一个真的云,在出现宕机时,应该能够自动迁移,无缝要求可能太高,但秒级应该行吧? 2-5分钟,我宁肯相信是工作人员在更换物理机。
经过我多年潜心研究揭露出一个真相:仅仅一只1C1G小鸡就能满足我的所有要求了。扎心。。。
蚊子肉也是肉,1C1G也是鸡,基于此,我特地找了手里三只1C1G的小鸡来对比下。
网络就不扯了,三家的网络国际都很好,对中国当然都一塌糊涂。这个谁都知道。
NetCup 1o
ISP : netcup GmbH
ASN : AS197540 netcup GmbH
Host : NETCUP-GMBH
Location : Nuremberg, Bavaria (BY)
Country : Germany
fio Disk Speed Tests (Mixed R/W 50/50) (Partition /dev/vda3):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 37.45 MB/s (9.3k) | 527.12 MB/s (8.2k)
Write | 37.54 MB/s (9.3k) | 529.90 MB/s (8.2k)
Total | 75.00 MB/s (18.7k) | 1.05 GB/s (16.5k)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 725.19 MB/s (1.4k) | 788.18 MB/s (769)
Write | 763.72 MB/s (1.4k) | 840.67 MB/s (820)
Total | 1.48 GB/s (2.9k) | 1.62 GB/s (1.5k)
Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 377
Multi Core | 365
Oracle 免费AMD
ISP : Oracle Corporation
ASN : AS31898 Oracle Corporation
Host : Oracle Cloud Infrastructure (ap-tokyo-1)
Location : Tokyo, Tokyo (13)
Country : Japan
fio Disk Speed Tests (Mixed R/W 50/50) (Partition /dev/sda2):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 6.37 MB/s (1.5k) | 26.46 MB/s (413)
Write | 6.37 MB/s (1.5k) | 26.97 MB/s (421)
Total | 12.74 MB/s (3.1k) | 53.44 MB/s (834)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 24.50 MB/s (47) | 24.17 MB/s (23)
Write | 26.01 MB/s (50) | 26.68 MB/s (26)
Total | 50.51 MB/s (97) | 50.85 MB/s (49)
Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 336
Multi Core | 310
Google Cloud 免费E2-Micro
ISP : Google LLC
ASN : AS15169 Google LLC
Host : Google Cloud (us-west1)
Location : The Dalles, Oregon (OR)
Country : United States
fio Disk Speed Tests (Mixed R/W 50/50) (Partition /dev/sda1):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 406.00 KB/s (101) | 5.79 MB/s (90)
Write | 428.00 KB/s (107) | 6.09 MB/s (95)
Total | 834.00 KB/s (208) | 11.89 MB/s (185)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 27.53 MB/s (53) | 37.68 MB/s (36)
Write | 29.45 MB/s (57) | 40.94 MB/s (39)
Total | 56.98 MB/s (110) | 78.62 MB/s (75)
Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 475
Multi Core | 99
昨天发了go版的,不过会搭建go开发环境进行编译的人毕竟不多,发编译后的二进制码也不是我作风。今天发一个bash脚本版的吧。
感谢cctv,感谢gpt,这代码是直接让它改写的go,我没有改动。测试了一下没问题。
我说说使用步骤:
为了验证上面的tg参数是否正确,可以在第6步后, ./ovh.sh 你的token 你的id test 试运行一下,它会报告法国有货,即发送通知到Tg: Server availability changed to: 72H in datacenter: bhs。没问题的话就ctrl-c,然后继续第7步。
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <telegram_bot_token> <chat_id> [test]"
exit 1
fi
TELEGRAM_BOT_TOKEN=$1
CHAT_ID=$2
TEST_MODE=$3
API_URL="https://ca.ovh.com/engine/apiv6/dedicated/server/datacenter/availabilities/?excludeDatacenters=false&planCode=24ska01&server=24ska01"
send_telegram_notification() {
local datacenter=$1
local availability=$2
local message="Server availability changed to: $availability in datacenter: $datacenter"
echo "Sending notification: $message"
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
-d "chat_id=$CHAT_ID" \
-d "text=$message" >/dev/null
echo "Notification sent."
}
check_availability() {
echo "Fetching server availability data..."
response=$(curl -s "$API_URL")
if [ -z "$response" ]; then
echo "Failed to fetch data."
return
fi
echo "Received JSON response: $response"
if [ "$TEST_MODE" == "test" ]; then
echo "Test mode enabled. Forcing bhs datacenter availability to 72H."
response=$(echo "$response" | jq '.[0].datacenters |= map(if .datacenter == "bhs" then .availability = "72H" else . end)')
fi
echo "$response" | jq -c '.[0].datacenters[]' | while read -r datacenter; do
availability=$(echo "$datacenter" | jq -r '.availability')
name=$(echo "$datacenter" | jq -r '.datacenter')
echo "Checking datacenter: $name, availability: $availability"
if [ "$availability" != "unavailable" ]; then
echo "Availability change detected: $availability in datacenter: $name"
send_telegram_notification "$name" "$availability"
break
fi
done
echo "Finished checking all datacenters."
}
while true; do
check_availability
sleep 60
done
前几天正在写博客评点哪吒,结果OVH放货了KS-A,等写完发现,已经卖完了。这不得不拍断大腿了。
赶紧补救,写个监控KS-A放货的玩意,下次一定要把握住了。
程序就是每一分钟去ovh网页上拉一下库存,如果有,就telegram赶紧通知。
先只贴go源代码了,改天有空我看看是不是写个使用说明。
调用格式是 ./ovh -token=tg机器人的token -chatid=自己tg号的id
加上-test,会模拟加拿大有货,给tg发条通知。这样检查tg参数对不对。
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strings"
"time"
)
const apiURL = "https://ca.ovh.com/engine/apiv6/dedicated/server/datacenter/availabilities/?excludeDatacenters=false&planCode=24ska01&server=24ska01"
type Datacenter struct {
Availability string `json:"availability"`
Datacenter string `json:"datacenter"`
}
type Server struct {
Datacenters []Datacenter `json:"datacenters"`
}
func checkAvailability(testMode bool, telegramBotToken, chatID string) {
log.Println("Starting availability check...")
resp, err := http.Get(apiURL)
if err != nil {
log.Println("Failed to fetch data:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println("Failed to read response body:", err)
return
}
log.Println("Received JSON response:", string(body))
var servers []Server
err = json.Unmarshal(body, &servers)
if err != nil {
log.Println("Failed to parse JSON:", err)
return
}
// 如果是测试模式,强行设置 bhs 数据中心的可用性为 72H
if testMode {
log.Println("Test mode enabled. Forcing bhs datacenter availability to 72H.")
for i, server := range servers {
for j, dc := range server.Datacenters {
if dc.Datacenter == "bhs" {
servers[i].Datacenters[j].Availability = "72H"
}
}
}
}
for _, server := range servers {
for _, dc := range server.Datacenters {
log.Printf("Checking datacenter: %s, availability: %s\n", dc.Datacenter, dc.Availability)
if dc.Availability != "unavailable" {
log.Printf("Availability change detected: %s in datacenter: %s\n", dc.Availability, dc.Datacenter)
sendTelegramNotification(dc.Datacenter, dc.Availability, telegramBotToken, chatID)
return // 一旦发现可用的服务器,立即发送通知并停止进一步检查
}
}
}
log.Println("No availability changes detected.")
}
func sendTelegramNotification(datacenter, availability, telegramBotToken, chatID string) {
msg := fmt.Sprintf("Server availability changed to: %s in datacenter: %s", availability, datacenter)
telegramApi := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", telegramBotToken)
log.Printf("Sending notification: %s\n", msg)
form := url.Values{}
form.Add("chat_id", chatID)
form.Add("text", msg)
resp, err := http.Post(telegramApi, "application/x-www-form-urlencoded", strings.NewReader(form.Encode()))
if err != nil {
log.Println("Failed to send telegram message:", err)
return
}
defer resp.Body.Close()
log.Println("Notification sent successfully.")
}
func main() {
// 解析命令行参数
testMode := flag.Bool("test", false, "Enable test mode to simulate availability change")
telegramBotToken := flag.String("token", "", "Telegram bot token")
chatID := flag.String("chatid", "", "Telegram chat ID")
flag.Parse()
// 检查是否提供了必要的参数
if *telegramBotToken == "" || *chatID == "" {
fmt.Println("Usage: ./exename -token=<telegramBotToken> -chatid=<chatID> [-test]")
os.Exit(1)
}
for {
checkAvailability(*testMode, *telegramBotToken, *chatID)
time.Sleep(1 * time.Minute)
}
}