Setting up NUT on Solairs

This is a copy from : https://blogs.oracle.com/mikey/entry/network_ups_tools_on_solaris

Network UPS Tools on Solaris

I have become the lucky owner of a Trust 1200VA management UPS. The bad news is that, the manufacturer provides software for Microsoft systems only. However, I found an opensource ups monitor called Network UPS Tools, that is said to work under unix a-like systems. And yes, I managed to make it work on Solaris 10, this short howto tells you how.
The first thing we need is a user account that will be used to run nut daemons. I say, the user ‘ups’, and the group ‘ups’ (also), with the home directory in /var/ups, that will be used as the state directory (this is mentioned later).

# groupadd -g 999 ups
# useradd -u 999 -g ups -d /var/ups -s /bin/false -m ups
# chown ups:ups /var/ups
# chmod 750 /var/ups

At this point you need NUT sources, that are available for download at www.networkupstools.org/source.html. You have to download, extract, and compile them:

# /usr/sfw/bin/wget www.networkupstools.org/source/2.2/nut-2.2.0.tar.gz
# gunzip -c nut-2.2.0.tar.gz | tar -xf -
# cd nut-2.2.0
# ./configure --prefix=/opt/nut --with-statepath=/var/ups --with-user=ups --with-group=ups
# make && make install

Let’s stop here for a second, as I need to explain couple of things, with regards to the configure command. The prefix is where nut is going to be installed, the statedir is the same as the home directory of previously created user, the user and the group are self-explanatory.

I presume everything went fine, there were not errors – just like in the ideal world. Ok, its time configure it a little bit. So be prepared to edit couple of files in the text editor of your choice, but please do also read the comments, as some of the options (e.g. the password) have to be changed.

/opt/nut/etc/ups.conf:

[trust]
# full list of deivers at www.networkupstools.org/compat/stable.html)
driver = megatec
port = /dev/ttya

/opt/nut/etc/upsd.conf:

# bind to localhost only
LISTEN 127.0.0.1
# define ACLs
ACL all 0.0.0.0/0
ACL localhost 127.0.0.1/32
# Accept connections from localhost...
ACCEPT localhost
# ... and reject anything else
REJECT all

/opt/nut/etc/upsd.users

# define monitor user
[monuser]
password = YOUR_PASSWORD
allowfrom = localhost
upsmon master

/opt/nut/etc/upssched.conf

CMDSCRIPT /opt/nut/bin/upssched-cmd

/opt/nut/etc/upsmon.conf

RUN_AS_USER root # root is required for shotdown
MONITOR trust@localhost 1 monuser YOUR_PASSWORD_AGAIN master
MINSUPPLIES 1
SHUTDOWNCMD "/usr/sbin/poweroff"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
NOTIFYCMD /opt/nut/bin/notify # will create this later
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5

Done, now simply change permissions to only created config files, so that only ups user is able to read them as your password is stored there.

# chgrp ups ups.conf upsd.conf upsmon.conf upssched.conf
# chmod 640 ups.conf upsd.conf upsmon.conf upssched.conf

I have previously mentioned the notify script that, would mail you whenever the UPS status changes (e.g. low battery).

#!/bin/bash
echo "$\*" | mail -s "UPS state changed" foo@bar.com

Don’t forget to make it exacutable

# chmod 755 /opt/nut/bin/notify

We are almost home, the only thing left here is the SMF, so that the nut daemons would start auto-magically on system boot. You need the method and manifest files to make this work.

# mkdir -p /opt/nut/lib/svc/method
# vi nut

#!/usr/bin/sh

. /lib/svc/share/smf_include.sh

NUT_DIR=/opt/nut
STATE_DIR=/var/ups
PID_UPS=${STATE_DIR}/upsd.pid
PID_MON=/var/run/upsmon.pid

ups_stop () {
if [ -f ${PID_MON} ]; then
/usr/bin/kill `cat ${PID_MON}` > /dev/null
/usr/bin/rm -f ${PID_MON}
fi
if [ -f ${PID_UPS} ]; then
/usr/bin/kill `cat ${PID_UPS}` > /dev/null
/usr/bin/rm -f ${PID_UPS}
fi
${NUT_DIR}/bin/upsdrvctl stop > /dev/null 2>&1
}

ups_start () {
$NUT_DIR/bin/upsdrvctl start >/dev/null 2>&1
$NUT_DIR/sbin/upsd >/dev/null 2>&1
$NUT_DIR/sbin/upsmon >/dev/null 2>&1
}

##
# Start of script
#
case “$1″ in
start)
ups_start
;;
stop)
ups_stop
;;
restart)
ups_stop
while pgrep upsd > /dev/null
do
sleep 1
done
ups_start
;;
\*)
echo “”
echo “Usage: `basename $0` { start | stop | restart }”
echo “”
exit 64
;;
esac

# vi /var/svc/manifest/network/nut.xml

<?xml version=”1.0″?>
<!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1″>

<service_bundle type=’manifest’ name=’nut’>
<service name=’application/nut’ type=’service’ version=’1′>

