Skip to content

Commit f64b414

Browse files
committed
+config 新增群晖synology的systeminfo输出
1 parent e90710c commit f64b414

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

files/bash.d/systeminfo-synology.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
# by 运维朱工
3+
# site:bash.lutixia.cn
4+
####################################
5+
6+
7+
8+
# 获取IP地址和主机名
9+
IP_ADDR=$(ifconfig eth0 | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort -u | head -1)
10+
HOSTNAME=$(hostname)
11+
12+
# CPU负载信息:
13+
cpu_load() {
14+
echo -e "\t\t\tcpu的负载情况"
15+
echo -e "\t------------------------------------------------"
16+
echo -e "\tCPU load in 1 min is: `awk '{printf "%15s",$1}' /proc/loadavg`"
17+
echo -e "\tCPU load in 5 min is: `awk '{printf "%15s",$2}' /proc/loadavg`"
18+
echo -e "\tCPU load in 10 min is: `awk '{printf "%15s",$3}' /proc/loadavg`"
19+
echo
20+
}
21+
22+
# mem基本信息:
23+
memory_info() {
24+
echo -e "\t\t\t内存的使用情况"
25+
echo -e "\t------------------------------------------------"
26+
echo -e "\t`free -h | awk '/Mem/{printf "%-10s %s","内存总容量:",$2}'`"
27+
echo -e "\t`free -h | awk '/Mem/{printf "%-10s %s","内存空闲容量:",$4}'`"
28+
echo -e "\t`free -h | awk '/Mem/{printf "%-10s %s","内存缓存:",$6}'`"
29+
echo
30+
}
31+
32+
# 磁盘使用量排序:
33+
disk_rank() {
34+
echo -e "\t\t\t各分区使用率"
35+
echo -e "\t------------------------------------------------"
36+
df -h -x tmpfs -x devtmpfs | sort -nr -k 5 | awk '/dev/{printf "\t%-20s %10s\n", $1, $5}'
37+
echo
38+
}
39+
40+
# 显示系统信息
41+
echo
42+
echo -e "\t\t\t系统基本信息:"
43+
echo -e "\t------------------------------------------------"
44+
echo -e "\tCurrent Time : $(date)"
45+
echo -e "\tVersion : $(echo "$(grep 'os_name' /etc.defaults/VERSION | awk -F= '{print $2}') $(grep 'productversion' /etc.defaults/VERSION | awk -F= '{print $2}')" | tr -d '"')"
46+
echo -e "\tKernel : $(uname -r)"
47+
echo -e "\tUptime : $(uptime -p)"
48+
echo -e "\tIP addr : $IP_ADDR"
49+
echo -e "\tHostname : $HOSTNAME"
50+
echo -e "\tCpu : $(cat /proc/cpuinfo | grep "model name" | awk -F'[:]+' '{print $NF}' | sed 's/^[^ ]* //' | sort -u)"
51+
echo -e "\tMemory : $(free -h | awk '/^Mem:/ { print $3 "/" $2 }')"
52+
echo -e "\tSWAP : $(free -h | awk '/^Swap:/ { print $3 "/" $2 }')"
53+
echo -e "\tUsers Logged : $(who | wc -l) users"
54+
echo
55+
56+
cpu_load
57+
memory_info
58+
disk_rank

playbooks/config.yml

+12
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@
254254
group: root
255255
with_fileglob:
256256
- files/bash.d/systeminfo.sh
257+
when: not ('os.synology' in group_names)
258+
259+
- copy:
260+
src: "{{ item }}"
261+
dest: /etc/profile.d/
262+
mode: 0644
263+
owner: root
264+
group: root
265+
with_fileglob:
266+
- files/bash.d/systeminfo-synology.sh
267+
when: ('os.synology' in group_names)
268+
257269

258270
- blockinfile:
259271
dest: "~{{ username }}/.bashrc"

0 commit comments

Comments
 (0)