Browse Source

initial commit with some tools..

master
tuxd3v 2 months ago
parent
commit
a373dff341
8 changed files with 183 additions and 4 deletions
  1. +0
    -4
      README.md
  2. +26
    -0
      docs/README.md
  3. +3
    -0
      etc/update-motd.d/10-uname
  4. +5
    -0
      etc/update-motd.d/20-devuan
  5. +11
    -0
      etc/update-motd.d/README
  6. +15
    -0
      etc/update-motd.d/gen-20-devuan
  7. +3
    -0
      etc/update-motd.d/gen-30-monitor
  8. +120
    -0
      usr/local/bin/monitor

+ 0
- 4
README.md View File

@@ -1,4 +0,0 @@
# extras

Performance,Utilities,Monitoring, etc tools for Devuan
This tools will be used in Single Board Computers and maybe others device images..

+ 26
- 0
docs/README.md View File

@@ -0,0 +1,26 @@
# Extras
---

Performance,Utilities,Monitoring, etc tools for Devuan..
This tools will be used in Single Board Computers and maybe others device images..

#### Table of contents
* [Introduction](#introduction)
* [Characteristics](#characteristics)
* [Maintainer](#maintainer)

### Introduction:
----
This repository will hold tools to support Devuan images..

Since motd, to Temperature readings, etc

### Characteristics:
----
* motd for devuan Beowulf **/etc/update-motd.d/{10-uname,20-devuan}**
* UPS monitoring for Olimex Olime2 **/etc/update-motd.d/30-monitor**

### Maintainer
----
maintainer: tuxd3v


+ 3
- 0
etc/update-motd.d/10-uname View File

@@ -0,0 +1,3 @@
#!/bin/sh
cat /etc/update-motd.d/20-devuan
uname -snrvm

+ 5
- 0
etc/update-motd.d/20-devuan View File

@@ -0,0 +1,5 @@
 ____ ____ __ ___ _ _ __ _ 
| _ \| ____\ \ / / | | | / \ | \ | | __ _ _ __ _ __ ___ 
| | | | _| \ \ / /| | | |/ _ \ | \| |/ _` | '__| '_ ` _ \ 
| |_| | |___ \ V / | |_| / ___ \ | |\ | (_| | | | | | | | |
|____/|_____| \_/ \___/_/ \_\ _| \__|\__,_|_| |_| |_| |_|

+ 11
- 0
etc/update-motd.d/README View File

@@ -0,0 +1,11 @@

# Permissions and localtion of files..
# ---

# ls -l /etc/update-motd.d/{10-uname,20-devuan}
-rwxr-xr-x 1 root root 56 Jan 1 1970 /etc/update-motd.d/10-uname
-rw-r--r-- 1 root root 530 Jan 1 1970 /etc/update-motd.d/20-devuan

$ ls -l /etc/update-motd.d/30-monitor
lrwxrwxrwx 1 root root 22 May 21 2020 /etc/update-motd.d/30-monitor -> /usr/local/bin/monitor


+ 15
- 0
etc/update-motd.d/gen-20-devuan View File

@@ -0,0 +1,15 @@
#! /bin/sh

# Maintainer: tuxd3v <tuxd3v@sapo.pt>

# Execute this cript on the target machine to create '/etc/update-motd.d/20-devuan'
# Logout and Login again to see the efect

echo -en "\033[1;35m ____ ____\033[0m\033[1;31m __ ___ _ _ \033[0m\033[1;35m__ _ \033[0m\n" > /etc/update-motd.d/20-devuan
echo -en "\033[1;35m| _ \| ____\033[0m\033[1;31m\ \ / / | | | / \ \033[0m\033[1;35m| \ | |\033[0m\033[0;32m __ _ _ __ _ __ ___ \033[0m\n" >> /etc/update-motd.d/20-devuan
echo -en "\033[1;35m| | | | _|\033[0m\033[1;31m \ \ / /| | | |/ _ \ \033[0m\033[1;35m| \| |\033[0m\033[0;32m/ _\` | '__| '_ \` _ \ \033[0m\n" >> /etc/update-motd.d/20-devuan
echo -en "\033[1;35m| |_| | |___\033[0m\033[1;31m \ V / | |_| / ___ \ \b\033[0m\033[1;35m| |\ \033[0m\033[0;32m| (_| | | | | | | | |\033[0m\n" >> /etc/update-motd.d/20-devuan
echo -en "\033[1;35m|____/|_____|\033[0m\033[1;31m \_/\033[0m \033[1;31m\___/_/\033[0m \033[1;31m\_\ \b\033[0m\033[1;35m_| \__|\033[0m\033[0;32m\__,_|_| |_| |_| |_|\033[0m\n" >> /etc/update-motd.d/20-devuan

# This will call in '/etc/update-motd.d/10-uname' the content above
sed '1icat /etc/update-motd.d/20-devuan' /etc/update-motd.d/10-uname

+ 3
- 0
etc/update-motd.d/gen-30-monitor View File

@@ -0,0 +1,3 @@
#! /bin/sh

ln -s /usr/local/bin/monitor /etc/update-motd.d/30-monitor

+ 120
- 0
usr/local/bin/monitor View File

@@ -0,0 +1,120 @@
#! /usr/bin/awk -f

# Maintainer: tuxd3v@sapo.pt
# 2020/05/20

# LAst Colummn is dynamic in size
function state(a,b) {
switch (b) {
case "Discharging":
if( a == "spacing" )
a="-----------"
else if( a == "State" )
a=" State "
else if( a == "AC" )
a=" \033[1;31mUnplugged\033[0m "
else if( a == "bat_state" )
a="\033[1;33m"b"\033[0m"
break
case "Charging":
if( a == "spacing" )
a="--------"
else if( a == "State" )
a=" State "
else if( a == "AC" )
a=" \033[1;32mAC\033[0m "
else if( a == "bat_state" )
a="\033[1;33m"b"\033[0m"
break
case "Full":
if( a == "spacing" )
a="-----"
else if( a == "State" )
a="State"
else if( a == "AC" )
a=" \033[1;32mAC\033[0m "
else if( a == "bat_state" )
a="\033[1;32m"b"\033[0m "
break
case "Not charging":
if( a == "spacing" )
a="------------"
else if( a == "State" )
a=" State "
else if( a == "AC" )
a=" \033[1;32mAC\033[0m "
else if( a == "bat_state" )
a=b
break
default:
a="------"
break
}
return a
}

# First Colummn is dynamic in size bellow 10
function capacity(a) {
if( a < 10 )
return " "
else if( a < 100 )
return " "
else
return ""
}

BEGIN {
source[ "HWMON0" ] = "hwmon0"
source[ "HWMON1" ] = "hwmon1"
getline check < "/sys/class/hwmon/hwmon1/name"
if( check == "axp20x_ac" ){
source[ "HWMON0" ] = "hwmon1"
source[ "HWMON1" ] = "hwmon0"
source[ "AC_name" ] = check
getline source[ "BATTERY_name" ] < sprintf( "/sys/class/hwmon/%s/name", source[ "HWMON1" ] )
}else{
getline source[ "AC_name" ] < sprintf( "/sys/class/hwmon/%s/name", source[ "HWMON0" ] )
source[ "BATTERY_name" ] = check
}
getline source[ "AC_type" ] < sprintf( "/sys/class/hwmon/%s/device/type", source[ "HWMON0" ] )
getline source[ "AC_present" ] < sprintf( "/sys/class/hwmon/%s/device/present", source[ "HWMON0" ] )
getline source[ "AC_online" ] < sprintf( "/sys/class/hwmon/%s/device/online", source[ "HWMON0" ] )
getline source[ "AC_health" ] < sprintf( "/sys/class/hwmon/%s/device/health", source[ "HWMON0" ] )
getline source[ "AC_voltage_now" ] < sprintf( "/sys/class/hwmon/%s/device/voltage_now", source[ "HWMON0" ] )
getline source[ "AC_current_now" ] < sprintf( "/sys/class/hwmon/%s/device/current_now", source[ "HWMON0" ] )

getline source[ "BATTERY_type" ] < sprintf( "/sys/class/hwmon/%s/device/type", source[ "HWMON1" ] )
getline source[ "BATTERY_capacity" ] < sprintf( "/sys/class/hwmon/%s/device/capacity", source[ "HWMON1" ] )
getline source[ "BATTERY_status" ] < sprintf( "/sys/class/hwmon/%s/device/status", source[ "HWMON1" ] )
getline source[ "BATTERY_present" ] < sprintf( "/sys/class/hwmon/%s/device/present", source[ "HWMON1" ] )
getline source[ "BATTERY_online" ] < sprintf( "/sys/class/hwmon/%s/device/online", source[ "HWMON1" ] )
getline source[ "BATTERY_health" ] < sprintf( "/sys/class/hwmon/%s/device/health", source[ "HWMON1" ] )
getline source[ "BATTERY_voltage_now" ] < sprintf( "/sys/class/hwmon/%s/device/voltage_now", source[ "HWMON1" ] )
getline source[ "BATTERY_current_now" ] < sprintf( "/sys/class/hwmon/%s/device/current_now", source[ "HWMON1" ] )

#Pass Values to Units
source[ "AC_voltage_now" ] = source[ "AC_voltage_now" ]/1000000
source[ "AC_current_now" ] = source[ "AC_current_now" ]/1000000
source[ "BATTERY_voltage_now" ] = source[ "BATTERY_voltage_now" ]/1000000
source[ "BATTERY_current_now" ] = source[ "BATTERY_current_now"]/1000000

# Get Dev1 Version
getline Dev1ver < "/etc/devuan_version"

# Correct Battery Capacity when battery offline
if( source["BATTERY_present"] == 0 && source["BATTERY_present"] == 0 )
source["BATTERY_capacity"] = 0

print "+----------------------------+"
printf "| \033[1;35mDE\033[1;31mVUA\033[1;35mN\033[1;32marm\033[0m \033[1;31m%s\033[0m |\n", Dev1ver
printf "+--------------+-------------+---------+--------+------------+------------+%s+\n", state("spacing", source["BATTERY_status"])
printf "| PowerSource | Capacity[%] | Present | Online | Voltage[V] | Current[A] |%s|\n", state("State", source["BATTERY_status"])
printf "+--------------+-------------+---------+--------+------------+------------+%s+\n", state("spacing", source["BATTERY_status"])
printf "|%s | %s | %d | %d | %.4f | %.4f |%s|\n", source["AC_name"],"NA",source["AC_present"],source["AC_online"],source["AC_voltage_now"],source["AC_current_now"], state("AC", source["BATTERY_status"])
printf "+--------------+-------------+---------+--------+------------+------------+%s+\n", state("spacing", source["BATTERY_status"])
printf "|%s| %.4f%s | %d | %d | %.4f | %.4f |%s|\n", source["BATTERY_name"],source["BATTERY_capacity"],capacity(source["BATTERY_capacity"]),source["BATTERY_present"],source[ "BATTERY_online"],source["BATTERY_voltage_now"],source[ "BATTERY_current_now" ], state("bat_state", source["BATTERY_status"])
printf "+--------------+-------------+---------+--------+------------+------------+%s+\n", state("spacing", source["BATTERY_status"])
exit 0
}


Loading…
Cancel
Save