<instance name=’default’ enabled=’false’>

<dependency name=’network’
grouping=’require_all’
restart_on=’error’
type=’service’>
<service_fmri value=’svc:/milestone/network:default’/>
</dependency>

<dependency name=’filesystem-local’
grouping=’require_all’
restart_on=’none’
type=’service’>
<service_fmri
value=’svc:/system/filesystem/local:default’/>
</dependency>

<exec_method
type=’method’
name=’start’
exec=’/opt/nut/lib/svc/method/nut start’
timeout_seconds=’60’>
<method_context />
</exec_method>

<exec_method
type=’method’
name=’stop’
exec=’/opt/nut/lib/svc/method/nut stop’
timeout_seconds=’60’>
<method_context />
</exec_method>

<exec_method
type=’method’
name=’refresh’
exec=’/opt/nut/lib/svc/method/nut restart’
timeout_seconds=’60’>
<method_context />
</exec_method>

</instance>

<stability value=’Evolving’ />
<template>
<common_name>
<loctext xml:lang=’C’>
Network UPS Tools
</loctext>
</common_name>
</template>

</service>
</service_bundle>

You can download them directly from:
blogs.sun.com/mikey/resource/method-nut and blogs.sun.com/mikey/resource/manifest-nut

That’s everything, time to enable the service and test the configuration:

# svccfg import nut.xml
# svcadm enable svc:/application/nut:default
# /opt/nut/bin/upsc trust@localhost

battery.charge: 95.0
battery.voltage: 13.50
battery.voltage.nominal: 12.0
driver.name: megatec
driver.parameter.pollinterval: 2
driver.parameter.port: /dev/ttya
driver.version:
driver.version.internal: 1.5.4
input.frequency: 49.9
input.voltage: 247.0
input.voltage.fault: 247.0
input.voltage.maximum: 252.3
input.voltage.minimum: 243.0
output.voltage: 247.0
output.voltage.nominal: 230.0
ups.beeper.status: enabled
ups.delay.shutdown: 0
ups.delay.start: 2
ups.load: 11.0
ups.mfr: unknown
ups.model: unknown
ups.serial: unknown
ups.status: OL
ups.temperature: 25.0

You should be able to see the output similar to this above, which is a kind of confirmation that everything works fine.

SACalendar

SACalendar is a customizable iOS 7 Calendar.



Download here

Logging service for Swift – Swell

Swell is a logging utility for Swift and Objective C.

Features

????Turn on logging during development, turn them off when building for the App Store
????Enable or disable logging for specific classes
????Different log levels allow for finer-grained control of logging within a class
????Log to the console, text file, or a custom location
????Log message isn’t computed when logging is disabled (thanks to the @auto_closure feature)

Download here

RFRateMe for iOS


RFRateMe will help you promote your iPhone/iPad app without irritating your users. It’s very simple to install, use and configure (If you need to change the default behavior).
via Feedly/Pocket ift.tt/1hxgx67 on January 25, 2014 at 09:56PM

sakkaras/SKSTableView · GitHub


SKSTableView is a custom table view class extended from UITableView class. This class provides a single-level hierarchical structure(an expandable table view) for your contents.
via Feedly/Pocket ift.tt/Kmf1sz on January 19, 2014 at 02:02PM

fullc0de/HKKTagWriteView · GitHub


This is an input custom view like Evernote app style tagging. The major difference is that the view supports only single line of tagging with horizontal scroll.
via Feedly/Pocket ift.tt/1cIdXFN on January 19, 2014 at 08:37AM

benzguo/BZGFormViewController · GitHub


BZGFormViewController is a lightweight UITableViewController subclass inspired by the dynamic form validation UX in Twitter’s iOS app. If you’re using cocoapods, just add pod ‘BZGFormViewController’ to your Podfile. Otherwise, add the contents of BZGFormViewController to your project.
via Feedly/Pocket github.com/benzguo/BZGFormViewController on January 15, 2014 at 10:50PM

Boris-Em/BEMSimpleLineGraph · GitHub


BEMSimpleLineGraph makes it easy to create and customize line graphs for iOS. Learn more about the BEMSimpleLineGraph project requirements, licensing, and contributions.
via Feedly/Pocket github.com/Boris-Em/BEMSimpleLineGraph on January 14, 2014 at 02:55PM

vtourraine/VTAcknowledgementsViewController · GitHub


Ready to use “Acknowledgements”/“Licenses” view controller for CocoaPods. This project is only useful if you use CocoaPods, so let’s assume that you’re indeed using CocoaPods.
via Feedly/Pocket github.com/vtourraine/VTAcknowledgementsViewController on January 12, 2014 at 04:17PM

brianmichel/BMInitialsPlaceholderView · GitHub


A view capable of drawing initials into a circle. Similar to what iMessage does when you are enaged in a group chat.
via Feedly/Pocket github.com/brianmichel/BMInitialsPlaceholderView on January 02, 2014 at 09:48PM

WP Like Button Plugin by Free WordPress Templates