Last active
April 6, 2022 23:47
-
-
Save riccardobl/80445ec5e2eb441ce0b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moved to https://github.com/riccardobl/simple-bash-bandwidth-monitor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Moved to https://github.com/riccardobl/simple-bash-bandwidth-monitor | |
${font sans-serif:bold:size=8}SERVERS ${hr 2} | |
${font sans-serif:normal:size=8}IP address: $alignr XXXXXXXXXXXXXXXXXX | |
DLS: ${texeci 5 curl --silent "http://XXXXXXXXXXXXXXXXXX/status.php?t=down&f=HUMAN"} $alignr total: ${texeci 5 curl --silent "http://XXXXXXXXXXXXXXXXXX/status.php?t=total-down&f=HUMAN"} | |
ULS: ${texeci 5 curl --silent "http://XXXXXXXXXXXXXXXXXX/status.php?t=up&f=HUMAN"} $alignr total: ${texeci 5 curl --silent "http://XXXXXXXXXXXXXXXXXX/status.php?t=total-up&f=HUMAN"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Moved to https://github.com/riccardobl/simple-bash-bandwidth-monitor | |
$type=@$_REQUEST['t']; | |
if( $type!=="down" && $type!=="total-down" && $type!=="total-up" ) $type="up"; | |
$format=@$_REQUEST['f']; | |
if( $format !== "HUMAN" && $format!=="GB" && $format!=="MB" && $format!=="KB" ) $format="B"; | |
echo exec("./status.sh $type eth0 $format"); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Moved to https://github.com/riccardobl/simple-bash-bandwidth-monitor | |
type=$1; | |
interface=$2 | |
out_format=$3 | |
data=($(grep $interface /proc/net/dev)) | |
sleep 2 | |
data2=($(grep $interface /proc/net/dev)) | |
if [[ "$type" == *"up"* ]] | |
then | |
id=9 | |
else | |
id=1 | |
fi | |
sa=${data2[$id]} | |
if [[ "$type" == *"total"* ]] | |
then | |
sb=0 | |
else | |
sb=${data[$id]} | |
fi | |
delta=$(( sa - sb )) | |
if [ "$out_format" == "HUMAN" ] | |
then | |
numfmt --to=iec-i --suffix=B $delta | |
elif [ "$out_format" == "GB" ] | |
then | |
echo $delta | awk '{printf "%.2f", $1 / 1024 / 1024 / 1024}' | |
elif [ "$out_format" == "MB" ] | |
then | |
echo $delta | awk '{printf "%.2f", $1 / 1024 / 1024}' | |
elif [ "$out_format" == "KB" ] | |
then | |
echo $delta | awk '{printf "%.2f", $1 / 1024}' | |
else | |
echo $delta | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment