====== FreeBSD Как узнать заряд батареи ноутбука из консоли? ====== ===== Ноутбук работает от сети. Аккумулятор заряжен. ===== # acpiconf -i batt Design capacity: 2200 mAh Last full capacity: 1310 mAh Technology: secondary (rechargeable) Design voltage: 10800 mV Capacity (warn): 110 mAh Capacity (low): 66 mAh Low/warn granularity: 264 mAh Warn/full granularity: 3780 mAh Model number: UM08A31 Serial number: Type: Lion OEM info: SANYO State: high Remaining capacity: 100% Remaining time: unknown Present rate: 773 mA (9129 mW) Present voltage: 11811 mV ===== Ноутбук работает от аккумулятора. ===== # acpiconf -i batt Design capacity: 2200 mAh Last full capacity: 1310 mAh Technology: secondary (rechargeable) Design voltage: 10800 mV Capacity (warn): 110 mAh Capacity (low): 66 mAh Low/warn granularity: 264 mAh Warn/full granularity: 3780 mAh Model number: UM08A31 Serial number: Type: Lion OEM info: SANYO State: discharging Remaining capacity: 95% Remaining time: 1:28 Present rate: 846 mA (9622 mW) Present voltage: 11374 mV ===== Ноутбук работает от сети. Аккумулятор заряжается. ===== # acpiconf -i batt Design capacity: 2200 mAh Last full capacity: 1310 mAh Technology: secondary (rechargeable) Design voltage: 10800 mV Capacity (warn): 110 mAh Capacity (low): 66 mAh Low/warn granularity: 264 mAh Warn/full granularity: 3780 mAh Model number: UM08A31 Serial number: Type: Lion OEM info: SANYO State: charging Remaining capacity: 95% Remaining time: unknown Present rate: 773 mA (9286 mW) Present voltage: 12013 mV ===== Настройка SNMP ===== Скрипт отображающий состояние батареи. cat Batt_state.sh #!/usr/local/bin/bash echo `acpiconf -i batt | grep "State" | awk '{print $2}'` exit 0 # cat Batt_r_capacity.sh #!/usr/local/bin/bash echo `acpiconf -i batt | grep "Remaining capacity" | awk '{print $3}' | sed -e 's/%//'` exit 0 Для того чтобы SNMP знал откуда брать состояние батареи и в какой oid выкладывать значения. Нужно в файл /usr/local/share/snmp/snmpd.conf добовить такую строчку: extend .1.3.6.1.4.1.2021.50.1 r_capacity /scripts/Batt_r_capacity.sh extend .1.3.6.1.4.1.2021.50.2 state /scripts/Batt_state.sh Перезапускаю SNMP # /usr/local/etc/rc.d/snmpd restart Проверяем выдаются ли наши значения по запросу: Ссылки:\\ https://www.freebsd.org/cgi/man.cgi?query=acpiconf&sektion=8&manpath=freebsd-release-ports