Raritan / Server Technology Xerus™ PDU JSON-RPC API
ServerMonitor.idl
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright 2010 Raritan Inc. All rights reserved.
4  */
5 
6 #include <Event.idl>
7 #include <UserEvent.idl>
8 
9 /** Server Monitor */
10 module servermon {
11 
12  /** Server Monitor Interface */
13  interface ServerMonitor {
14 
15  /**
16  * Server Reachability State
17  */
18  enumeration ServerReachability {
19  WAITING, ///< Waiting for reliable connection
20  REACHABLE, ///< Server is up and running
21  UNREACHABLE, ///< No response from server
22  ERROR ///< Error pinging server (e.g. DNS lookup failure)
23  };
24 
25  /**
26  * Server Power Control State
27  */
28  enumeration ServerPowerState {
29  UNKNOWN, ///< Power state currently not known
30  ON, ///< Server power target is on
31  OFF, ///< Server power target is off
32  SHUTTING_DOWN ///< Server is being manually shut down
33  };
34 
35  /**
36  * Server Power Control Result
37  */
39  NO_ERROR, ///< No error, operation may still be in progress
40  SHUTDOWN_CMD_FAILED, ///< Error issuing the shutdown command to the server
41  SWITCHING_OFF_FAILED, ///< Switching the outlet or outlet group off failed
42  SWITCHING_ON_FAILED, ///< Switching the outlet or outlet group on failed
43  POWER_CHECK_TIMEOUT ///< Checking if power is off timed out
44  };
45 
46  /**
47  * Methods of checking power state
48  */
49  enumeration ServerPowerCheckMethod {
50  TIMER, ///< Server is assumed to be off after a time interval
51  POWER_DROP ///< Server is off if power consumption dropped
52  };
53 
54  /**
55  * Settings for controlling and checking power state of the server
56  */
57  structure ServerPowerSettings {
58  boolean enabled; ///< Power control for this server enabled
59  Object target; ///< Target for power control, Outlet or OutletGroup
60  ServerPowerCheckMethod powerCheck; ///< Method to check server's power state
61  double powerThreshold; ///< Active power below this threshold means server is off (in Watt)
62  int timeout; ///< Seconds the power check takes before it ends / times out
63  string shutdownCmd; ///< Shutdown command to send to the server
64  string username; ///< Login used to issue shutdown command to the server
65  string password; ///< Password for the login, write-only, not set if empty
66  int sshPort; ///< SSH port of the server
67  };
68 
69  /**
70  * Server Reachability Settings
71  */
72  [sparse_in]
73  structure ServerSettings {
74  string host; ///< Server hostname/IP address
75  boolean enabled; ///< Pinging enabled
76  int pingInterval; ///< Wait time after successful ping
77  int retryInterval; ///< Wait time after unsuccessful ping
78  int activationCount; ///< Minimum number of successful pings to enable feature
79  int failureCount; ///< Number of unsuccessful pings to consider server down
80  int resumeDelay; ///< Wait time before resuming pinging
81  int resumeCount; ///< Number of resumes before going back to WAITING state
82  ServerPowerSettings powerSettings; ///< Settings for controlling the power state of the server
83  };
84 
85  /**
86  * Server Reachability Status
87  */
88  structure ServerStatus {
89  ServerPowerState powerState; ///< Power control state
90  ServerPowerControlResult lastPowerControlResult; ///< Last result of a power control operation
91  ServerReachability reachable; ///< Reachability state
92  time lastRequest; ///< UNIX timestamp (UTC) of last request sent
93  time lastResponse; ///< UNIX timestamp (UTC) of last response received
94  int requests; ///< Number of requests sent
95  int responses; ///< Number of responses received
96  int failures; ///< Number of consecutive failed pings
97  int resumes; ///< Number of resumes
98  };
99 
100  /**
101  * Event: ServerPowerState has changed
102  */
103  valueobject ServerPowerStateEvent extends idl.Event {
104  int id; ///< id of the server entry
105  string host; ///< Server hostname/IP address
106  ServerPowerState oldPowerState; ///< Old power state
107  ServerPowerState newPowerState; ///< New power state
108  };
109 
110  /**
111  * Event: A power control operation was initiated
112  */
113  valueobject ServerPowerControlInitiatedEvent extends event.UserEvent {
114  int id; ///< id of the server
115  string host; ///< Server hostname/IP address
116  boolean on; ///< True if server shall be switched on, false otherwise
117  };
118 
119  /**
120  * Event: A power control operation was completed
121  */
123  int id; ///< id of the server
124  string host; ///< Server hostname/IP address
125  ServerPowerControlResult result; ///< Result of the power control operation
126  };
127 
128  /**
129  * Event: Reachability status for a monitored server has changed or
130  * server continues to be unreachable
131  */
132  valueobject ServerReachabilityEvent extends idl.Event {
133  int id; ///< id of the server entry
134  string host; ///< Server hostname/IP address
135  ServerReachability reachable; ///< Current Reachability state
136  };
137 
138  /**
139  * A new server entry was added
140  */
141  valueobject ServerAddedEvent extends event.UserEvent {
142  int id; ///< id of the added server entry
143  ServerSettings settings; ///< Settings of the added server
144  };
145 
146  /**
147  * A server entry was changed
148  */
149  valueobject ServerSettingsChangedEvent extends event.UserEvent {
150  int id; ///< id of the server entry
151  ServerSettings oldSettings; ///< Settings before change
152  ServerSettings newSettings; ///< Settings after change
153  };
154 
155  /**
156  * A server entry was deleted
157  */
158  valueobject ServerDeletedEvent extends event.UserEvent {
159  int id; ///< id of the deleted server entry
160  };
161 
162  /**
163  * Server Entry
164  */
165  structure Server {
166  ServerSettings settings; ///< Server settings
167  ServerStatus status; ///< Server status
168  };
169 
170  constant int ERR_NO_SUCH_ID = 1; ///< No such ID
171  constant int ERR_INVALID_SETTINGS = 2; ///< Invalid settings
172  constant int ERR_DUPLICATE_HOSTNAME = 3; ///< Duplicate hostname
173  constant int ERR_MAX_SERVERS_REACHED = 4; ///< Maximum number of server entries
174 
175  /**
176  * Add a new server entry.
177  *
178  * @param id New entry id, automatically assigned
179  * @param settings New server settings
180  *
181  * @return 0 if OK
182  * @return 2 if the settings are invalid
183  * @return 3 if an entry for the given hostname exists
184  * @return 4 if the maximum number of servers is reached
185  *
186  * @note The ServerSettings structure can be "sparse"; fields missing in
187  * the JSON representation will be set to default values.
188  */
189  int addServer(out int id, in ServerSettings settings);
190 
191  /**
192  * Modify an existing server entry.
193  *
194  * @param id Entry id
195  * @param settings New settings
196  *
197  * @return 0 if OK
198  * @return 1 if the entry does not exist
199  * @return 2 if the settings are invalid
200  * @return 3 if an entry for the given hostname exists
201  *
202  * @note The ServerSettings structure can be "sparse"; fields missing in
203  * the JSON representation will remain unchanged.
204  */
205  int modifyServer(in int id, in ServerSettings settings);
206 
207  /**
208  * Delete a server entry.
209  *
210  * @param id Entry id
211  *
212  * @return 0 if OK
213  * @return 1 if the entry does not exist
214  */
215  int deleteServer(in int id);
216 
217  /**
218  * Retrieve a server entry (settings and status).
219  *
220  * @param server Server settings and status
221  * @param id Entry id
222  *
223  * @return 0 if OK
224  * @return 1 if the entry does not exist
225  */
226  int getServer(out Server server, in int id);
227 
228  /**
229  * Retrieve a list of server entries (settings and status).
230  *
231  * @return Server list
232  */
233  map<int, Server> listServers();
234 
235  /**
236  * Control the power state of the outlets the server uses.
237  * Attempting to switch the power off will issue a graceful shutdown of
238  * the server beforehand.
239  *
240  * @param id Entry id
241  * @param on Switch power on if true, off if false
242  *
243  * @return 0 if OK
244  * @return 1 if the entry does not exist
245  * @return 2 if the settings are invalid
246  */
247  int powerControl(in int id, in boolean on);
248 
249  };
250 
251 }
Server Monitor Interface.
Definition: ServerMonitor.idl:13
ServerPowerState
Server Power Control State.
Definition: ServerMonitor.idl:28
@ OFF
Server power target is off.
Definition: ServerMonitor.idl:31
@ UNKNOWN
Power state currently not known.
Definition: ServerMonitor.idl:29
@ ON
Server power target is on.
Definition: ServerMonitor.idl:30
ServerReachability
Server Reachability State.
Definition: ServerMonitor.idl:18
@ REACHABLE
Server is up and running.
Definition: ServerMonitor.idl:20
@ WAITING
Waiting for reliable connection.
Definition: ServerMonitor.idl:19
@ UNREACHABLE
No response from server.
Definition: ServerMonitor.idl:21
int deleteServer(in int id)
Delete a server entry.
int modifyServer(in int id, in ServerSettings settings)
Modify an existing server entry.
ServerPowerControlResult
Server Power Control Result.
Definition: ServerMonitor.idl:38
@ SWITCHING_ON_FAILED
Switching the outlet or outlet group on failed.
Definition: ServerMonitor.idl:42
@ SWITCHING_OFF_FAILED
Switching the outlet or outlet group off failed.
Definition: ServerMonitor.idl:41
@ SHUTDOWN_CMD_FAILED
Error issuing the shutdown command to the server.
Definition: ServerMonitor.idl:40
@ NO_ERROR
No error, operation may still be in progress.
Definition: ServerMonitor.idl:39
ServerPowerCheckMethod
Methods of checking power state.
Definition: ServerMonitor.idl:49
@ TIMER
Server is assumed to be off after a time interval.
Definition: ServerMonitor.idl:50
int powerControl(in int id, in boolean on)
Control the power state of the outlets the server uses.
int getServer(out Server server, in int id)
Retrieve a server entry (settings and status).
map< int, Server > listServers()
Retrieve a list of server entries (settings and status).
int addServer(out int id, in ServerSettings settings)
Add a new server entry.
Basic IDL definitions.
Definition: Event.idl:10
Server Monitor.
Definition: ServerMonitor.idl:10
Common base for all events.
Definition: Event.idl:13
A new server entry was added.
Definition: ServerMonitor.idl:141
ServerSettings settings
Settings of the added server.
Definition: ServerMonitor.idl:143
int id
id of the added server entry
Definition: ServerMonitor.idl:142
A server entry was deleted.
Definition: ServerMonitor.idl:158
int id
id of the deleted server entry
Definition: ServerMonitor.idl:159
Event: A power control operation was completed.
Definition: ServerMonitor.idl:122
ServerPowerControlResult result
Result of the power control operation.
Definition: ServerMonitor.idl:125
int id
id of the server
Definition: ServerMonitor.idl:123
string host
Server hostname/IP address.
Definition: ServerMonitor.idl:124
Event: A power control operation was initiated.
Definition: ServerMonitor.idl:113
int id
id of the server
Definition: ServerMonitor.idl:114
boolean on
True if server shall be switched on, false otherwise.
Definition: ServerMonitor.idl:116
string host
Server hostname/IP address.
Definition: ServerMonitor.idl:115
Settings for controlling and checking power state of the server.
Definition: ServerMonitor.idl:57
ServerPowerCheckMethod powerCheck
Method to check server's power state.
Definition: ServerMonitor.idl:60
string username
Login used to issue shutdown command to the server.
Definition: ServerMonitor.idl:64
int sshPort
SSH port of the server.
Definition: ServerMonitor.idl:66
double powerThreshold
Active power below this threshold means server is off (in Watt)
Definition: ServerMonitor.idl:61
string password
Password for the login, write-only, not set if empty.
Definition: ServerMonitor.idl:65
Object target
Target for power control, Outlet or OutletGroup.
Definition: ServerMonitor.idl:59
int timeout
Seconds the power check takes before it ends / times out.
Definition: ServerMonitor.idl:62
boolean enabled
Power control for this server enabled.
Definition: ServerMonitor.idl:58
string shutdownCmd
Shutdown command to send to the server.
Definition: ServerMonitor.idl:63
Event: ServerPowerState has changed.
Definition: ServerMonitor.idl:103
int id
id of the server entry
Definition: ServerMonitor.idl:104
ServerPowerState oldPowerState
Old power state.
Definition: ServerMonitor.idl:106
string host
Server hostname/IP address.
Definition: ServerMonitor.idl:105
ServerPowerState newPowerState
New power state.
Definition: ServerMonitor.idl:107
Event: Reachability status for a monitored server has changed or server continues to be unreachable.
Definition: ServerMonitor.idl:132
ServerReachability reachable
Current Reachability state.
Definition: ServerMonitor.idl:135
string host
Server hostname/IP address.
Definition: ServerMonitor.idl:134
int id
id of the server entry
Definition: ServerMonitor.idl:133
A server entry was changed.
Definition: ServerMonitor.idl:149
ServerSettings newSettings
Settings after change.
Definition: ServerMonitor.idl:152
ServerSettings oldSettings
Settings before change.
Definition: ServerMonitor.idl:151
int id
id of the server entry
Definition: ServerMonitor.idl:150
Server Reachability Settings.
Definition: ServerMonitor.idl:73
boolean enabled
Pinging enabled.
Definition: ServerMonitor.idl:75
int pingInterval
Wait time after successful ping.
Definition: ServerMonitor.idl:76
int activationCount
Minimum number of successful pings to enable feature.
Definition: ServerMonitor.idl:78
ServerPowerSettings powerSettings
Settings for controlling the power state of the server.
Definition: ServerMonitor.idl:82
int retryInterval
Wait time after unsuccessful ping.
Definition: ServerMonitor.idl:77
int resumeDelay
Wait time before resuming pinging.
Definition: ServerMonitor.idl:80
int resumeCount
Number of resumes before going back to WAITING state.
Definition: ServerMonitor.idl:81
int failureCount
Number of unsuccessful pings to consider server down.
Definition: ServerMonitor.idl:79
string host
Server hostname/IP address.
Definition: ServerMonitor.idl:74
Server Reachability Status.
Definition: ServerMonitor.idl:88
time lastResponse
UNIX timestamp (UTC) of last response received.
Definition: ServerMonitor.idl:93
int failures
Number of consecutive failed pings.
Definition: ServerMonitor.idl:96
ServerPowerState powerState
Power control state.
Definition: ServerMonitor.idl:89
int resumes
Number of resumes.
Definition: ServerMonitor.idl:97
ServerReachability reachable
Reachability state.
Definition: ServerMonitor.idl:91
int responses
Number of responses received.
Definition: ServerMonitor.idl:95
ServerPowerControlResult lastPowerControlResult
Last result of a power control operation.
Definition: ServerMonitor.idl:90
int requests
Number of requests sent.
Definition: ServerMonitor.idl:94
time lastRequest
UNIX timestamp (UTC) of last request sent.
Definition: ServerMonitor.idl:92
Server Entry.
Definition: ServerMonitor.idl:165
ServerSettings settings
Server settings.
Definition: ServerMonitor.idl:166
ServerStatus status
Server status.
Definition: ServerMonitor.idl:167