File manager - Edit - /var/www/payraty/helpdesk/public/storage/branding_media/images/byobu.zip
Back
PK ! 퍽zZ Z cpu_freqnu ȯ�� #!/bin/sh -e # # cpu_freq: calculate current cpu frequency # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __cpu_freq_detail() { cat /proc/cpuinfo } __cpu_freq() { local hz freq count if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq fpdiv $hz "1000000" 1 # 1Ghz freq="$_RET" elif [ -r "/proc/cpuinfo" ]; then if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%01.1f", $2 / 1000 }') else # Must scale frequency by number of processors, if counting bogomips count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || grep -ci "^processor" /proc/cpuinfo) freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }') freq=$(printf "%s %s" "$freq" "$count" | awk '{printf "%01.1f\n", $1/$2/1000}') fi elif hz=$(sysctl -n hw.cpufrequency 2>/dev/null); then fpdiv $hz "1000000000" 1 # 1Ghz freq="$_RET" fi [ -n "$freq" ] || return color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color -- } # vi: syntax=sh ts=4 noexpandtab PK ! �N= � � uptimenu ȯ�� #!/bin/sh -e # # uptime: condensed uptime of the machine # # Copyright (C) 2009 Raphaël Pinson. # Copyright (C) 2009 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Raphaël Pinson <raphink@ubuntu.com> # Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __uptime_detail() { uptime } __uptime() { local u= idle= str= if [ -r /proc/uptime ]; then read u idle < /proc/uptime u=${u%.*} elif [ -x /usr/sbin/sysctl ]; then # MacOS support u=$(/usr/sbin/sysctl -n kern.boottime | cut -f4 -d' ' | cut -d',' -f1) u=$(($(date +%s) - $u)) fi if [ "$u" ]; then if [ "$u" -gt 86400 ]; then str="$(($u / 86400))d$((($u % 86400) / 3600))h" elif [ "$u" -gt 3600 ]; then str="$(($u / 3600))h$((($u % 3600) / 60))m" elif [ "$u" -gt 60 ]; then str="$(($u / 60))m" else str="${u}s" fi else # Last ditch hack str=$(uptime | sed -e "s/.* up *//" -e "s/ *days, */d/" -e "s/:/h/" -e "s/,.*/m/") fi [ -n "$str" ] || return color w b; printf "%s" "${str}"; color -- } # vi: syntax=sh ts=4 noexpandtab PK ! �$ $ cpu_tempnu ȯ�� #!/bin/sh -e # # cpu_temp: cpu temperature # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __cpu_temp_detail() { local i for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do [ -r "$i" ] || continue printf "%s\n" "$i:" cat "$i"/* done } __cpu_temp() { local i t unit for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do case "$i" in *temp*_input|*thermal_zone*/temp) [ -s "$i" ] && read t < "$i" && t=$(($t/1000)) ;; *) [ -s "$i" ] && t=$($BYOBU_SED -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i") ;; esac if [ -n "$t" ] && [ "$t" -gt 0 ]; then unit="$ICON_C" if [ "$TEMP" = "F" ]; then t=$(($t*9/5 + 32)) unit="$ICON_F" fi color b k Y; printf "%s" "$t"; color -; color k Y; printf "%s" "$unit"; color -- break fi done } # vi: syntax=sh ts=4 noexpandtab PK ! ��6 6 disknu ȯ�� #!/bin/sh -e # # disk: print the current disk space and usage # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __disk_detail() { df -h -P } __disk() { local out="" MP="" size="" pct="" unit="" # Default to /, but let users override [ -z "$MONITORED_DISK" ] && MP="/" || MP="$MONITORED_DISK" case $MP in /dev/*) MP=$(awk '$1 == m { print $2; exit(0); }' "m=$MP" /proc/mounts);; esac # this could be done faster with 'stat --file-system --format' # but then we'd have to do blocks -> human units ourselves out=$({ df -h -P "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $2, $5); }') set -- ${out} size=${1}; pct=${2}; unit=${size#${size%?}} # get the unit (last char) size=${size%?}; # take the unit off pct=${pct%?}; # take off the '%' case "$unit" in k*|K*) unit="$ICON_KB" ;; m*|M*) unit="$ICON_MB" ;; g*|G*) unit="$ICON_GB" ;; t*|T*) unit="$ICON_TB" ;; esac [ -n "$size" ] || return color b m W; printf "%s" "$size"; color -; color m W; printf "%s" "$unit"; color -; color b m W; printf "%s" "$pct"; color -; color m W; printf "%s" "$PCT"; color --; } # vi: syntax=sh ts=4 noexpandtab PK ! /�6� � updates_availablenu ȯ�� #!/bin/sh -e # # updates_available: calculate and cache the number of updates available # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ___print_updates() { local u= s= read u s < "$1" if [ -n "$u" ]; then if [ "$u" -gt 0 ]; then color b r W; printf "%d" "$u"; color -; color r W if [ -n "$s" ] && [ "$s" -gt 0 ]; then printf "$ICON_SECURITY" else printf "$ICON_UPDATES" fi color -- elif [ "$u" = "0" ] && [ -e "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/updates_available" ]; then # Clear out byobu's status cache rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/updates_available"* fi fi } ___update_cache() { local mycache=$1 flock="$1.lock" # Now we actually have to do hard computational work to calculate updates. # Let's try to be "nice" about it: renice 10 $$ >/dev/null 2>&1 || true ionice -c3 -p $$ >/dev/null 2>&1 || true # These are very computationally intensive processes. # Background this work, have it write to the cache files, # and let the next cache check pick up the results. # Ensure that no more than one of these run at a given time if [ -x /usr/lib/update-notifier/apt-check ]; then # If apt-check binary exists, use it flock -xn "$flock" sh -c "(/usr/lib/update-notifier/apt-check 2>&1 | awk '-F;' 'END { print \$1, \$2 }' >\"${mycache}-x\" 2>/dev/null ; mv \"${mycache}-x\" \"$mycache\")" & elif eval $BYOBU_TEST apt-get >/dev/null; then # If apt-get exists, use it flock -xn "$flock" apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst >$mycache 2>/dev/null & elif eval $BYOBU_TEST pkcon >/dev/null; then # use packagekit to show list of packages LC_ALL=C flock -xn "$flock" pkcon get-updates -p | awk '/^Results:$/ { start=NR }; /^Security/ { security++ }; END { if (!/There are no updates available at this time./) { print NR-start, security }}' > "$mycache" 2>/dev/null & elif eval $BYOBU_TEST zypper >/dev/null; then # If zypper exists, use it flock -xn "$flock" zypper --no-refresh lu --best-effort | grep -c 'v |' >$mycache 2>/dev/null & elif eval $BYOBU_TEST yum >/dev/null; then # If yum exists, use it # TODO: We need a better way of counting updates available from a RH expert flock -xn "$flock" yum list updates -q | grep -vc "Updated Packages" >$mycache 2>/dev/null & elif eval $BYOBU_TEST pacman >/dev/null; then # If pacman (Archlinux) exists, use it LC_ALL=C flock -xn "$flock" pacman -Sup | grep -vc "^\(::\| \)" >$mycache 2>/dev/null & elif eval $BYOBU_TEST opkg >/dev/null; then # If opkg (OpenWrt) exists, use it, also background if flock exists if eval $BYOBU_TEST flock >/dev/null; then flock -xn "$flock" opkg list-upgradable | wc -l >$mycache 2>/dev/null & else opkg list-upgradable | wc -l >$mycache & fi elif eval $BYOBU_TEST brew >/dev/null; then # If homebrew (Mac OSX) exists, use it, also background if flock exists if eval $BYOBU_TEST flock >/dev/null; then flock -xn "$flock" brew outdated | wc -l >$mycache 2>/dev/null & else brew outdated | wc -l >$mycache & fi fi } ___update_needed() { # Checks if we need to update the cache. # TODO: add more distro local mycache=$1 # The cache doesn't exist: create it [ ! -e "$mycache" ] && return 0 if eval $BYOBU_TEST apt-get >/dev/null; then # Debian/ubuntu d0=$(($(stat -c %Y $mycache 2>/dev/null)-5)) d1=$(stat -c %Y /var/lib/apt) d2=$(stat -c %Y /var/lib/apt/lists) d3=$(stat -c %Y /var/log/dpkg.log) now=$(date +%s) delta=$(($now-$d0)) if [ $d0 -lt 0 ] || [ $d0 -lt $d1 ] || [ $d0 -lt $d2 ] || [ $d0 -lt $d3 ] || [ 3605 -lt $delta ] ; then return 0 else return 1 fi elif [ -e "/var/lib/PackageKit/transactions.db" ]; then [ "/var/lib/PackageKit/transactions.db" -nt "$mycache" ] return $? elif eval $BYOBU_TEST pacman >/dev/null; then # Archlinux local db for db in /var/lib/pacman/sync/*.db; do [ "$db" -nt "$mycache" ] && return 0 done return 1 elif eval $BYOBU_TEST opkg >/dev/null; then # OpenWrt [ ! -e /var/lock/opkg.lock ] || return 1 if [ -d /var/opkg-lists ]; then [ /var/opkg-lists -nt "$mycache" ] return $? else local u s read u s < "$mycache" [ "$u" -gt 0 ] return $? fi elif eval $BYOBU_TEST brew >/dev/null; then # Mac OSX # check if any new versions have been installed since # we last cached. this may not recognize formulae # installed with HEAD for f in $(brew --prefix)/Cellar/*; do [ "$f" -nt "$mycache" ] && return 0 done # nothing new has been installed, so check wether the # formulae database was updated [ "$(brew --prefix)/Library/Formula" -nt "$mycache" ] return $? fi return 1 } __updates_available_detail() { if eval $BYOBU_TEST apt-get >/dev/null; then local detail=`apt-get -s -o Debug::NoLocking=true upgrade` if [ "$1" = "--detail" ]; then printf "$detail" else local short=`printf "%s" "$detail" | grep -c ^Inst` printf "$short" fi fi } __updates_available() { local mycache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/updates-available" # If mycache is present, use it [ -r $mycache ] && ___print_updates "$mycache" # If we really need to do so (mycache doesn't exist, or the package database has changed), # background an update now ___update_needed "$mycache" && ___update_cache "$mycache" } # vi: syntax=sh ts=4 noexpandtab PK ! �j j batterynu ȯ�� #!/bin/sh -e # # battery: print the state of the battery # # Copyright (C) 2009 Raphaël Pinson. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Raphaël Pinson <raphink@ubuntu.com> # Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __battery_detail() { local bat for bat in /proc/acpi/battery/*; do cat "$bat/info" cat "$bat/state" done # FIXME: do the same thing with the /sys interface } __battery() { local bat line present sign state percent full rem color bcolor # Linux support present=""; full="0"; rem="0"; state="" for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do case "$bat" in /sys/*) if [ -r "$bat/uevent" ]; then . "$bat/uevent" case "$POWER_SUPPLY_NAME" in AC|ac|Ac|aC) continue ;; esac present="$POWER_SUPPLY_PRESENT" # Some use "CHARGE", others use "ENERGY", still others "CAPACITY" [ -n "$POWER_SUPPLY_CHARGE_FULL" ] && full=$((POWER_SUPPLY_CHARGE_FULL+full)) [ -n "$POWER_SUPPLY_ENERGY_FULL" ] && full=$((POWER_SUPPLY_ENERGY_FULL+full)) [ -n "$POWER_SUPPLY_CHARGE_NOW" ] && rem=$((POWER_SUPPLY_CHARGE_NOW+rem)) [ -n "$POWER_SUPPLY_ENERGY_NOW" ] && rem=$((POWER_SUPPLY_ENERGY_NOW+rem)) if [ -n "$POWER_SUPPLY_CAPACITY" ] && [ ! -n "$POWER_SUPPLY_ENERGY_NOW" ] && [ ! -n "$POWER_SUPPLY_CHARGE_NOW" ]; then rem="$POWER_SUPPLY_CAPACITY" && full="100" fi [ "$POWER_SUPPLY_STATUS" != "Unknown" ] && state="$POWER_SUPPLY_STATUS" fi ;; /proc/*) [ -f "$bat/info" ] || continue while read line; do set -- ${line} case "$line" in present:*) # make sure that this battery is present [ "$2" = "no" ] && continue 2 present="$2";; last\ full\ capacity:*) full="$4";; esac [ -n "$present" -a -n "$full" ] && break done < "${bat}/info" while read line; do set -- ${line} case "$line" in remaining\ capacity:*) rem="$3";; charging\ state:*) state="$3";; esac [ -n "$rem" -a -n "$state" ] && break done < "$bat/state" [ -n "$full" ] && [ -n "$rem" ] && [ -n "$state" ] && break ;; esac done # Mac OS X support if eval $BYOBU_TEST /usr/sbin/ioreg >/dev/null 2>&1; then # MacOS support local key for key in CurrentCapacity MaxCapacity ExternalChargeCapable FullyCharged; do line=$(/usr/sbin/ioreg -n AppleSmartBattery -w0 | grep $key | sed -e 's/|//g' | awk '{ print $3 }') case "$key" in CurrentCapacity) rem="$line";; MaxCapacity) full="$line";; ExternalChargeCapable) if [ "${line}" = "Yes" ]; then state="charging" elif [ "${line}" = "No" ]; then state="discharging" fi ;; FullyCharged) if [ "${line}" = "Yes" ]; then state="charged" fi ;; esac done fi if [ $rem -ge 0 ] && [ $full -gt 0 ]; then percent=$(((100*$rem)/$full)) if [ "$percent" -lt 33 ]; then color="R w" bcolor="b R w" elif [ "$percent" -lt 67 ]; then color="Y k" bcolor="b Y k" else color="G k" bcolor="b G k" fi percent="${percent}${PCT}" # Convert state to lower case state=$(printf "%s" "$state" | $BYOBU_SED 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/') case $state in charging) sign="+" ;; discharging) sign="-" ;; charged|unknown|full) sign="=" ;; *) sign="$state" ;; esac if [ -z "$percent" ]; then rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/battery"* return fi color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- fi } # vi: syntax=sh ts=4 noexpandtab PK ! Ĩ �s s memorynu ȯ�� #!/bin/sh -e # # mem_available: grab the current memory and usage # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __memory_detail() { free } __memory() { local free="" total="" buffers="" cached="" local kb_main_used=0 buffers_plus_cached=0 fo_buffers=0 fo_cached=0 if [ -r /proc/meminfo ]; then while read tok val unit; do case "$tok" in MemTotal:) total=${val};; MemFree:) free=${val};; Buffers:) buffers=${val};; Cached:) cached=${val};; esac [ -n "${free}" -a -n "${total}" -a -n "${buffers}" -a -n "${cached}" ] && break; done < /proc/meminfo elif eval $BYOBU_TEST vm_stat >/dev/null 2>&1; then # MacOS support # calculation borrowed from http://apple.stackexchange.com/a/48195/18857 free_blocks=$(vm_stat | grep free | awk '{ print $3 }' | sed -e 's/\.//') inactive_blocks=$(vm_stat | grep inactive | awk '{ print $3 }' | sed -e 's/\.//') speculative_blocks=$(vm_stat | grep speculative | awk '{ print $3 }' | sed -e 's/\.//') free=$((($free_blocks+speculative_blocks)*4)) inactive=$(($inactive_blocks*4)) total=$((($free+$inactive))) buffers=0 cached=0 fi kb_main_used=$(($total-$free)) buffers_plus_cached=$(($buffers+$cached)) # "free output" buffers and cache (output from 'free') fo_buffers=$(($kb_main_used - $buffers_plus_cached)) fpdiv $((100*${fo_buffers})) "${total}" 0; usage=${_RET} if [ $total -ge 1048576 ]; then fpdiv "$total" 1048567 1 total=${_RET} unit="$ICON_GB" elif [ $total -ge 1024 ]; then fpdiv "$total" 1024 0 total=${_RET} unit="$ICON_MB" else unit="$ICON_KB" fi if [ $usage -gt 90 ]; then # Change foreground to yellow, if usage over 90% fg="Y" else fg="W" fi [ -n "$total" ] || return color b g W; printf "%s" "$total"; color -; color g W; printf "%s" "$unit"; color -; color b g "$fg"; printf "%s" "$usage"; color -; color g "$fg"; printf "%s" "$PCT"; color -- } # vi: syntax=sh ts=4 noexpandtab PK ! ��`+h h networknu ȯ�� #!/bin/sh -e # # network: calculate the network up/down rates # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __network_detail() { get_network_interface; local interface="$_RET" LC_ALL=C /sbin/ip addr show "$interface" | $BYOBU_SED 's/\s*$//' } __network() { get_network_interface; local interface="$_RET" local x1=0 x2=0 tx1=0 i= t= unit= symbol= cache= rate= status_freq network t="$_RET" # By default, we won't bug the user with the display of network traffic # below NETWORK_THRESHOLD in kbps; override in $BYOBU_CONFIG_DIR/status [ -n "$NETWORK_THRESHOLD" ] || NETWORK_THRESHOLD=20 for i in up down; do unit="kb" case $i in up) symbol="$ICON_UP" ;; down) symbol="$ICON_DN" ;; esac cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/network.$i" [ -r "$cache" ] && read x1 < "$cache" || tx1=0 local iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed cat /proc/net/dev > "$cache".dev while read iface rbytes rpackets rerrs rdrop rfifo rframe rcompressed rmulticast tbytes tpackets terrs tdrop tfifo tcolls tcarrier tcompressed; do case "$iface" in ${interface}:) [ "$i" = "up" ] && x2=${tbytes} || x2=${rbytes} break; ;; ${interface}:*) # Interface and tbytes got munged together [ "$i" = "up" ] && x2=${rmulticast##*:} || x2=${iface##*:} break; ;; esac done < "$cache".dev printf "%s" "$x2" > "$cache" rate=$((8*($x2 - $x1) / $t / 1024)) # in kbps [ "$rate" -lt 0 ] && rate=0 if [ $rate -gt $NETWORK_THRESHOLD ]; then case "$NETWORK_UNITS" in bytes) rate=$(($rate/8)) if [ "$rate" -gt 1048576 ]; then fpdiv "$rate" 1048576 1 rate=${_RET} unit="GB/s" elif [ "$rate" -gt 1024 ]; then fpdiv "$rate" 1024 1 rate=${_RET} unit="MB/s" else unit="kB/s" fi ;; *) # Default to bps # Why 1000 and not 1024? http://en.wikipedia.org/wiki/Data_rate_units if [ "$rate" -gt 1000000 ]; then fpdiv "$rate" 1000000 1 rate=${_RET} unit="Gb" elif [ "$rate" -gt 1000 ]; then fpdiv "$rate" 1000 1 rate=${_RET} unit="Mb" fi ;; esac [ -n "$rate" ] || continue color b m w; printf "%s%s" "$symbol" "$rate"; color -; color m w; printf "%s" "$unit"; color -- else rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/network"* fi done } # vi: syntax=sh ts=4 noexpandtab PK ! .�S�b b servicesnu ȯ�� #!/bin/sh -e # # services: show what services are running on this server (configurable) # # Copyright (C) 2009 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __services_detail() { return } service_running() { if [ -f "/etc/init/$1.conf" ]; then # Use upstart case "$(status $1 2>/dev/null)" in *running*) true ;; *) false ;; esac elif [ -f "/etc/init.d/$1" ]; then # Fall back to sysvinit /etc/init.d/$1 status >/dev/null 2>&1 else false fi } __services() { local services="$SERVICES" # Users can define a list of services to monitor in $BYOBU_CONFIG_DIR/status if [ -z "$services" ]; then if [ -f "/etc/eucalyptus/eucalyptus.conf" ]; then # If the user has not defined any services, but this system is a # UEC system, default to the list of Ubuntu Enterprise Cloud Services services="eucalyptus-cloud|CLC eucalyptus-walrus|WC eucalyptus-cc|CC eucalyptus-sc|SC eucalyptus-nc|NC" fi fi output= for i in $services; do service=${i%|*} nick=${i#*|} case "$service" in eucalyptus-nc) if service_running $service; then # This is a node controller, determine VM usage . /etc/eucalyptus/eucalyptus.conf count=$(pgrep -c -f /usr/bin/kvm || true) output="$output,NC:$count" fi ;; *) service_running $service && output="$output,$nick" ;; esac done [ -n "$output" ] || return color w c; printf "%s" ${output#,}; color -- } # vi: syntax=sh ts=4 noexpandtab PK ! "��� � customnu ȯ�� #!/bin/sh -e # # custom: run the user's custom status scripts # # Copyright (C) 2009 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __custom_detail() { return } __custom() { local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/custom" local i= output= for i in "$BYOBU_CONFIG_DIR/bin/"[0-9]*_*; do # Loop over custom scripts # Ensure executable [ -x "$i" ] || continue # Ignore vim backup files ending in ~ case "$i" in *~) continue ;; esac local now="$(date +%s)" local script=${i##*/} local freq=${script%%_*} freq=${freq#0} local lastrun= [ -r "$cache.$script.last" ] && read lastrun < "$cache.$script.last" || lastrun=0 local expiration=$(($lastrun+$freq)) if [ $now -ge $expiration ]; then "$i" > "$cache.$script" 2>/dev/null printf "%s\n" "${now}" > "$cache.$script.last" fi readfile < "$cache.$script" local str="${_RET}" case "$str" in *"$ESC{"*) # User has formatted the colors output="$output$(printf "$str")" ;; *) # Default coloring output="$output$str " ;; esac done if [ -z "$output" ]; then rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/custom"* return fi printf "$output" | $BYOBU_SED ':a;N;$!ba;s/\n//g' } # vi: syntax=sh ts=4 noexpandtab PK ! ��2$ $ distronu ȯ�� #!/bin/sh -e # # distro: grab the distro/os # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __distro_detail() { lsb_release -a 2>/dev/null } __distro() { local DISTRO="${DISTRO}" if [ -n "$DISTRO" ]; then # user defined true else DISTRO="$BYOBU_DISTRO" fi color bold2; printf "%s" "$DISTRO"; color -- } # vi: syntax=sh ts=4 noexpandtab PK ! ���f f fan_speednu ȯ�� #!/bin/sh -e # # fan_speed: speed of the cpu or case fan # # Copyright (C) 2009 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __fan_speed_detail() { # Nothing interesting to say here about fan speed return } __fan_speed() { local i="" speed=0 # Let's check a few different probes for fan speed # This seems to cover most of them: for i in $FAN /sys/class/hwmon/*/*/fan1_input /sys/class/hwmon/*/device/hwmon/*/fan1_input; do [ -f "$i" ] || continue read speed < "$i" if [ -n "$speed" ] && [ "$speed" -gt 0 ]; then color bold1; printf "%s" "$speed"; color -; color none; printf "rpm"; color -- return 0 fi done # But others (e.g. Dell Inspirons) seem to be here: if [ -r /proc/i8k ]; then local line="" read line < /proc/i8k set -- $line for speed in $7 $8; do if [ -n "$speed" ] && [ "$speed" -gt 0 ]; then # I8K_FAN_MULT defaults to 30 (buggy BIOS workaround?), # use `modprobe i8k fan_mult=1` to disable if unneeded, # resulting in nonsensical speeds [ "$speed" -gt 10000 ] && speed=$((${speed} / 30)) color bold1; printf "%s" "$speed"; color -; color none; printf "rpm"; color -- return 0 fi done fi } # vi: syntax=sh ts=4 noexpandtab PK ! ��ys s menunu ȯ�� #!/bin/sh -e # # menu: display the menu text # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland <kirkland@byobu.org> # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __menu_detail() { return } __menu() { local bindings esc key text [ -r "$BYOBU_CONFIG_DIR/keybindings" ] && bindings="$BYOBU_CONFIG_DIR/keybindings" || bindings="$BYOBU_CONFIG_DIR/.screenrc" if grep -qs "^source.*screen-escape-keys$" $bindings 2>/dev/null || grep -qs "^source.*f-keys.screen.disable$" $bindings 2>/dev/null || [ "$1" = "--disable-f-keys" ]; then # Get the second to last byte from the "escape" option esc=`grep "^escape" $bindings | tail -c 3 | head -c 1` [ -n "$esc" ] && key="^$esc-@" || key="^a-@" elif grep -qs "^source.*none$" $bindings 2>/dev/null; then key="byobu-config" else key="F9" fi text=$(gettext "Menu" 2>/dev/null) || text="Menu" color k w; printf "%s:<" "$text"; color -; color b k w; printf "%s" "$key"; color k w; printf ">" } # vi: syntax=sh ts=4 noexpandtab PK ! T���P P releasenu ȯ�� #!/bin/sh -e # # release: grab the os/distro release version # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __release_detail() { lsb_release -a 2>/dev/null } __release() { local RELEASE="${RELEASE}" if [ -n "$RELEASE" ]; then # user defined true elif [ -r "/etc/os-release" ]; then # lsb_release is *really* slow; try to use /etc/os-release RELEASE=$(. /etc/os-release && echo "$VERSION_ID") elif [ -r "/etc/issue" ]; then # next try /etc/issue first local issue read issue < /etc/issue case "$issue" in Ubuntu*) set -- $issue; RELEASE="$2"; ;; Debian*) local ver read ver < /etc/debian_version RELEASE="$ver" ;; esac elif eval $BYOBU_TEST sw_vers >/dev/null 2>&1; then RELEASE="$(sw_vers -productVersion)" fi if [ -z "$RELEASE" ] && eval $BYOBU_TEST lsb_release >/dev/null 2>&1; then # If lsb_release is available, use it RELEASE=$(lsb_release -s -r) fi if [ -n "$RELEASE_ABBREVIATED" ] && [ $RELEASE_ABBREVIATED -gt 0 ]; then color bold2; printf "%.${RELEASE_ABBREVIATED}s" "$RELEASE"; color -- else color bold2; printf "%s" "$RELEASE"; color -- fi } # vi: syntax=sh ts=4 noexpandtab PK ! ��&�� � hostnamenu ȯ�� #!/bin/sh -e # # hostname: report a host's name # # Copyright (C) 2008-2011 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __hostname_detail() { hostname -f 2>/dev/null } __hostname() { local h= if eval $BYOBU_TEST hostname >/dev/null 2>&1; then h=$(hostname -s 2>/dev/null || hostname) elif [ -r /proc/sys/kernel/hostname ]; then read h < /proc/sys/kernel/hostname fi if metadata_available; then local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/hostname" # Background a retrieval of our public hostname timeout 0.2 wget -q -O- http://169.254.169.254/latest/meta-data/public-hostname </dev/null >"$cache" 2>/dev/null & sleep 0.02 [ -s "$cache" ] && read h < "$cache" fi [ -n "$h" ] || return color bold2; printf "%s" "$h"; color -- } # vi: syntax=sh ts=4 noexpandtab PK ! F�Y� � logonu ȯ�� #!/bin/sh -e # # logo: determine which logo to use # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __logo_detail() { MARKUP="false" __logo } __logo() { local logo= if [ -n "$LOGO" ]; then # Allow users to define their own logo in $BYOBU_CONFIG_DIR/status printf "%s" "$LOGO" return fi local distro="$(printf "%s" "$BYOBU_DISTRO" | $BYOBU_SED 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')" case "$distro" in *ubuntu*) if $MARKUP; then if [ "$BYOBU_BACKEND" = "tmux" ] && [ "$BYOBU_CHARMAP" = "UTF-8" ]; then if [ ! "$VTE_CJK_WIDTH" = "1" ] && [ ! "$VTE_CJK_WIDTH" = "wide" ] ; then # color "colour202" "colour255" ; printf " u "; color - # Ubuntu's logo doesn't display anywhere, except for on Ubuntu itself, which has the Ubuntu font with the logo # which breaks when you ssh into Ubuntu from elsewhere (Windows, Debian, Mac) color "colour202" "colour255" ; printf " u "; color - else color m W; printf " u "; color - fi else color m W; printf " u "; color - fi else printf " u " fi ;; *alpine*) logo=" /\\\\\\\\ " $MARKUP && printf "$(color b b W)%s$(color -)" "$logo" || printf "$logo" ;; *altlinux*) logo="alt" $MARKUP && printf "$(color Y k)%s$(color -)" "$logo" || printf "$logo" ;; *arch*) logo=" A " $MARKUP && printf "$(color b w b)%s$(color -)" "$logo" || printf "$logo" ;; *centos*) if [ "$BYOBU_BACKEND" = "tmux" ] && [ "$BYOBU_CHARMAP" = "UTF-8" ]; then logo="※ " $MARKUP && printf "$(color w m)※ $(color -)" || printf "$logo" else $MARKUP && printf "$(color g w)*$(color -)$(color m w)*$(color -)$(color y w)*$(color -)$(color b w)*$(color -)" || printf "$logo" fi ;; *debian*) logo=" @ " $MARKUP && printf "$(color w r)%s$(color -)" "$logo" || printf "$logo" ;; *fedora*) logo=" f " $MARKUP && printf "$(color b w)%s$(color -)" "$logo" || printf "$logo" ;; *foresight*) logo="<@>" $MARKUP && printf "$(color b W g)%s$(color -)" "$logo" || printf "$logo" ;; *gentoo*) logo=" > " $MARKUP && printf "$(color b c w)%s$(color -)" "$logo" || printf "$logo" ;; *glinux*) logo=" G " # Green: 3cba54=71, Yellow: f4c20d=214, Red: db3236=167, Blue: 4885ed=69 $MARKUP && printf "$(color colour0 colour69)██$(color colour0 colour167)■$(color colour0 colour214)■$(color colour0 colour69)▄$(color colour0 colour71)█$(color colour0 colour167)■$(color -)" || printf "$logo" ;; *mac*|*darwin*) if [ "$BYOBU_BACKEND" = "tmux" ] && [ "$BYOBU_CHARMAP" = "UTF-8" ]; then # The Apple option character #logo=" ⌘ " # The Apple logo -- only visible from Mac terminals logo=" " else logo=" X " fi $MARKUP && printf "$(color w k)%s$(color -)" "$logo" || printf "$logo" ;; *mandriva*) logo=" (* " $MARKUP && printf "$(color b k c) ($(color -)$(color b k y)*$(color -) " || printf "$logo" ;; *mint*) logo=" lm " $MARKUP && printf "$(color g w)$logo$(color -)$(color g w)$(color -) " || printf "$logo" ;; *openwrt*) logo="OWrt" $MARKUP && printf "$(color b colour66 W)%s$(color -)" "$logo" || printf "$logo" ;; *raspbian*) logo=" @ " $MARKUP && printf "$(color colour125 colour15)%s$(color -)" "$logo" || printf "$logo" ;; *red*hat*|*rhel*) logo=" RH " $MARKUP && printf "$(color R k)%s$(color -)" "$logo" || printf "$logo" ;; *rockhopper*) logo="palm" $MARKUP && printf "$(color k w)%s$(color -)" "$logo" || printf "$logo" ;; *slackware*) logo=".S " $MARKUP && printf "$(color u B k)%s$(color -)" "$logo" || printf "$logo" ;; *suse*) logo="SUSE" $MARKUP && printf "$(color W g)%s$(color -)" "$logo" || printf "$logo" ;; *xandros*) logo=" X " $MARKUP && printf "$(color W r)%s$(color -)" "$logo" || printf "$logo" ;; *) if [ "$BYOBU_BACKEND" = "tmux" ] && [ "$BYOBU_CHARMAP" = "UTF-8" ]; then logo="〣" else logo="[B]" fi $MARKUP && printf "$(color b k W)%s$(color -)" "$logo" || printf " $logo " ;; esac printf " " } # vi: syntax=sh ts=4 noexpandtab PK ! ih=; ; * include/tmux-detach-all-but-current-clientnu ȯ�� #!/bin/sh # # tmux-detach-all-but-current-client # Copyright (C) 2013-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. a1= a2= tty1= tty2= # List all clients, ordered by most recent activity descending for c in $(tmux list-clients -F "#{client_activity}___#{client_tty}" | sort -n -r); do if [ -z "$a1" ]; then a1=${c%%___*} tty1=${c##*___} elif [ -z "$a2" ]; then a2=${c%%___*} tty2=${c##*___} fi if [ -n "$a1" ] && [ -n "$a2" ]; then if [ "$a1" = "$a2" ]; then # Activity timestamps match in top 2 attached clients # Let's not detach anyone here! tmux display-message "Multiple active attached clients detected, refusing to detach" >/dev/null 2>&1 elif [ -n "$tty1" ]; then # Detach all but the current client, iterating across each # Tempting to use detach-client -a -t here, but there's a bug # in there, keeping that from working properly tmux detach-client -t "$tty2" >/dev/null 2>&1 a2= fi fi done PK ! �Ȯu"