luca219

  • Content Count

    32
  • Joined

  • Last visited

Reputation Activity

  1. Like
    luca219 got a reaction from technik007_cz in Cubietruck Battery monitor with nagios   
    hi all,
    if someone need, I adapted for nagios the script to monitor battery cubietruck.
    The script is pnp4nagios friendly.
    #!/bin/bash ###################################################################################### # # Battery info # /usr/sbin/i2cset -y -f 0 0x34 0x82 0xC3 # read power OPERATING MODE register @01h POWER_OP_MODE=$(/usr/sbin/i2cget -y -f 0 0x34 0x01) BAT_EXIST=$(($(($POWER_OP_MODE&0x20))/32)) # divide by 32 is like shifting rigth 5 times CHARG_IND=$(($(($POWER_OP_MODE&0x40))/64)) # divide by 64 is like shifting rigth 6 times ######################################################################################## #read battery voltage 79h, 78h 0 mV -> 000h, 1.1 mV/bit FFFh -> 4.5045 V BAT_VOLT_LSB=$(/usr/sbin/i2cget -y -f 0 0x34 0x79) BAT_VOLT_MSB=$(/usr/sbin/i2cget -y -f 0 0x34 0x78) BAT_BIN=$(( $(($BAT_VOLT_MSB << 4)) | $(($(($BAT_VOLT_LSB & 0xF0)) >> 4)) )) BAT_VOLT=$(echo "($BAT_BIN*1.1)"|bc) # store maximum battery voltage to compare to if [ -f "/etc/default/battery" ]; then source "/etc/default/battery" else echo "MAX=$BAT_VOLT" > /etc/default/battery echo "MIN=3484" >> /etc/default/battery fi # integer is enough, cut down the decimals MAX=${MAX%.*} BAT_VOLT=${BAT_VOLT%.*} # mainline kernel shows battery existence even if not exists. this is walkaround if [ "$BAT_VOLT" -ge "3200" ]; then # if we have new max value, alter defaults if [ "$BAT_VOLT" -gt "$MAX" ]; then MAX=$BAT_VOLT sed -e 's/MAX=.*/MAX='$BAT_VOLT'/g' -i /etc/default/battery fi # if we have new min value, alter defaults if [ "$BAT_VOLT" -lt "$MIN" ]; then MIN=$BAT_VOLT sed -e 's/MIN=.*/MIN='$BAT_VOLT'/g' -i /etc/default/battery fi # calculate percentage percent=$(echo "($BAT_VOLT-$MIN)*100/($MAX-$MIN)"|bc) fi # define output format output="Load : $percent% | Load_Batt=$percent;80;35;3.4;4.2;" # if load% in range 80-10 ok if [ "$percent" -ge 80 -a "$percent" -le 100 ]; then echo "OK- $output" exit 0 # if load % in range 40-79 warning elif [ "$percent" -ge 40 -a "$percent" -le 79 ]; then echo "WARNING - $output" exit 1 # if load % in range 0-39 critical elif [ "$percent" -ge 0 -a "$percent" -le 39 ]; then echo "CRITICAL - $output" exit 2 # if check non riceve data else echo "UNKNOW" exit 3 fi if run script for non admin user need add permission to  /usr/sbin/iscget
    ex:
    chmod 777 /usr/sbin/iscget and change default permission for /dev/i2c-0
    ex:
    sudo nano /lib/udev/rules.d/60-i2c-tools.rules KERNEL=="i2c-0" , GROUP="i2c", MODE="0660" to
    KERNEL=="i2c-0" , GROUP="i2c", MODE="0666" and reboot
     
     
     

  2. Like
    luca219 got a reaction from tkaiser in Cubietruck Battery monitor with nagios   
    hi all,
    if someone need, I adapted for nagios the script to monitor battery cubietruck.
    The script is pnp4nagios friendly.
    #!/bin/bash ###################################################################################### # # Battery info # /usr/sbin/i2cset -y -f 0 0x34 0x82 0xC3 # read power OPERATING MODE register @01h POWER_OP_MODE=$(/usr/sbin/i2cget -y -f 0 0x34 0x01) BAT_EXIST=$(($(($POWER_OP_MODE&0x20))/32)) # divide by 32 is like shifting rigth 5 times CHARG_IND=$(($(($POWER_OP_MODE&0x40))/64)) # divide by 64 is like shifting rigth 6 times ######################################################################################## #read battery voltage 79h, 78h 0 mV -> 000h, 1.1 mV/bit FFFh -> 4.5045 V BAT_VOLT_LSB=$(/usr/sbin/i2cget -y -f 0 0x34 0x79) BAT_VOLT_MSB=$(/usr/sbin/i2cget -y -f 0 0x34 0x78) BAT_BIN=$(( $(($BAT_VOLT_MSB << 4)) | $(($(($BAT_VOLT_LSB & 0xF0)) >> 4)) )) BAT_VOLT=$(echo "($BAT_BIN*1.1)"|bc) # store maximum battery voltage to compare to if [ -f "/etc/default/battery" ]; then source "/etc/default/battery" else echo "MAX=$BAT_VOLT" > /etc/default/battery echo "MIN=3484" >> /etc/default/battery fi # integer is enough, cut down the decimals MAX=${MAX%.*} BAT_VOLT=${BAT_VOLT%.*} # mainline kernel shows battery existence even if not exists. this is walkaround if [ "$BAT_VOLT" -ge "3200" ]; then # if we have new max value, alter defaults if [ "$BAT_VOLT" -gt "$MAX" ]; then MAX=$BAT_VOLT sed -e 's/MAX=.*/MAX='$BAT_VOLT'/g' -i /etc/default/battery fi # if we have new min value, alter defaults if [ "$BAT_VOLT" -lt "$MIN" ]; then MIN=$BAT_VOLT sed -e 's/MIN=.*/MIN='$BAT_VOLT'/g' -i /etc/default/battery fi # calculate percentage percent=$(echo "($BAT_VOLT-$MIN)*100/($MAX-$MIN)"|bc) fi # define output format output="Load : $percent% | Load_Batt=$percent;80;35;3.4;4.2;" # if load% in range 80-10 ok if [ "$percent" -ge 80 -a "$percent" -le 100 ]; then echo "OK- $output" exit 0 # if load % in range 40-79 warning elif [ "$percent" -ge 40 -a "$percent" -le 79 ]; then echo "WARNING - $output" exit 1 # if load % in range 0-39 critical elif [ "$percent" -ge 0 -a "$percent" -le 39 ]; then echo "CRITICAL - $output" exit 2 # if check non riceve data else echo "UNKNOW" exit 3 fi if run script for non admin user need add permission to  /usr/sbin/iscget
    ex:
    chmod 777 /usr/sbin/iscget and change default permission for /dev/i2c-0
    ex:
    sudo nano /lib/udev/rules.d/60-i2c-tools.rules KERNEL=="i2c-0" , GROUP="i2c", MODE="0660" to
    KERNEL=="i2c-0" , GROUP="i2c", MODE="0666" and reboot
     
     
     

  3. Like
    luca219 got a reaction from Igor in Cubietruck Battery monitor with nagios   
    hi all,
    if someone need, I adapted for nagios the script to monitor battery cubietruck.
    The script is pnp4nagios friendly.
    #!/bin/bash ###################################################################################### # # Battery info # /usr/sbin/i2cset -y -f 0 0x34 0x82 0xC3 # read power OPERATING MODE register @01h POWER_OP_MODE=$(/usr/sbin/i2cget -y -f 0 0x34 0x01) BAT_EXIST=$(($(($POWER_OP_MODE&0x20))/32)) # divide by 32 is like shifting rigth 5 times CHARG_IND=$(($(($POWER_OP_MODE&0x40))/64)) # divide by 64 is like shifting rigth 6 times ######################################################################################## #read battery voltage 79h, 78h 0 mV -> 000h, 1.1 mV/bit FFFh -> 4.5045 V BAT_VOLT_LSB=$(/usr/sbin/i2cget -y -f 0 0x34 0x79) BAT_VOLT_MSB=$(/usr/sbin/i2cget -y -f 0 0x34 0x78) BAT_BIN=$(( $(($BAT_VOLT_MSB << 4)) | $(($(($BAT_VOLT_LSB & 0xF0)) >> 4)) )) BAT_VOLT=$(echo "($BAT_BIN*1.1)"|bc) # store maximum battery voltage to compare to if [ -f "/etc/default/battery" ]; then source "/etc/default/battery" else echo "MAX=$BAT_VOLT" > /etc/default/battery echo "MIN=3484" >> /etc/default/battery fi # integer is enough, cut down the decimals MAX=${MAX%.*} BAT_VOLT=${BAT_VOLT%.*} # mainline kernel shows battery existence even if not exists. this is walkaround if [ "$BAT_VOLT" -ge "3200" ]; then # if we have new max value, alter defaults if [ "$BAT_VOLT" -gt "$MAX" ]; then MAX=$BAT_VOLT sed -e 's/MAX=.*/MAX='$BAT_VOLT'/g' -i /etc/default/battery fi # if we have new min value, alter defaults if [ "$BAT_VOLT" -lt "$MIN" ]; then MIN=$BAT_VOLT sed -e 's/MIN=.*/MIN='$BAT_VOLT'/g' -i /etc/default/battery fi # calculate percentage percent=$(echo "($BAT_VOLT-$MIN)*100/($MAX-$MIN)"|bc) fi # define output format output="Load : $percent% | Load_Batt=$percent;80;35;3.4;4.2;" # if load% in range 80-10 ok if [ "$percent" -ge 80 -a "$percent" -le 100 ]; then echo "OK- $output" exit 0 # if load % in range 40-79 warning elif [ "$percent" -ge 40 -a "$percent" -le 79 ]; then echo "WARNING - $output" exit 1 # if load % in range 0-39 critical elif [ "$percent" -ge 0 -a "$percent" -le 39 ]; then echo "CRITICAL - $output" exit 2 # if check non riceve data else echo "UNKNOW" exit 3 fi if run script for non admin user need add permission to  /usr/sbin/iscget
    ex:
    chmod 777 /usr/sbin/iscget and change default permission for /dev/i2c-0
    ex:
    sudo nano /lib/udev/rules.d/60-i2c-tools.rules KERNEL=="i2c-0" , GROUP="i2c", MODE="0660" to
    KERNEL=="i2c-0" , GROUP="i2c", MODE="0666" and reboot
     
     
     

  4. Like
    luca219 got a reaction from Igor in CPU core is only recognized one   
    sorry Igor, I do not want to waste your time.
    i have add repo
    echo "deb http://apt.armbian.com $(lsb_release -cs) main" > /etc/apt/sources.list.d/armbian.list apt-key adv --keyserver keys.gnupg.net --recv-keys 0x93D6889F9F0E78D5 apt-get update and install
    apt-get install linux-u-boot-cubietruck after reboot I do not understand what happened

     
    any suggestion?
     
    solved sorry
  5. Like
    luca219 got a reaction from underr in no shutdown cubietruck with li-battery   
    great!!   problem solved!!
     
    step for cubietruck and cubieboard3
     
    [root@hosts]# bin2fex /boot/cubietruck.bin /root/cubietruck.fex
    fexc-bin: /boot/cubietruck.bin: version: 0.1.2
    fexc-bin: /boot/cubietruck.bin: size: 46240 (83 sections)
     
    [root@hosts]# nano /root/cubietruck.fex
    include on [target] section:
    power_start = 1
     
    make backup
    [root@hosts]# cp /boot/cubietruck.bin /boot/cubietruck.binori
    [root@hosts]# fex2bin /root/cubietruck.fex /boot/cubietruck.bin
     
    reboot
    shutdown now work!!
     
    Thank you