Skip to content

Commit

Permalink
Merge pull request #5 in BIOS/nut from ~E9926362/nut:obs/BUILD to obs…
Browse files Browse the repository at this point in the history
…/BUILD

* commit 'dfdf588dac92d3be175dac30a875e0b19551aefe': (22 commits)
  snmp-ups.c : a little bit of input checking does not hurt, especially when it fixes a segfault
  Remove unimplement nut-scanner option
  Update nut-scanner manual page
  Fix c++ style comments
  upsstats.html: Conform to HTML 4.01 Strict
  upsstats-single.html: Conform to HTML 4.01 Strict
  Fix c++ style comments
  Fix exit code for --list
  common.c/.h : simplify the upsdebugx() enhancement (no need to fight with warnings/pragmas)
  common.h : rearranged the ENABLE_WARNING/DISABLE_WARNING macro definitions so they are only called for supported compilers and generate empty macros (no-op) for others
  common.c : move anti-warning macros out of the function body, some compilers do not like that
  common.c : in upsdebugx() added "[Dx]" prefix : do not add it for level 0
  configure.ac : do not fail configuration if a doctype picked with "auto" can not be built on this system - just skip it
  Added and documented an snmp-ups argument to list currently loaded MIB-to-NUT mappings (typo fix)
  Added and documented an snmp-ups argument to list currently loaded MIB-to-NUT mappings
  snmp-ups.c : small typo fix
  Mention tripplite mapping in snmp-ups manpage; updated some comments about it in ietf-mib.c
  configure.ac : when verifying ability to build docs, consider out-of-tree builds too
  configure.ac : verify that we can actually build a simple or chunked HTML document, beside having nominal versions of software
  configure.ac : verify that we can actually build a manpage document, beside having nominal versions of software
  ...
  • Loading branch information
arnaudquette-eaton committed Oct 11, 2016
2 parents c0b380b + dfdf588 commit e87398e
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 80 deletions.
12 changes: 6 additions & 6 deletions common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,11 @@ void upsdebug_with_errno(int level, const char *fmt, ...)
if (nut_debug_level < level)
return;

