### Install and Test CGI Programs Source: https://context7.com/therealbstern/apcupsd/llms.txt Builds and installs the CGI web interface components for monitoring. ```bash # Install CGI programs to web server cgi-bin directory # Build apcupsd with CGI support: ./configure --enable-cgi --with-cgi-bin=/var/www/cgi-bin make sudo make install # CGI Programs installed: # /var/www/cgi-bin/multimon.cgi - Multi-UPS monitoring dashboard # /var/www/cgi-bin/upsstats.cgi - Single UPS detailed status with graphs # /var/www/cgi-bin/upsfstats.cgi - Full text status output # /var/www/cgi-bin/upsimage.cgi - Generates status bar graphs # Access URLs: # http://yourserver/cgi-bin/multimon.cgi # http://yourserver/cgi-bin/upsstats.cgi?host=127.0.0.1 # http://yourserver/cgi-bin/upsfstats.cgi?host=192.168.1.10 # Test CGI from command line cd /var/www/cgi-bin ./multimon.cgi # Output: HTML content showing UPS status table ``` -------------------------------- ### Install APCUPSD Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Execute the installation command after a successful build. ```bash gmake install ``` -------------------------------- ### Install apcupsd as Root Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst After building apcupsd from source, use 'make install' with root privileges to install the service and its components. This step is crucial for system-level integration. ```bash make install ``` -------------------------------- ### Verify Installation Paths Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Commands to locate the installed apcupsd binary and associated configuration files. ```bash $ which apcupsd /sbin/apcupsd $ whereis apcupsd apcupsd: /sbin/apcupsd /etc/apcupsd /etc/apcupsd.conf /etc/apcupsd.status /usr/man/man8/apcupsd.8.gz /usr/man/man8/apcupsd.8 ``` -------------------------------- ### Configure apcupsd for standard and CGI installations Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.html Recommended ./configure commands for standard installations and those requiring CGI support. ```bash ./configure --prefix=/usr --sbindir=/sbin --enable-usb ``` ```bash ./configure --prefix=/usr --sbindir=/sbin --enable-usb \ --enable-cgi --with-cgi-bin=/home/httpd/cgi-bin ``` -------------------------------- ### Example USB Device Output (Back-UPS 350) Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Another example output from 'cat /proc/bus/usb/devices', this time for a Back-UPS 350, illustrating the expected format for device identification and driver assignment. ```text T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=051d ProdID=0002 Rev= 1.00 S: Manufacturer=American Power Conversion S: Product=Back-UPS 350 FW: 5.2.I USB FW: c1 S: SerialNumber=BB0115017954 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 30mA I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=hid E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl= 10ms ``` -------------------------------- ### Configure Apcupsd for Basic Installation Source: https://github.com/therealbstern/apcupsd/blob/master/platforms/unknown/lfs-install-hint.txt Use this command to configure Apcupsd for a basic installation. The --prefix and --sbindir options specify installation directories. ```bash ./configure --prefix=/usr --sbindir=/sbin ``` -------------------------------- ### Example Drivers Output (Linux 2.6.x) Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst An example of the output from 'ls -l /sys/bus/usb/drivers/' on a Linux 2.6.x system, showing common USB drivers like hid, hiddev, hub, usb, and usbfs. ```text total 0 drwxr-xr-x 2 root root 0 May 1 18:55 hid drwxr-xr-x 2 root root 0 May 1 18:55 hiddev drwxr-xr-x 2 root root 0 May 1 18:55 hub drwxr-xr-x 2 root root 0 May 1 18:55 usb drwxr-xr-x 2 root root 0 May 1 18:55 usbfs ``` -------------------------------- ### Start apcupsd Service Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.html Execute this command to start the apcupsd service. Ensure you replace with the correct directory for your system (e.g., /etc/rc.d or /etc/rc.d/init.d). ```bash /apcupsd start ``` -------------------------------- ### Solaris: Example Device Node Output Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.html This output shows the device nodes created for an APC UPS on Solaris after successful detection and configuration. The presence of files like 'cntrl0' and 'devstat' indicates proper setup. ```text cntrl0 cntrl0stat devstat if0in1 if0in1stat ``` -------------------------------- ### Build and install Apcupsd on Solaris Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Commands for installing necessary packages and performing a reconfigure boot to enable USB support. ```shell make install ``` ```shell reboot -- -r ``` -------------------------------- ### apcaccess Output Example for Smart-UPS Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.html Example output from 'apcaccess status' for a Smart-UPS, showing detailed UPS information including voltage, load, battery status, and runtime. ```text APC : 001,048,1088 DATE : Fri Dec 03 16:49:24 EST 1999 HOTNAME : daughter RELEASE : 3.7.2 CABLE : APC Cable 940-0024C MODEL : APC Smart-UPS 600 UPSMODE : Stand Alone UPSNAME : SU600 LINEV : 122.1 Volts MAXLINEV : 123.3 Volts MINLINEV : 122.1 Volts LINEFREQ : 60.0 Hz OUTPUTV : 122.1 Volts LOADPCT : 32.7 Percent Load Capacity BATTV : 26.6 Volts BCHARGE : 095.0 Percent MBATTCHG : 15 Percent TIMELEFT : 19.0 Minutes MINTIMEL : 3 Minutes SENSE : Medium DWAKE : 000 Seconds DSHUTD : 020 Seconds LOTRANS : 106.0 Volts HITRANS : 129.0 Volts RETPCT : 010.0 Percent STATFLAG : 0x08 Status Flag STATUS : ONLINE ITEMP : 34.6 C Internal ALARMDEL : Low Battery LASTXFER : Unacceptable Utility Voltage Change SELFTEST : NO STESTI : 336 DLOWBATT : 05 Minutes DIPSW : 0x00 Dip Switch REG1 : N/A REG2 : N/A REG3 : 0x00 Register 3 MANDATE : 03/30/95 SERIALNO : 13035861 BATTDATE : 05/05/98 NOMOUTV : 115.0 NOMBATTV : 24.0 HUMIDITY : N/A AMBTEMP : N/A EXTBATTS : N/A BADBATTS : N/A FIRMWARE : N/A APCMODEL : 6TD END APC : Fri Dec 03 16:49:25 EST 1999 ``` -------------------------------- ### Install RPM Package Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst For RPM-based systems like Red Hat or SuSE, use 'rpm -ihv' for a fresh installation or 'rpm -Uhv' for an upgrade. Note that upgrades may require manual verification of the halt script. ```bash rpm -ihv ``` ```bash rpm -Uhv ``` -------------------------------- ### Example USB Device Output Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst This is an example of the output from 'cat /proc/bus/usb/devices', showing a recognized American Power Conversion Back-UPS RS 1000 with the 'hid' driver attached. ```text T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=051d ProdID=0002 Rev= 1.06 S: Manufacturer=American Power Conversion S: Product=Back-UPS RS 1000 FW:7.g3 .D USB FW:g3 S: SerialNumber=JB0308036505 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 24mA I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=hid ``` -------------------------------- ### Configure apcupsd with Prefix Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Sets the installation directory for non-executable files like manuals. The default is /usr. ```bash --prefix=path ``` -------------------------------- ### Start and Stop apcupsd Daemon Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Use the init script to start or stop the apcupsd service, ensuring proper cleanup of files. ```bash /apcupsd start ``` ```bash /apcupsd stop ``` -------------------------------- ### Sample HTML output from multimon.cgi Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Example of the HTML output generated by the multimon.cgi program when correctly configured. ```html Content-type: text/html Multimon: UPS Status Page
... ``` -------------------------------- ### Configure syslog for apcupsd Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Example configuration for /etc/syslog.conf to route different apcupsd log levels to specific files or pipes. ```conf # exclude all apcupsd info by default *.info;local0.none /var/log/messages # Everything for apcupsd goes here local0.info;local0.!notice /var/log/apcupsd.data local0.notice;local0.!warn |/var/log/apcupsd.status local0.warn /var/log/apcupsd.events local0.warn /var/log/messages ``` -------------------------------- ### Configure Serial Smart-UPS for APCUPSd Source: https://context7.com/therealbstern/apcupsd/llms.txt Example configuration for a serial-connected Smart-UPS using the APC smart protocol. Specify the serial device path. ```bash # /etc/apcupsd/apcupsd.conf - Serial Smart-UPS Configuration UPSNAME SmartUPS UPSCABLE smart UPSTYPE apcsmart DEVICE /dev/ttyS0 # First serial port LOCKFILE /var/lock SCRIPTDIR /etc/apcupsd PWRFAILDIR /var/run NOLOGINDIR /var/run ONBATTERYDELAY 6 BATTERYLEVEL 5 MINUTES 3 TIMEOUT 0 NETSERVER on NISIP 0.0.0.0 NISPORT 3551 EVENTSFILE /var/log/apcupsd.events UPSCLASS standalone UPSMODE disable ``` -------------------------------- ### Example devfsd Output Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Expected output when devfsd is active. ```text 533 ? S 0:00 devfsd /dev ``` -------------------------------- ### Configure apcupsd for standard systems Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Standard configuration command for enabling USB support and setting installation directories. ```bash ./configure --prefix=/usr --sbindir=/sbin --enable-usb ``` -------------------------------- ### Query NIS via Bash Source: https://context7.com/therealbstern/apcupsd/llms.txt Examples of querying the NIS server using netcat and a simple bash monitoring script. ```bash # Query NIS using netcat echo "status" | nc localhost 3551 # Query events echo "events" | nc 192.168.1.10 3551 # Simple bash monitoring script #!/bin/bash HOST="${1:-localhost}" PORT="${2:-3551}" STATUS=$(echo "status" | nc -q1 "$HOST" "$PORT" | grep "^STATUS") BCHARGE=$(echo "status" | nc -q1 "$HOST" "$PORT" | grep "^BCHARGE") TIMELEFT=$(echo "status" | nc -q1 "$HOST" "$PORT" | grep "^TIMELEFT") echo "UPS Status: $STATUS" echo "Battery: $BCHARGE" echo "Runtime: $TIMELEFT" ``` -------------------------------- ### Configure USB UPS for APCUPSd Source: https://context7.com/therealbstern/apcupsd/llms.txt Example configuration for a USB-connected UPS. Leave the DEVICE parameter blank for auto-detection. ```bash # /etc/apcupsd/apcupsd.conf - USB UPS Configuration Example ## General Configuration UPSNAME MyUPS UPSCABLE usb UPSTYPE usb DEVICE # Leave blank for USB auto-detection LOCKFILE /var/lock SCRIPTDIR /etc/apcupsd PWRFAILDIR /var/run NOLOGINDIR /var/run ## Power Failure Settings ONBATTERYDELAY 6 # Seconds before onbattery event BATTERYLEVEL 5 # Shutdown at 5% battery MINUTES 3 # Shutdown at 3 minutes remaining TIMEOUT 0 # Disable timeout-based shutdown ## User Notification ANNOY 300 # Warn users every 5 minutes ANNOYDELAY 60 # First warning after 60 seconds NOLOGON disable # Don't prevent logins ## Network Information Server (NIS) NETSERVER on # Enable NIS NISIP 0.0.0.0 # Listen on all interfaces NISPORT 3551 # Default NIS port EVENTSFILE /var/log/apcupsd.events EVENTSFILEMAX 10 # Max 10KB event file ## UPS Sharing (standalone mode) UPSCLASS standalone UPSMODE disable ## Logging STATTIME 0 # Disable status file writes STATFILE /var/log/apcupsd.status LOGSTATS off DATATIME 0 ``` -------------------------------- ### Display Configuration Help Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst This command displays all available configuration options for the apcupsd build process. It's recommended to use default settings unless specific customization is required. ```bash ./configure --help ``` -------------------------------- ### Check apcupsd System Logs Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Verify startup success by inspecting the system log file. ```bash tail /var/log/messages ``` ```text Dec 5 17:01:05 matou apcupsd[5917]: apcupsd 3.7.2 startup succeeded ``` -------------------------------- ### List Multiple Configuration Files Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Verify the existence of multiple configuration files for different UPS instances. ```bash [adk0212@mail apcupsd]$ ls -l /etc/apcupsd/*.conf -rw-r--r-- 1 root root 11799 Aug 3 08:39 /etc/apcupsd/apcupsd.ups0.conf -rw-r--r-- 1 root root 11822 Aug 25 14:31 /etc/apcupsd/apcupsd.ups1.conf ``` -------------------------------- ### Example apcaccess Status Output Source: https://context7.com/therealbstern/apcupsd/llms.txt This is an example of the output you might receive when querying UPS status using `apcaccess`. ```text # Example output: # APC : 001,034,0868 # DATE : 2024-01-15 10:30:00 +0000 # HOSTNAME : server1 # VERSION : 3.14.14 (31 May 2016) debian # UPSNAME : SmartUPS1000 # CABLE : USB Cable # DRIVER : USB UPS Driver ``` -------------------------------- ### Raw EEPROM Data Example Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/smartprotocol.rst A truncated example of the raw character stream returned by the UPS after sending a ^Z command. ```text #uD43132135138129uM43229234239224uA43110112114108 .... ``` -------------------------------- ### Configure apcupsd from Source Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Before building apcupsd from source, run the './configure' script. This script checks for necessary dependencies and prepares the build environment. It should be run as a normal user. ```bash ./configure ``` -------------------------------- ### Execute multimon.cgi for testing Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Run the multimon.cgi program from the command line to verify the configuration. ```bash ./multimon.cgi ``` -------------------------------- ### Build apcupsd Install Package Source: https://github.com/therealbstern/apcupsd/blob/master/platforms/darwin/building-universal-binaries.txt Build the apcupsd installation package (.pkg) for macOS. This requires navigating to the darwin platform directory and using sudo for elevated privileges. ```bash cd platforms/darwin sudo make apcupsd.pkg ``` -------------------------------- ### Create USB device nodes on BSD-like systems Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Use these commands to manually create ugen device nodes if the UPS is not automatically bound. ```shell cd /dev ; ./MAKEDEV ugenN ``` -------------------------------- ### Configure apcupsd for Standalone Mode Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Minimum required configuration directives for a standalone apcupsd installation. ```text ## apcupsd.conf v1.1 ## UPSCABLE (number of cable you have) UPSTYPE dumb DEVICE /dev/ttyS0 LOCKFILE /var/lock UPSCLASS standalone UPSMODE disable ``` -------------------------------- ### Manage apcupsd service on SUSE Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Commands to start or stop the apcupsd service on SUSE-based systems. ```bash /etc/rc.d/apcupsd start ``` ```bash /etc/rc.d/apcupsd stop ``` -------------------------------- ### Build APCUPSd from Source Source: https://context7.com/therealbstern/apcupsd/llms.txt Compilation commands for building APCUPSd with different feature sets including USB, SNMP, and CGI support. ```bash # Download and extract source tar xzf apcupsd-3.14.14.tar.gz cd apcupsd-3.14.14 # Basic USB configuration (most common) ./configure \ --prefix=/usr \ --sbindir=/sbin \ --sysconfdir=/etc/apcupsd \ --with-pid-dir=/var/run \ --with-log-dir=/var/log \ --with-lock-dir=/var/lock \ --enable-usb make sudo make install # Full-featured build with SNMP and CGI ./configure \ --prefix=/usr \ --sbindir=/sbin \ --sysconfdir=/etc/apcupsd \ --with-pid-dir=/var/run \ --with-log-dir=/var/log \ --with-lock-dir=/var/lock \ --enable-usb \ --enable-snmp \ --enable-net \ --enable-cgi \ --with-cgi-bin=/var/www/cgi-bin make sudo make install # Serial-only build (no USB support) ./configure \ --prefix=/usr \ --sbindir=/sbin \ --sysconfdir=/etc/apcupsd \ --disable-usb \ --enable-apcsmart make sudo make install ``` -------------------------------- ### Invoke apcupsd manually Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Starts the apcupsd daemon directly from the command line. Requires root privileges. ```bash /sbin/apcupsd ``` -------------------------------- ### Configure apcupsd with Sbindir Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Sets the installation directory for executable files like apcupsd. Caution is advised when placing executables in directories like /usr/sbin or /usr/local/sbin, as they may be unmounted during shutdown, potentially preventing apcupsd from turning off UPS power. ```bash --sbindir=path ``` -------------------------------- ### Manage apcupsd service on Red Hat Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Commands to start or stop the apcupsd service on Red Hat-based systems. ```bash /etc/rc.d/init.d/apcupsd start ``` ```bash /etc/rc.d/init.d/apcupsd stop ``` -------------------------------- ### Enable Gnome Monitoring Application Build Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Include the gapcmon package in the build process by defining the build_gapcmon flag. ```bash --define "build_gapcmon 1" ``` -------------------------------- ### GET /< (Bad battery pack count) Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/smartprotocol.rst Retrieves the count of faulty battery packs currently connected to the UPS. ```APIDOC ## GET < ### Description Returns the number of bad battery packs detected. ### Method GET ### Endpoint < ### Response #### Success Response (200) - **count** (integer) - Number of bad packs. ``` -------------------------------- ### Check Loaded Drivers (Linux 2.6.x) Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst On Linux 2.6.x kernels, use 'ls -l' on the /sys/bus/usb/drivers/ directory to list available USB drivers. Ensure sysfs is mounted on /sys for this command to work correctly. ```bash ls -l /sys/bus/usb/drivers/ ``` -------------------------------- ### Configure CGI Bin Directory Source: https://github.com/therealbstern/apcupsd/blob/master/doc/manual/manual.rst Defines the directory where CGI programs will be installed. The default is /etc/apcupsd, which may not be the desired location. ```bash --with-cgi-bin=path ```
APCUPSD UPS Network Monitor
Sun Jan 16 12:07:27 CET 2000
System Model Status