line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hardware::UPS::Perl::Constants; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#============================================================================== |
4
|
|
|
|
|
|
|
# package description: |
5
|
|
|
|
|
|
|
#============================================================================== |
6
|
|
|
|
|
|
|
# This package defines the following variables to be used in Perl modules and |
7
|
|
|
|
|
|
|
# scripts dealing with an UPS. For a detailed description see the pod |
8
|
|
|
|
|
|
|
# documentation included at the end of this file. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Constants: |
11
|
|
|
|
|
|
|
# ---------- |
12
|
|
|
|
|
|
|
# UPSBASENAME - the basename of the script |
13
|
|
|
|
|
|
|
# UPSEXECUTABLE - the complete path to the script |
14
|
|
|
|
|
|
|
# UPSFQDN - the FQDN of the local host |
15
|
|
|
|
|
|
|
# UPSHOSTNAME - the hostname of the local host |
16
|
|
|
|
|
|
|
# UPSLOGFILE - the default log file |
17
|
|
|
|
|
|
|
# UPSMAILTO - the default address to send mails to in case of alerts |
18
|
|
|
|
|
|
|
# UPSPIDFILE - the standard PID file |
19
|
|
|
|
|
|
|
# UPSPORT - the default serial port |
20
|
|
|
|
|
|
|
# UPSSCRIPT - script name |
21
|
|
|
|
|
|
|
# UPSTCPPORT - the default TCP/IP port for network communication |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
#============================================================================== |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#============================================================================== |
26
|
|
|
|
|
|
|
# Copyright: |
27
|
|
|
|
|
|
|
#============================================================================== |
28
|
|
|
|
|
|
|
# Copyright (c) 2007 Christian Reile, . All |
29
|
|
|
|
|
|
|
# rights reserved. This program is free software; you can redistribute it |
30
|
|
|
|
|
|
|
# and/or modify it under the same terms as Perl itself. |
31
|
|
|
|
|
|
|
#============================================================================== |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#============================================================================== |
34
|
|
|
|
|
|
|
# Entries for Revision Control: |
35
|
|
|
|
|
|
|
#============================================================================== |
36
|
|
|
|
|
|
|
# Revision : $Revision: 1.7 $ |
37
|
|
|
|
|
|
|
# Author : $Author: creile $ |
38
|
|
|
|
|
|
|
# Last Modified On: $Date: 2007/04/14 09:37:26 $ |
39
|
|
|
|
|
|
|
# Status : $State: Exp $ |
40
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
41
|
|
|
|
|
|
|
# Modifications : |
42
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# $Log: Constants.pm,v $ |
45
|
|
|
|
|
|
|
# Revision 1.7 2007/04/14 09:37:26 creile |
46
|
|
|
|
|
|
|
# documentation update. |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# Revision 1.6 2007/04/07 15:13:47 creile |
49
|
|
|
|
|
|
|
# adaptations to "best practices" style; |
50
|
|
|
|
|
|
|
# update of documentation. |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# Revision 1.5 2007/03/13 17:18:04 creile |
53
|
|
|
|
|
|
|
# some beautifications. |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
# Revision 1.4 2007/03/03 21:09:03 creile |
56
|
|
|
|
|
|
|
# usage of perl pragma constant declaring everything as |
57
|
|
|
|
|
|
|
# real constants. |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
# Revision 1.3 2007/02/05 20:32:36 creile |
60
|
|
|
|
|
|
|
# almost all constants are in @EXPORT_OK now; |
61
|
|
|
|
|
|
|
# pod documentation revised. |
62
|
|
|
|
|
|
|
# |
63
|
|
|
|
|
|
|
# Revision 1.2 2007/02/04 19:01:31 creile |
64
|
|
|
|
|
|
|
# bug fix of pod documentation. |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
# Revision 1.1 2007/02/03 16:44:50 creile |
67
|
|
|
|
|
|
|
# initial revision. |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
#============================================================================== |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#============================================================================== |
73
|
|
|
|
|
|
|
# module preamble: |
74
|
|
|
|
|
|
|
#============================================================================== |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
BEGIN { |
79
|
1
|
|
|
1
|
|
7
|
use Exporter (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
80
|
1
|
|
|
1
|
|
18
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
210
|
|
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
1
|
|
14
|
$VERSION = sprintf( "%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/ ); |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
23
|
@ISA = qw(Exporter); |
85
|
1
|
|
|
|
|
2
|
@EXPORT = qw( |
86
|
|
|
|
|
|
|
); |
87
|
1
|
|
|
|
|
3
|
@EXPORT_OK = qw( |
88
|
|
|
|
|
|
|
UPSBASENAME |
89
|
|
|
|
|
|
|
UPSEXECUTABLE |
90
|
|
|
|
|
|
|
UPSFQDN |
91
|
|
|
|
|
|
|
UPSHOSTNAME |
92
|
|
|
|
|
|
|
UPSMAILTO |
93
|
|
|
|
|
|
|
UPSLOGFILE |
94
|
|
|
|
|
|
|
UPSPIDFILE |
95
|
|
|
|
|
|
|
UPSPORT |
96
|
|
|
|
|
|
|
UPSSCRIPT |
97
|
|
|
|
|
|
|
UPSTCPPORT |
98
|
|
|
|
|
|
|
); |
99
|
1
|
|
|
|
|
33
|
%EXPORT_TAGS = qw(); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
1
|
|
|
1
|
|
6
|
use vars @EXPORT; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#============================================================================== |
106
|
|
|
|
|
|
|
# end of module preamble |
107
|
|
|
|
|
|
|
#============================================================================== |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
#============================================================================== |
110
|
|
|
|
|
|
|
# packages required: |
111
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
112
|
|
|
|
|
|
|
# |
113
|
|
|
|
|
|
|
# constant - Perl pragma to declare constants |
114
|
|
|
|
|
|
|
# Env - Perl module that imports environment variables |
115
|
|
|
|
|
|
|
# as scalars or arrays |
116
|
|
|
|
|
|
|
# File::Basename - Parse file paths into directory, filename and |
117
|
|
|
|
|
|
|
# suffix |
118
|
|
|
|
|
|
|
# File::Spec::Functions - portably perform operations on file names |
119
|
|
|
|
|
|
|
# FindBin - Locate directory of original perl script |
120
|
|
|
|
|
|
|
# Net::Domain - evaluate the current host's internet name and |
121
|
|
|
|
|
|
|
# domain |
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
#============================================================================== |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
9
|
use Env qw( |
126
|
|
|
|
|
|
|
UPS_MAILTO |
127
|
|
|
|
|
|
|
UPS_PORT |
128
|
|
|
|
|
|
|
UPS_TCPPORT |
129
|
1
|
|
|
1
|
|
1996
|
); |
|
1
|
|
|
|
|
3810
|
|
130
|
1
|
|
|
1
|
|
211
|
use File::Basename (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
131
|
1
|
|
|
1
|
|
1163
|
use File::Spec::Functions; |
|
1
|
|
|
|
|
978
|
|
|
1
|
|
|
|
|
122
|
|
132
|
1
|
|
|
1
|
|
1124
|
use FindBin (); |
|
1
|
|
|
|
|
1179
|
|
|
1
|
|
|
|
|
23
|
|
133
|
1
|
|
|
1
|
|
1028
|
use Net::Domain; |
|
1
|
|
|
|
|
15819
|
|
|
1
|
|
|
|
|
80
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#============================================================================== |
136
|
|
|
|
|
|
|
# defining exported constants: |
137
|
|
|
|
|
|
|
#============================================================================== |
138
|
|
|
|
|
|
|
|
139
|
1
|
|
|
1
|
|
13
|
use constant UPSFQDN => Net::Domain->hostfqdn(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
140
|
1
|
|
|
1
|
|
751
|
use constant UPSHOSTNAME => Net::Domain->hostname(); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
141
|
|
|
|
|
|
|
|
142
|
1
|
50
|
|
1
|
|
62
|
use constant UPSMAILTO => $UPS_MAILTO ? $UPS_MAILTO : q{}; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
143
|
1
|
50
|
|
1
|
|
368
|
use constant UPSPORT => $UPS_PORT ? $UPS_PORT : "/dev/ttyS0"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
144
|
1
|
50
|
|
1
|
|
59
|
use constant UPSTCPPORT => $UPS_TCPPORT ? $UPS_TCPPORT : "9050"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
145
|
|
|
|
|
|
|
|
146
|
1
|
|
|
1
|
|
61
|
use constant UPSBASENAME => File::Basename::basename($0); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
124
|
|
147
|
1
|
|
|
1
|
|
5
|
use constant UPSEXECUTABLE => catfile $FindBin::Bin, UPSBASENAME; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
152
|
|
148
|
|
|
|
|
|
|
|
149
|
1
|
50
|
|
|
|
71
|
use constant UPSSCRIPT => sprintf( |
150
|
|
|
|
|
|
|
"%s", UPSBASENAME =~ /\.pl$/ ? $` =~ /(\w+)$/ : UPSBASENAME =~ /(\w+)$/ |
151
|
1
|
|
|
1
|
|
5
|
); |
|
1
|
|
|
|
|
3
|
|
152
|
|
|
|
|
|
|
|
153
|
1
|
|
|
1
|
|
4
|
use constant UPSLOGFILE => "/var/log/" . UPSSCRIPT . ".log"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
154
|
1
|
|
|
1
|
|
6
|
use constant UPSPIDFILE => "/var/run/" . UPSSCRIPT . ".pid"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#============================================================================== |
157
|
|
|
|
|
|
|
# package return: |
158
|
|
|
|
|
|
|
#============================================================================== |
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__END__ |