On Jun 27, 2015, at 9:17 AM, Charles Lepple <clepple at gmail.com> wrote:> On Jun 26, 2015, at 11:07 PM, Sundeep Mediratta <smedius at gmail.com> wrote: > >> 0.000233 upsdrv_initups(): Power Sources blob: >> <CFArray 0x7ffd18605480 [0x7fff7443bed0]>{type = immutable, count = 1, values = ( >> 0 : <CFBasicHash 0x7ffd18605360 [0x7fff7443bed0]>{type = immutable dict, count = 10, >> entries => > > Thanks. There is a subtle difference in the "Power Sources" blob: on 10.9 and earlier, it is a dictionary rather than an array. I will try later today to see if there is a better way to enumerate the power sources.I can't test this easily on 10.10 (my 10.10 box is powered by a serial UPS that does not show up in Energy Saver), but it uses the proper API now, and works on 10.9. I pushed the branch as macosx_power_dict: https://github.com/networkupstools/nut/commit/b608975b55895e853ba8d24fc08761bff2c65940 Patch: https://github.com/networkupstools/nut/compare/macosx_power_dict.diff I don't use MacPorts much, but I think this is how you would add this patch to the NUT portfile: https://guide.macports.org/#development.patches.source patchfiles macosx_power_dict.diff patch.pre_args -p1 -- Charles Lepple clepple at gmail
Sundeep Mediratta
2015-Jun-28 04:34 UTC
[Nut-upsuser] Driver macosx-ups failing on Yosemite
> On Jun 27, 2015, at 4:37 PM, Charles Lepple <clepple at gmail.com> wrote: > > patchfiles macosx_power_dict.diff > patch.pre_args -p1Thank you. Does not give any errors, seems to run. Will try with upsd next. macosx-ups -DDDD -a cyberpower Network UPS Tools - Mac OS X UPS meta-driver 1.1 (2.6.5-Unversioned directory) Warning: This is an experimental driver. Some features may not function correctly. 0.000000 debug level is '4' 0.000564 upsdrv_initups(): Power Sources blob: <CFArray 0x7f901c000500 [0x7fff7443bed0]>{type = immutable, count = 1, values = ( 0 : <CFBasicHash 0x7f901c0009c0 [0x7fff7443bed0]>{type = immutable dict, count = 10, entries => 0 : <CFString 0x7f901c000230 [0x7fff7443bed0]>{contents = "Voltage"} = <CFNumber 0x4e2037 [0x7fff7443bed0]>{value = +20000, type = kCFNumberSInt64Type} 1 : <CFString 0x7f901c000940 [0x7fff7443bed0]>{contents = "Power Source ID"} = <CFNumber 0x37 [0x7fff7443bed0]>{value = +0, type = kCFNumberSInt64Type} 3 : <CFString 0x7f901c000770 [0x7fff7443bed0]>{contents = "Transport Type"} = <CFString 0x7f901c000250 [0x7fff7443bed0]>{contents = "USB"} 6 : <CFString 0x7f901c000740 [0x7fff7443bed0]>{contents = "Current Capacity"} = <CFNumber 0x6437 [0x7fff7443bed0]>{value = +100, type = kCFNumberSInt64Type} 7 : <CFString 0x7f901c0001a0 [0x7fff7443bed0]>{contents = "Time to Empty"} = <CFNumber 0x1b37 [0x7fff7443bed0]>{value = +27, type = kCFNumberSInt64Type} 8 : <CFString 0x7f901c000720 [0x7fff7443bed0]>{contents = "Max Capacity"} = <CFNumber 0x6437 [0x7fff7443bed0]>{value = +100, type = kCFNumberSInt64Type} 9 : <CFString 0x7f901c0001c0 [0x7fff7443bed0]>{contents = "Is Charging"} = <CFBoolean 0x7fff7443c8a8 [0x7fff7443bed0]>{value = true} 10 : <CFString 0x7f901c0001e0 [0x7fff7443bed0]>{contents = "Power Source State"} = <CFString 0x7f901c000970 [0x7fff7443bed0]>{contents = "AC Power"} 11 : <CFString 0x7f901c000210 [0x7fff7443bed0]>{contents = "Is Present"} = <CFBoolean 0x7fff7443c8a8 [0x7fff7443bed0]>{value = true} 12 : <CFString 0x7fff7440b7c0 [0x7fff7443bed0]>{contents = "Name"} = <CFString 0x7f901c000990 [0x7fff7443bed0]>{contents = "UPS CP1000AVRLCD"} } )} 0.003791 Matching power supply model names against regex 'CP1000AVRLCD' 0.003848 Number of power supplies found: 1 <CFArray 0x7f901c0006e0 [0x7fff7443bed0]>{type = immutable, count = 1, values = ( 0 : <CFBasicHash 0x7f901c0009c0 [0x7fff7443bed0]>{type = immutable dict, count = 10, entries => 0 : <CFString 0x7f901c000230 [0x7fff7443bed0]>{contents = "Voltage"} = <CFNumber 0x4e2037 [0x7fff7443bed0]>{value = +20000, type = kCFNumberSInt64Type} 1 : <CFString 0x7f901c000940 [0x7fff7443bed0]>{contents = "Power Source ID"} = <CFNumber 0x37 [0x7fff7443bed0]>{value = +0, type = kCFNumberSInt64Type} 3 : <CFString 0x7f901c000770 [0x7fff7443bed0]>{contents = "Transport Type"} = <CFString 0x7f901c000250 [0x7fff7443bed0]>{contents = "USB"} 6 : <CFString 0x7f901c000740 [0x7fff7443bed0]>{contents = "Current Capacity"} = <CFNumber 0x6437 [0x7fff7443bed0]>{value = +100, type = kCFNumberSInt64Type} 7 : <CFString 0x7f901c0001a0 [0x7fff7443bed0]>{contents = "Time to Empty"} = <CFNumber 0x1b37 [0x7fff7443bed0]>{value = +27, type = kCFNumberSInt64Type} 8 : <CFString 0x7f901c000720 [0x7fff7443bed0]>{contents = "Max Capacity"} = <CFNumber 0x6437 [0x7fff7443bed0]>{value = +100, type = kCFNumberSInt64Type} 9 : <CFString 0x7f901c0001c0 [0x7fff7443bed0]>{contents = "Is Charging"} = <CFBoolean 0x7fff7443c8a8 [0x7fff7443bed0]>{value = true} 10 : <CFString 0x7f901c0001e0 [0x7fff7443bed0]>{contents = "Power Source State"} = <CFString 0x7f901c000970 [0x7fff7443bed0]>{contents = "AC Power"} 11 : <CFString 0x7f901c000210 [0x7fff7443bed0]>{contents = "Is Present"} = <CFBoolean 0x7fff7443c8a8 [0x7fff7443bed0]>{value = true} 12 : <CFString 0x7fff7440b7c0 [0x7fff7443bed0]>{contents = "Name"} = <CFString 0x7f901c000990 [0x7fff7443bed0]>{contents = "UPS CP1000AVRLCD"} } )} 0.006480 Retrieving power source #1 0.006488 Power source key/index: <CFBasicHash 0x7f901c0009c0 [0x7fff7443bed0]>{type = immutable dict, count = 10, entries => 0 : <CFString 0x7f901c000230 [0x7fff7443bed0]>{contents = "Voltage"} = <CFNumber 0x4e2037 [0x7fff7443bed0]>{value = +20000, type = kCFNumberSInt64Type} 1 : <CFString 0x7f901c000940 [0x7fff7443bed0]>{contents = "Power Source ID"} = <CFNumber 0x37 [0x7fff7443bed0]>{value = +0, type = kCFNumberSInt64Type} 3 : <CFString 0x7f901c000770 [0x7fff7443bed0]>{contents = "Transport Type"} = <CFString 0x7f901c000250 [0x7fff7443bed0]>{contents = "USB"} 6 : <CFString 0x7f901c000740 [0x7fff7443bed0]>{contents = "Current Capacity"} = <CFNumber 0x6437 [0x7fff7443bed0]>{value = +100, type = kCFNumberSInt64Type} 7 : <CFString 0x7f901c0001a0 [0x7fff7443bed0]>{contents = "Time to Empty"} = <CFNumber 0x1b37 [0x7fff7443bed0]>{value = +27, type = kCFNumberSInt64Type} 8 : <CFString 0x7f901c000720 [0x7fff7443bed0]>{contents = "Max Capacity"} = <CFNumber 0x6437 [0x7fff7443bed0]>{value = +100, type = kCFNumberSInt64Type} 9 : <CFString 0x7f901c0001c0 [0x7fff7443bed0]>{contents = "Is Charging"} = <CFBoolean 0x7fff7443c8a8 [0x7fff7443bed0]>{value = true} 10 : <CFString 0x7f901c0001e0 [0x7fff7443bed0]>{contents = "Power Source State"} = <CFString 0x7f901c000970 [0x7fff7443bed0]>{contents = "AC Power"} 11 : <CFString 0x7f901c000210 [0x7fff7443bed0]>{contents = "Is Present"} = <CFBoolean 0x7fff7443c8a8 [0x7fff7443bed0]>{value = true} 12 : <CFString 0x7fff7440b7c0 [0x7fff7443bed0]>{contents = "Name"} = <CFString 0x7f901c000990 [0x7fff7443bed0]>{contents = "UPS CP1000AVRLCD"} } 0.008232 Getting 'Name' key (UPS model) 0.008237 model name: UPS CP1000AVRLCD 0.008245 Matched model name 0.008255 upsdrv_initinfo() 0.008430 Getting 'Name' key 0.008447 Got name: UPS CP1000AVRLCD 0.008455 Max Capacity = 100 units (usually 100) 0.008460 upsdrv_updateinfo() 0.008542 Power Source State: AC Power 0.008572 battery_voltage = 20000 mV 0.008578 battery_runtime = 27 minutes 0.008582 Current Capacity = 100/100 units 0.008702 dstate_init: sock /opt/local/var/db/ups/macosx-ups-cyberpower open on fd 3 0.008718 upsdrv_updateinfo() 0.008901 Power Source State: AC Power 0.008938 battery_voltage = 20000 mV 0.008943 battery_runtime = 27 minutes 0.008947 Current Capacity = 100/100 units 2.013770 upsdrv_updateinfo() 2.014079 Power Source State: AC Power 2.014127 battery_voltage = 20000 mV 2.014138 battery_runtime = 27 minutes 2.014147 Current Capacity = 100/100 units 4.015421 upsdrv_updateinfo() 4.015739 Power Source State: AC Power Sundeep Mediratta
Sundeep Mediratta
2015-Jun-28 13:48 UTC
[Nut-upsuser] Driver macosx-ups failing on Yosemite
Driver is working, but high CPU use- process cpu% cpu-time threads wakeup pid uid macosx-ups 100.0 26:50.99 1 0 70413 _nut 99% to 100% CPU use, > 26 minutes runtime This does not seem right. Thanks> On Jun 27, 2015, at 4:37 PM, Charles Lepple <clepple at gmail.com> wrote: > > On Jun 27, 2015, at 9:17 AM, Charles Lepple <clepple at gmail.com> wrote: > >> On Jun 26, 2015, at 11:07 PM, Sundeep Mediratta <smedius at gmail.com> wrote: >> >>> 0.000233 upsdrv_initups(): Power Sources blob: >>> <CFArray 0x7ffd18605480 [0x7fff7443bed0]>{type = immutable, count = 1, values = ( >>> 0 : <CFBasicHash 0x7ffd18605360 [0x7fff7443bed0]>{type = immutable dict, count = 10, >>> entries => >> >> Thanks. There is a subtle difference in the "Power Sources" blob: on 10.9 and earlier, it is a dictionary rather than an array. I will try later today to see if there is a better way to enumerate the power sources. > > I can't test this easily on 10.10 (my 10.10 box is powered by a serial UPS that does not show up in Energy Saver), but it uses the proper API now, and works on 10.9. > > I pushed the branch as macosx_power_dict: > > https://github.com/networkupstools/nut/commit/b608975b55895e853ba8d24fc08761bff2c65940 > > Patch: https://github.com/networkupstools/nut/compare/macosx_power_dict.diff > > I don't use MacPorts much, but I think this is how you would add this patch to the NUT portfile: > > https://guide.macports.org/#development.patches.source > > patchfiles macosx_power_dict.diff > patch.pre_args -p1 > > -- > Charles Lepple > clepple at gmail > > >
Sundeep Mediratta
2015-Jun-28 14:49 UTC
[Nut-upsuser] Driver macosx-ups failing on Yosemite
I think the high CPU usage was caused by the native OS X driver crashing and not working properly. The native driver was not sensing the UPS going on battery or any change in battery percentage. Unplugging the USB and then plugging it back again made the native driver come back up again properly. Restarting the macosx-ups driver seems to get back to normal CPU usage. I will monitor and see how it goes, but it seems the native yosemite driver is flaky. Or maybe the UPS is flaky. Will monitor and see how it goes. May have to attach the UPS to the linux machine and use the mac as a client, however it is easier to use the mac with the native control panel if the native driver works OK.> On Jun 27, 2015, at 4:37 PM, Charles Lepple <clepple at gmail.com> wrote: > > On Jun 27, 2015, at 9:17 AM, Charles Lepple <clepple at gmail.com> wrote: > >> On Jun 26, 2015, at 11:07 PM, Sundeep Mediratta <smedius at gmail.com> wrote: >> >>> 0.000233 upsdrv_initups(): Power Sources blob: >>> <CFArray 0x7ffd18605480 [0x7fff7443bed0]>{type = immutable, count = 1, values = ( >>> 0 : <CFBasicHash 0x7ffd18605360 [0x7fff7443bed0]>{type = immutable dict, count = 10, >>> entries => >> >> Thanks. There is a subtle difference in the "Power Sources" blob: on 10.9 and earlier, it is a dictionary rather than an array. I will try later today to see if there is a better way to enumerate the power sources. > > I can't test this easily on 10.10 (my 10.10 box is powered by a serial UPS that does not show up in Energy Saver), but it uses the proper API now, and works on 10.9. > > I pushed the branch as macosx_power_dict: > > https://github.com/networkupstools/nut/commit/b608975b55895e853ba8d24fc08761bff2c65940 > > Patch: https://github.com/networkupstools/nut/compare/macosx_power_dict.diff > > I don't use MacPorts much, but I think this is how you would add this patch to the NUT portfile: > > https://guide.macports.org/#development.patches.source > > patchfiles macosx_power_dict.diff > patch.pre_args -p1 > > -- > Charles Lepple > clepple at gmail > > >
On Jun 28, 2015, at 10:49 AM, Sundeep Mediratta <smedius at gmail.com> wrote:> I think the high CPU usage was caused by the native OS X driver crashing and not working properly. The native driver was not sensing the UPS going on battery or any change in battery percentage.As you can imagine, if the native driver does not see a change, the macosx-ups driver will not, either. Unfortunately, there is no timestamp on the data from the OS, so I am not sure if there is anything we can do to detect that condition.> Unplugging the USB and then plugging it back again made the native driver come back up again properly. Restarting the macosx-ups driver seems to get back to normal CPU usage. I will monitor and see how it goes, but it seems the native yosemite driver is flaky. Or maybe the UPS is flaky. Will monitor and see how it goes.If you do see 100% CPU usage on the NUT driver in the future, I would be interested in seeing a profile sample to see where it is spinning. Activity Monitor -> CPU tab; click on the process, and under the gear icon, choose "Sample Process". Another potential problem that you might see is that the driver will trigger an assertion and exit when the UPS is unplugged. Theoretically, this could be fixed with a launchd plist that restarts the driver, but the usual way to handle this in NUT is to mark the data as stale, and wait for the UPS to reappear. (Does MacPorts use a launchd plist?)> May have to attach the UPS to the linux machine and use the mac as a client, however it is easier to use the mac with the native control panel if the native driver works OK.Something that has been on my TODO list for a while is a System Preference pane for NUT that would connect out to upsd running on another system, and present a virtual UPS object to Mac OS X. GUI programming is not my forte, but if you know anyone else interested in making this happen, let me know. -- Charles Lepple clepple at gmail