// For debugging output, we want to prepend the debug level so the user can
// e.g. lower the level (less -D's on command line) to retain just the amount
// of logging info he needs to see at the moment. Using '-DDDDD' all the time
// is too brutal and needed high-level overview can be lost. This [D#] prefix
// can help limit this debug stream quicker, than experimentally picking ;)
/* For debugging output, we want to prepend the debug level so the user can
* e.g. lower the level (less -D's on command line) to retain just the amount
* of logging info he needs to see at the moment. Using '-DDDDD' all the time
* is too brutal and needed high-level overview can be lost. This [D#] prefix
* can help limit this debug stream quicker, than experimentally picking ;) */
char fmt2[LARGEBUF];
if (level > 0) {
int ret;
Expand All @@ -446,7 +446,7 @@ void upsdebugx(int level, const char *fmt, ...)
if (nut_debug_level < level)
return;

// See comments above in upsdebug_with_errno() - they apply here too.
/* See comments above in upsdebug_with_errno() - they apply here too. */
char fmt2[LARGEBUF];
if (level > 0) {
int ret;
Expand Down
38 changes: 25 additions & 13 deletions conf/upsstats-single.html.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@
@UPSSTATSPATH upsstats.cgi@
@UPSIMAGEPATH upsimage.cgi@

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@REFRESH@
<title>@HOSTDESC@ : @VAR ups.model@ on @HOST@</title>
<!-- LINK REL="stylesheet" TYPE="text/css" HREF="http://localhost/nut/nut.css" / -->
<style type="text/css">
body{color:#00fc00; background:#808080; font-family:"Times New Roman", Times, serif;}
a:link{color:#00e;}
a:visited{color:#551a8b;}
table{background:#000;}
</style>
</head>
<body BGCOLOR="#808080" TEXT="#00FC00" LINK="#0000EE" VLINK="#551A8B">
<body>

<table BORDER="1" ALIGN="CENTER" CELLSPACING="0" CELLPADDING="10" BGCOLOR="#000000">
<table style="margin:auto" BORDER="1" CELLSPACING="0" CELLPADDING="10">

<tr>
<th COLSPAN="20">Network UPS Tools upsstats @VERSION@ - @HOSTDESC@ - @VAR ups.model@ on @HOST@</th>
Expand All @@ -51,7 +57,7 @@

<tr>

<td BGCOLOR="#000000" VALIGN="TOP">
<td VALIGN="TOP">

<table BORDER="0"> <!-- table 2 -->

Expand Down Expand Up @@ -195,29 +201,29 @@

@IFSUPP ambient.temperature@
@IFSUPP ambient.humidity@
<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
<td ALIGN="CENTER">Temperature<br>@IMG ambient.temperature tempmin=0 tempmax=50 width=90@</td>
<td ALIGN="CENTER">Humidity<br>@IMG ambient.humidity width=90@</td>
</tr></table>
</td>
@ELSE@
@IFSUPP ambient.temperature@
<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
<td ALIGN="CENTER">Temperature<br>@IMG ambient.temperature tempmin=0 tempmax=50@</td>
</tr></table>
</td>
@ELSE@
@IFSUPP ambient.humidity@
<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
<td ALIGN="CENTER">Humidity<br>@IMG ambient.humidity@</td>
</tr></table>
</td>
@ENDIF@

<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
@IFSUPP battery.charge@
@IFSUPP battery.voltage@
Expand All @@ -232,7 +238,7 @@
</tr></table>
</td>

<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
@IFSUPP input.L2-L3.voltage@
<td ALIGN="CENTER">L1-L2<br>@IMG input.L1-L2.voltage width=68@</td>
Expand All @@ -249,7 +255,7 @@
</tr></table>
</td>

<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
@IFSUPP output.L2-L3.voltage@
<td ALIGN="CENTER">L1-L2<br>@IMG output.L1-L2.voltage width=68@</td>
Expand All @@ -266,7 +272,7 @@
</tr></table>
</td>

<td ALIGN="CENTER" VALIGN="TOP" BGCOLOR="#000000">
<td ALIGN="CENTER" VALIGN="TOP">
<table BORDER="0"><tr>
@IFSUPP output.L2.power.percent@
<td ALIGN="CENTER">L1<br>@IMG output.L1.power.percent width=68@</td>
Expand All @@ -286,6 +292,12 @@
</tr>

</table>

<div><a href="https://jigsaw.w3.org/css-validator/check/referer"><img
style="float:right" src="https://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS" title="Valid CSS" height="31" width="88"></a>
<a href="https://validator.w3.org/check?uri=referer"><img
style="float:right" src="https://www.w3.org/Icons/valid-html401"
alt="Valid HTML 4.01 Strict" title="Valid HTML 4.01 Strict"
height="31" width="88"></a></div>
</body>
</html>
59 changes: 36 additions & 23 deletions conf/upsstats.html.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
@UPSSTATSPATH upsstats.cgi@
@UPSIMAGEPATH upsimage.cgi@

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
Expand All @@ -28,29 +28,37 @@ Network UPS Tools upsstats
@VERSION@
: UPS Status
</title>
<style type="text/css">
body{font-family:"Times New Roman", Times, serif;}
a:link{color:#00e;}
a:visited{color:#551a8b;}
th, td{padding:0.5ex;}
.t1{background:#0ff;}
.t2{background:#0f0;}
</style>
<!-- link rel="stylesheet" type="text/css" href="nut.css" / -->
@REFRESH@
</head>
<body BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000EE" VLINK="#551A8B">
<body>

<table BGCOLOR="#50A0A0" ALIGN="CENTER">
<table style="margin:auto; background:#50A0A0; text-align:center;">
<tr><td>

<table CELLPADDING="5">
<table>
<tr>
<th COLSPAN="10" BGCOLOR="#60B0B0">
<th COLSPAN="10" style="background:#60B0B0;">

<font SIZE="+2">Network UPS Tools upsstats
<span style="font-size:1.5em">Network UPS Tools upsstats
@VERSION@
</font>
</span>

<br>
@DATE %a %b %d %X %Z %Y@
</th>

</tr>

<tr BGCOLOR="#60B0B0">
<tr style="background:#60B0B0;">
<th COLSPAN="1">System</th>
<th COLSPAN="1">Model</th>
<th COLSPAN="1">Status</th>
Expand All @@ -65,20 +73,20 @@ Network UPS Tools upsstats

@FOREACHUPS@

<tr ALIGN=CENTER>
<td BGCOLOR="#00FFFF">
<tr>
<td class="t1">
@HOSTLINK@
</td>

<td BGCOLOR="#00FFFF">
<td class="t1">
@VAR ups.model@
</td>

<td BGCOLOR="@STATUSCOLOR@">
<td style="background:@STATUSCOLOR@">
@STATUS@
</td>

<td BGCOLOR="#00FF00">
<td class="t2">
@IFSUPP battery.charge@
@VAR battery.charge@
%
Expand All @@ -89,18 +97,18 @@ Network UPS Tools upsstats
@IFBETWEEN input.transfer.low input.transfer.high input.L1-L2.voltage@
@IFBETWEEN input.transfer.low input.transfer.high input.L2-L3.voltage@
@IFBETWEEN input.transfer.low input.transfer.high input.L3-L1.voltage@
<td BGCOLOR="#00FF00">
<td class="t2">
@ELSE@
@IFSUPP input.L2-N.voltage@
@IFBETWEEN input.transfer.low input.transfer.high input.L1-N.voltage@
@IFBETWEEN input.transfer.low input.transfer.high input.L2-N.voltage@
@IFBETWEEN input.transfer.low input.transfer.high input.L3-N.voltage@
<td BGCOLOR="#00FF00">
<td class="t2">
@ELSE@
@IFBETWEEN input.transfer.low input.transfer.high input.voltage@
<td BGCOLOR="#00FF00">
<td class="t2">
@ELSE@
<td BGCOLOR="#FF0000">
<td style="background:red;">
@ENDIF@

@IFSUPP input.L2-L3.voltage@
Expand All @@ -118,7 +126,7 @@ Network UPS Tools upsstats
@ENDIF@
</td>

<td BGCOLOR="#00FF00">
<td class="t2">
@IFSUPP output.L2-L3.voltage@
@VAR output.L1-L2.voltage@
@VAR output.L2-L3.voltage@
Expand All @@ -134,7 +142,7 @@ Network UPS Tools upsstats
@ENDIF@
</td>

<td BGCOLOR="#00FF00">
<td class="t2">
@IFSUPP output.L2.power.percent@
@VAR output.L1.power.percent@
@VAR output.L2.power.percent@
Expand All @@ -151,7 +159,7 @@ Network UPS Tools upsstats
@ENDIF@
</td>

<td BGCOLOR="#00FF00">
<td class="t2">
@IFSUPP ups.temperature@
@UPSTEMP@
@DEGREES@
Expand All @@ -162,13 +170,13 @@ Network UPS Tools upsstats
@ENDIF@
</td>

<td BGCOLOR="#00FF00">
<td class="t2">
@IFSUPP battery.runtime@
@RUNTIME@
@ENDIF@
</td>

<td BGCOLOR="#00FF00">
<td class="t2">
@TREELINK@
</td>
</tr>
Expand All @@ -180,4 +188,9 @@ Network UPS Tools upsstats
</td></tr>
</table>

<hr><div><small>
<a href="https://jigsaw.w3.org/css-validator/check/referer"><img style="float:right" src="https://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88"></a>
<a href="https://validator.w3.org/check?uri=referer"><img style="float:right" src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Strict" height="31" width="88"></a>
</small></div>

</body></html>
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ if test -z "${abs_srcdir}" ; then
*) abs_srcdir="$(cd "${srcdir}" && pwd)" ;;
esac
fi
DOCTESTDIR="$(mktemp -d configure-test.docbuild.$$.XXXXXXX)" && \
DOCTESTDIR="$(mktemp -d --tmpdir="`pwd`" configure-test.docbuild.$$.XXXXXXX)" && \
DOCTESTDIR="$(cd "$DOCTESTDIR" && pwd)"
for nut_doc_build_target in $nut_doc_build_list; do
case "${nut_doc_build_target}" in
Expand Down
2 changes: 1 addition & 1 deletion docs/man/nut-scanner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This option must be requested explicitely, even for a complete scan.
'serial ports' can be expressed in various forms:

- 'auto' to scan all serial ports.
- a single charcater indicating a port number ('0' (zero) for /dev/ttyS0 and
- a single character indicating a port number ('0' (zero) for /dev/ttyS0 and
/dev/ttyUSB0 on Linux, '1' for COM1 on Windows, 'a' for /dev/ttya on Solaris...)
- a range of N characters, hyphen separated, describing the range of
ports using 'X-Y', where X and Y are characters refering to the port number.
Expand Down
10 changes: 8 additions & 2 deletions docs/man/snmp-ups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ linkman:nutupsdrv[8].
SUPPORTED HARDWARE
------------------

The snmp-ups driver automatically detects and supports a wide range of devices by loading various MIBS:
The snmp-ups driver automatically detects and supports a wide range of devices by loading various MIBS, such as:

*ietf*::
UPS that is RFC 1628 (UPS MIB) compliant, e.g. MGE UPS SYSTEMS, Liebert, perhaps others (default)
Expand Down Expand Up @@ -59,7 +59,13 @@ Cyberpower RMCARD201. Should also support RMCARD100 (net version), RMCARD202 and
*huawei*::
Huawei UPS5000-E, perhaps others

For a more up-to-date listing, you can query the driver by passing the *mibs=--list* argument (see below).
*tripplite*::
TrippLite UPSes; at this time this is the IETF MIB mapping with just
the Tripplite entry point OID to verify the device vendor, and a real
hardware-specific configuration will be added in the future development.

For a complete and up-to-date listing, you can query the driver by passing
the *mibs=--list* argument (see below).

EXTRA ARGUMENTS
---------------
Expand Down
15 changes: 14 additions & 1 deletion drivers/ietf-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
/* SNMP OIDs set */
#define IETF_OID_UPS_MIB "1.3.6.1.2.1.33.1."
#define IETF_SYSOID ".1.3.6.1.2.1.33"

/* NOTE: Currently the Tripplite UPSes await user-validation of their
* real SNMP OID tree, so temporarily the IETF tree is used as "tripplite"
* for the mapping purposes; the devices ave their entry point OID though.
* For more details see:
* https://github.com/networkupstools/nut/issues/309
* https://github.com/networkupstools/nut/issues/171
* Also related to:
* https://github.com/networkupstools/nut/issues/270
*/
#define TRIPPLITE_SYSOID ".1.3.6.1.4.1.850.1"

/* #define DEBUG */
Expand Down Expand Up @@ -276,4 +286,7 @@ static snmp_info_t ietf_mib[] = {
};

mib2nut_info_t ietf = { "ietf", IETF_MIB_VERSION, IETF_OID_UPS_MIB "4.1.0", IETF_OID_UPS_MIB "1.1.0", ietf_mib, IETF_SYSOID };
mib2nut_info_t tripplite_ietf = { "ietf", IETF_MIB_VERSION, NULL, NULL, ietf_mib, TRIPPLITE_SYSOID };

/* FIXME: Rename the structure here (or even relocate to new file)
* and in snmp-ups.c when the real TrippLite mappings get defined. */
mib2nut_info_t tripplite_ietf = { "tripplite", IETF_MIB_VERSION, NULL, NULL, ietf_mib, TRIPPLITE_SYSOID };
4 changes: 3 additions & 1 deletion drivers/snmp-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void upsdrv_initups(void)
mib2nut[i]->oid_auto_check ? mib2nut[i]->oid_auto_check : "<NULL>" );
}
printf("\nOverall this driver has loaded %d MIB-to-NUT mapping tables\n", i);
fatalx(EXIT_FAILURE, "Marking the exit code as failure since the driver is not started now");
exit(EXIT_SUCCESS);
}

/* init SNMP library, etc... */
Expand Down Expand Up @@ -709,6 +709,8 @@ void nut_snmp_free(struct snmp_pdu ** array_to_free)
{
struct snmp_pdu ** current_element;

if (array_to_free == NULL) return;

current_element = array_to_free;

while (*current_element != NULL) {
Expand Down
1 change: 0 additions & 1 deletion tools/nut-scanner/nut-scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ typedef struct nutscan_snmp {
char * privProtocol;
char * peername;
void * handle;
char * fingerprints_file;
} nutscan_snmp_t;

/* IPMI structure */
Expand Down
Loading

0 comments on commit e87398e

Please sign in to comment.