HOME


sh-3ll 1.0
DIR:/proc/self/root/usr/local/lp/bin/telegraf-scripts/
Upload File :
Current File : //proc/self/root/usr/local/lp/bin/telegraf-scripts/server_weight.sh
#!/usr/bin/bash
# This script outputs the serverweight information in an influxdb compatiable method

# current format for serverweight
# [root@cpanel ~]# /usr/local/lp/bin/serverweight.sh today
# 2025-03-30 cpanel.jakdept.dev cpu .28 iowait 1.40 await .18 load95th 0.17 memory 21.58 swap 8.85 runsz 1.50 disk 5.90 users .50 uptime 0 weight 40.36
#
# expected format to go to telegraf:
# server_weight,full_hostname=cpanel.jakdept.dev,lpuid=W4S4LH cpu=0.28,iowait=1.26,await=0.17,load95th=0.36,memory=21.62,swap=8.4,runsz=1.65,disk=5.9,users=0.5,uptime=0,weight=40.14
#
# but like, lpuid is added by lpuid.conf. so:
# - change the timestamp to "full_hostname"
# - reformat the fields into tag format for influx
# - profit?
#

/usr/local/lp/bin/serverweight.sh today 2>/dev/null |
	awk '{$1="full_hostname"}1'|
	/usr/bin/env xargs -L1 printf "server_weight,%s=%s %s=%s,%s=%s,%s=%s,%s=%s,%s=%s,%s=%s,%s=%s,%s=%s,%s=%s,%s=%s,%s=%s\n"