Skip to content

Instantly share code, notes, and snippets.

View liushuainudt's full-sized avatar

刘帅 liushuainudt

  • 11:27 (UTC +08:00)
View GitHub Profile
@liushuainudt
liushuainudt / fan_speed_control.sh
Last active April 8, 2023 16:16
This script monitors the SAS2308 temperature on a FreeBSD or Truenas server, calculates the desired fan speed percentage using a formula, adjusts zone 1 fan speed accordingly, and logs data to "check.log". It optimizes IPMI calls and runs indefinitely.
#!/bin/sh
# This script is designed to monitor and control the fan speed in a server based on the temperature of the SAS2308 component.
# The script achieves this by using IPMI (Intelligent Platform Management Interface) commands and the mpsutil utility.
# Key features of the script include:
# Continuously monitoring the temperature of the SAS2308 component.
# Calculating the desired fan speed percentage based on the formula "3.8 * SAS_temperature - 128."
# Adjusting the zone 1 fan speed based on the calculated percentage.
# Logging temperature and fan speed data to a file named "check.log" in the script directory.
@liushuainudt
liushuainudt / fan.chart.sh
Last active April 3, 2023 15:01
Designed to monitor and report the speed (in RPM) of fans in a remote system using ipmitool and SSH. The script is intended to be used as a custom plugin for the Netdata monitoring system.-helped by Chatgpt
#!/bin/sh
# Define the name of the chart and its type
fan_chart="Devices.fanspeed"
chart_type="line"
# Define the SSH connection details
IPMI_USER="ADMIN"
IPMI_PASS="you pass word"
IPMI_HOST="192.168.0.121"
@liushuainudt
liushuainudt / temperature.chart.sh
Last active April 3, 2023 14:59
Designed to monitor and report the temperature values of a SAS controller (SAS2308) and a 10GB network interface card (NIC) in a remote system. The script is intended to be used as a custom plugin for the Netdata monitoring system.-helped by Chatgpt
#!/bin/sh
# Define the name of the chart and its type
temperature_chart="Devices.temperature"
chart_type="line"
# Define the SSH connection details
ssh_user="root"
ssh_host="192.168.0.108"
ssh_key="/var/log/netdata/.ssh/id_rsa"
@liushuainudt
liushuainudt / ipcalc.go
Last active April 3, 2023 15:18 — forked from kotakanbe/ipcalc.go
get all IP address from CIDR in golang
package main
import (
"fmt"
"net"
"os/exec"
"sync"
"github.com/k0kubun/pp"
)
@liushuainudt
liushuainudt / gist:018a2bbdb6bcd40c3af90b3318a0c9e9
Created March 18, 2020 07:17 — forked from jaydson/gist:1780598
How to detect a click event on a cross domain iframe
var myConfObj = {
iframeMouseOver : false
}
window.addEventListener('blur',function(){
if(myConfObj.iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
@liushuainudt
liushuainudt / faster_toPandas.py
Last active April 3, 2023 15:16 — forked from joshlk/faster_toPandas.py
PySpark faster toPandas using mapPartitions
import pandas as pd
from pyspark.sql import DataFrame as SparkDataFrame
from typing import Optional
def _map_to_pandas(rdds):
"""Converts each partition of the RDD to a Pandas DataFrame."""
return [pd.DataFrame(list(rdds))]
def toPandas(df: SparkDataFrame, n_partitions: Optional[int] = None) -> pd.DataFrame:
"""