(266735) Agent Developers Guide PDF
(266735) Agent Developers Guide PDF
N10053F
January 2004
Disclaimer
The information contained in this publication is subject to change without notice. VERITAS Software
Corporation makes no warranty of any kind with regard to this manual, including, but not limited to,
the implied warranties of merchantability and tness for a particular purpose. VERITAS Software
Corporation shall not be liable for errors contained herein or for incidental or consequential damages
in connection with the furnishing, performance, or use of this manual.
logo, VERITAS Cluster Server, and all other VERITAS product names and slogans are trademarks or
registered trademarks of VERITAS Software Corporation. VERITAS and the VERITAS logo, Reg. U.S.
Pat. & Tm. Off. Other product names and/or slogans mentioned herein may be trademarks or
USA
www.veritas.com
Third-Party Copyrights
Apache Software
This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
Copyright (c) 1999 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modication, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
3. The end-user documentation included with the redistribution, if any, must include the following acknowledgement:
This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
Alternately, this acknowledgement may appear in the software itself, if and wherever such third-party acknowledgements normally appear.
4. The names The Jakarta Project, Tomcat, and Apache Software Foundation must not be used to endorse or promote products derived from
this software without prior written permission. For written permission, please contact [email protected].
5. Products derived from this software may not be called Apache nor may Apache appear in their names without prior written permission
THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information
on the Apache Software Foundation, please see http://www.apache.org/.
SNMP Software
SNMP support in VCS is based on CMU SNMP v2 under the following copyright:
Copyright 1989, 1991, 1992 by Carnegie Mellon University
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting
documentation, and that the name of CMU not be used in advertising or publicity pertaining to distribution of the software without specic,
written prior permission.
CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv
Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
Entry Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Applications Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
v
Example Script Entry Points for the FileOnOff Resource . . . . . . . . . . . . . . . . . . . . . . 7
Categories of Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Attribute Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
C++ Agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Script Agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
VCSAgStartup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Sample Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
clean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
ActionTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
shutdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Agent Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ArgList Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
VCSAgStartup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
resinfo_op . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
info_output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
opt_update_args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
opt_add_args . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
clean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
attr_changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
shutdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Contents vii
VCS Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
VCSAgRegisterEPStruct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
VCSAgSetCookie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
VCSAgRegister . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
VCSAgUnregister . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
VCSAgGetCookie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
VCSAgEncodeString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Example: VCSAgEncodeString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
VCSAgStrlcpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
VCSAgStrlcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
VCSAgSnprintf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
ArgList Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
clean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
attr_changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
shutdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Timestamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Severity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
UMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Message Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Log Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
VCSAG_SET_ENVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
VCSAG_LOG_MSG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
VCSAG_LOGDBG_MSG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Contents ix
ActionTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
AgentFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
AgentReplyTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
AgentStartTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
ArgList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
AttrChangedTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
CleanTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
CloseTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
ComputeStats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
ConfInterval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
FaultOnMonitorTimeouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
FireDrill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
InfoInterval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
InfoTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
LogDbg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
LogFileSize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
ManageFaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
MonitorInterval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
MonitorStatsParam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
MonitorTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
NumThreads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
OfflineMonitorInterval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
OfflineTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
OnlineRetryLimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
OnlineTimeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
OnlineWaitLimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
ResourceInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
RestartLimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
RegList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
SupportedActions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
ToleranceLimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
AgentClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
AgentPriority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
ScriptClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
ScriptPriority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Contents xi
Guidelines for Pre-VCS 4.0 Agents with VCS 4.0 Framework . . . . . . . . . . . . . . . . . . . 145
Mapping of Log Tags (pre-VCS 4.0) to Log Severities (VCS 4.0) . . . . . . . . . . . . . . 146
Comparing pre-VCS 4.0 APIs and VCS 4.0 Logging Macros . . . . . . . . . . . . . . . . . 147
VCSAgLogConsoleMsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
VCSAgLogI18NMsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
VCSAgLogI18NMsgEx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
VCSAgLogI18NConsoleMsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
VCSAgLogI18NConsoleMsgEx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
This guide describes the API provided by the VERITAS Cluster Server (VCS) agent
framework. It explains how to build and test an agent on UNIX platforms.
Each VCS agent manages resources of a particular type within a highly available cluster
environment. An agent typically brings resources online, takes resources ofine, and
monitors resources to determine their state.
For information on the hardware and software supported by VCS 4.0, and a brief
overview of the features of VCS 4.0, see VERITAS Cluster Server Release Notes.
For information on using and conguring VCS, see the VERITAS Cluster Server Users
Guide.
For information on using VCS bundled agents, see the VCS Bundled Agents Reference
Guide.
For more information on installing VCS, see the VERITAS Cluster Server Installation
Guide.
Getting Help
For technical assistance, visit the VERITAS Technical Services Web site at
http://support.veritas.com. From there you can:
Contact the VERITAS Technical Services staff and post questions to them.
Download the latest patches and utilities.
View the VCS Frequently Asked Questions (FAQ) page.
Search the knowledge base for answers to technical support questions.
Receive automatic notice of product updates.
Learn about VCS training.
Read white papers related to VCS.
Access the latest product documentation and technical notes.
xiii
How This Guide is Organized
Conventions
Typeface Usage
italic variables
Symbol Usage
Preface xv
Conventions
This guide describes the API provided by the VERITAS Cluster Server (VCS) agent
framework. It explains how to build and test an agent on UNIX platforms.
Note Custom agents, that is, agents developed outside of VERITAS, are not supported by
VERITAS Technical Support.
agent. The agent acts as an intermediary between VCS and the resource it manages,
Agents packaged with VCS are referred to as bundled agents. Examples of bundled agents
include Share, IP (Internet Protocol), and NIC (network interface card) agents. For more
information on VCS bundled agents, including their attributes and modes of operation,
Agents packaged separately for use with VCS are referred to as enterprise agents.
They include agents for Informix, Sybase, Oracle, and others. Contact your VERITAS sales
representative for information on how to purchase these agents for your conguration.
For information on installing and conguring VCS, see the VERITAS Cluster Server
Installation Guide.
1
How Agents Work
Note The VCS engine process is known as had. The acronym stands for
high-availability daemon.
Entry Points
An entry point is a section of code or a script used by the agent to carry out a specic
function on a resource. The agent framework supports a specic set of entry points, each
of which has a basic structure and a set of return values. Descriptions of each of the
supported entry points begin with Agent Entry Points on page 19.
The agent developer implements entry points for a resource by providing the specic
denitions required to manage the resource. For example, when implementing an agents
online entry point, the developer includes the command to start a resource; when
implementing the monitor entry point, the developer includes the commands to check if
the resource is online or not.
Applications Considerations
The application for which a VCS agent is developed must be capable of being controlled
by the agent and be able to operate in a cluster environment. The following criteria
describe an application that can successfully operate in a cluster:
The application must be capable of being started by a specic command or set of
commands. Specic commands must be available to start the applications external
resources such as le systems and IP addresses.
Each instance of an application must be capable of being stopped by a dened
procedure. Other instances of the application must not be affected.
The application must be capable of being stopped cleanly, by forcible means if
necessary.
Each instance of an application must be capable of being monitored. Monitoring can
be simple or in-depth. Monitoring an application becomes more effective when the
monitoring test resembles the actual activity of the applications user.
The application must be capable of storing data on shared disks rather than locally or
in memory, and each cluster system must be capable of accessing the data and all
information required to run the application.
The application must be crash-tolerant, that is, it must be capable of being run on a
system that crashes and of being started on a failover node in a known state. This
typically means that data is regularly written to shared storage rather than stored in
memory.
The application must be host-independent within a cluster; that is, there are no
licensing requirements or host name dependencies that prevent successful failover.
The application must run properly with other applications in the cluster.
Chapter 1, Introduction 3
Developing an Agent: Overview
str PathName
This denition is included in the VCS types.cf le. Note the following points about the
FileOnOff type denition:
The keyword type is followed by the name of the resource type, in this case,
FileOnOff.
The ArgList attribute includes the names of the attributes, listing them in the order
they are sent to the entry points. In the case of this example, the FileOnOff resource
type contains only one attribute, PathName, the pathname for the le.
The PathName attribute is dened as a str, or string variable. The data type for
each attribute must be dened.
Chapter 1, Introduction 5
Developing an Agent: Overview
FileOnOff temp_file01 (
PathName = "/tmp/test"
The include statement at the beginning of the main.cf le names the types.cf le,
which includes the FileOnOff resource type denition. The resource dened in the
main.cf le species:
The resource type: FileOnOff
The unique name of the resource, temp_file01
The value for the PathName attribute: /tmp/test
The agent creates a le test in the directory /tmp.
Note The actual VCS FileOnOff entry points are written in C++, but for this example,
shell script is used.
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
RESNAME=$1
VCSAG_SET_ENVS $RESNAME
if [ -z "$2" ]
then
1020
else
touch $2
fi
exit 0;
Chapter 1, Introduction 7
Developing an Agent: Overview
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
RESNAME=$1
VCSAG_SET_ENVS $RESNAME
if [ -z "$2" ]
then
1020
exit 99
else
fi
fi
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
RESNAME=$1
VCSAG_SET_ENVS $RESNAME
if [ -z "$2" ]
then
1020
else
/bin/rm f $2
fi
exit 0;
# resource.
Chapter 1, Introduction 9
Types of Resources and Agent Entry Points They Require
Categories of Attributes
Resource-specic attributes.
An attribute that can be dened for a specic resource only is resource-specic.
Examples include the PathName attribute for the FileOnOff resource and the
MountPoint attribute for the Mount resource. Resource-specic attributes are set in
the main.cf le.
Type-dependent attributes:
When attributes can be dened only for resources of a specic type, they are
type-dependent. An example would be the StartVolumes and Stop Volumes attributes
of the VCS DiskGroup resource type. All resources of the type DiskGroup have the
default values for these attributes. For example:
type DiskGroup (
int StartVolumes = 1
int StopVolumes = 1
Type-dependent attributes can be static and non-static. Static attributes are typically
dened in the types.cf le, identied as static. For example:
type FileOnOff (
Static resource type attributes can be overridden. See Overriding Static Attributes
on page 97.
Type-independent attributes:
An attribute that can be dened for resources regardless of their type is a
type-independent type. An example might be the MonitorInterval attribute. These
attributes are dened in the agent framework when the agent is developed.
The value of a type-independent attribute can be set for a give type. For example, the
default value of MonitorInterval is 60 seconds, but it can be set for a specic resource
type in the types.cf le.
type FileOnOff (
str PathName
Chapter 1, Introduction 11
The Attributes of Resources and Resource Types
NetMask = "255.255.255.0"
ArpDelay = 5
Options = "trailers"
Temp attributes
Temp attributes are maintained by VCS only at run time. Their values are not dumped
to disk and hence, are lost when VCS is stopped and restarted. Refer to the VERITAS
Cluster Server Users Guide for information about temp attributes.
Integer
Signed integer constants are a sequence of digits from 0 to 9. They may be preceded
by a dash, and are interpreted in base 10. Integers cannot exceed the value of a 32-bit
signed integer, 21471183247. For example:
int StartVolumes = 1
Boolean
A boolean is an integer, the possible values of which are 0 (false) and 1 (true). For
example, the Critical attribute has two possible values:
bool Critical = 1
Attribute Dimensions
Scalar
A scalar has only one value. This is the default dimension. The denition of an
attribute resembles:
str scalar_attribute
For example:
str MountPoint
When values are assigned to a scalar, the attribute in the main.cf le might
resemble:
MountPoint = "/Backup"
Vector
A vector is an ordered list of values. Each value is indexed using a positive integer
beginning with zero. A set of brackets ([]) denotes that the dimension is a vector.
Brackets are specied after the attribute name in the attribute denition. To dene an
attribute with a vector dimension, add a line in the resource type denition that
resembles:
str vector_attribute[]
For example:
str BackupSys[]
When values are assigned to a vector, the attribute in the main.cf le might
resemble:
BackupSys[] = { sysA, sysB, sysC }
Chapter 1, Introduction 13
The Attributes of Resources and Resource Types
Keylist
A keylist is an unordered list of strings, with each string being unique within the list.
To dene an attribute with a keylist dimension, add a line in the resource type
denition that resembles:
keylist keylist_attribute = { value1, value2 }
For example:
keylist BackupVols = {}
When values are assigned to a keylist, the attribute in the main.cf le might
resemble:
BackupVols = { vol1, vol2 }
Association
An association is an unordered list of name-value pairs. Each pair is separated by an
equal sign. A set of braces ({}) denotes that an attribute is an association. Braces are
specied after the attribute name in the attribute denition. To dene an attribute
with an association dimension, add a line in the resource type denition that
resembles:
int assoc_attr{} = { attr1 = val1, attr2 = val2 }
For example:
int BackupSysList {}
When values are assigned to an association, the attribute in the main.cf le might
resemble:
BackupSysList{} = { sysa=1, sysb=2, sysc=3 }
Developing a VCS agent requires using the agent framework and implementing entry
points. An entry point is a plug-in, dened by the user, that is called when an event, such as
onlining, ofining, or monitoring a resource, occurs within the VCS agent. Denitions of
each of the supported entry points begin with Agent Entry Points on page 19.
The VCS agent framework ensures that a resource has only one entry point running at a
time. If multiple requests or events are received for the same resource, they are queued,
then processed one at a time. An exception to this behavior is an optimization such that
the agent framework discards internally generated periodic monitoring requests for a
resource that is being monitored or that has a pending monitor request. However, because
the agent framework is multithreaded, a single agent process can run entry points of
several resources simultaneously. For example, if a resource receives requests to ofine
rst, then close, the offline entry point is called rst. The close entry point is called
only after the ofine request returns or times out. However, if the ofine request is
received for one resource, and the close request is received for another, both are called
simultaneously.
15
Using C++ or Script Entry Points
C++ Agents
If you create an agent with all the agents entry points in C++, or some entry points in C++
and some in script, you must create a C++ agent that contains the VCSAgStartup
routine, the necessary C++ primitives, and the C++ entry points. A sample le containing
templates for creating an agent using C++ entry points is located in
$VCS_HOME/src/agent/Sample. Refer to Building a Custom VCS Agent on page 87
for information about how to build an agent using C++ entry points or a combination of
C++ and script entry points. See also Implementing Entry Points Using C++ on page 31
or Implementing Entry Points Using Scripts on page 61.
Script Agents
If you create an agent using only script entry points, that is, no C++ code, you can base the
agent on the ScriptAgent, $VCS_HOME/bin/ScriptAgent. Refer to Building a Custom
VCS Agent on page 87 for information about creating an agent using only script entry
points. See also, Implementing Entry Points Using Scripts on page 61.
VCSAgStartup
When an agent starts, it uses the routine named VCSAgStartup to initialize the agents
data structures and connect the agent to the VCS engine. After the agent downloads the
necessary information it needs for the congured resources from the engine, it can control
the resources based on the entry points.
Sample Structure
VCSAgStartup registers the agent entry points with the agent framework by calling the
primitive VCSAgRegisterEPStruct, which includes the structure
VCSAgV40EntryPointStruct.
VCSAgV40EntryPointStruct has the following denition:
// Structure used to register the entry points.
typedef struct {
int *conf_level);
void **attr_val);
void **attr_val);
char *action_output);
***opt_add_args);
} VCSAgV40EntryPointStruct;
void my_shutdown() {
...
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
ep.open = NULL;
ep.online = NULL;
ep.offline = NULL;
ep.monitor = NULL;
ep.attr_changed = NULL;
ep.clean = NULL;
ep.close = NULL;
ep.info = NULL;
ep.action = NULL;
ep.shutdown = my_shutdown;
VCSAgRegisterEPStruct(V40, &ep);
monitor
The monitor entry point typically contains the code to determine status of the resource.
For example, the monitor entry point of the IP agent checks whether or not an IP address
is congured, and returns the state online, ofine, or unknown.
The framework calls the monitor entry point entry point after completing the online
and offline entry points to determine if bringing the resource online or taking it ofine
was effective. The agent framework also calls this entry point periodically to detect if the
resource was brought online or taken ofine unexpectedly. Under normal circumstances,
the monitor runs every sixty seconds when a resource is online, and every 300 seconds
when a resource of expected to be ofine.
The monitor entry point receives a resource name and ArgList attribute values as input
(see ArgList on page 99).
It returns the resource status (online, ofine, or unknown), and the condence level 0100.
The condence level is informative only and is not used by VCS. It is returned only when
the resource status is online.
A C++ entry point can return a condence level of 0100. A script entry point combines
the status and the condence level in a single number. For example:
100 indicates ofine.
101 indicates online and condence level 10.
102 indicates online and condence level 20.
103109 indicates online and condence levels 3090.
110 indicates online and condence level 100.
If the exit value of the monitor script entry point falls outside the range 100110, the status
is considered unknown.
info
The info entry point enables agents to obtain information about an online resource. For
example, the Mount agents info entry point could be used to report on space available
in the le system.
All information collected by the info entry point is stored in the temp attribute
ResourceInfo. The ResourceInfo attribute is a string association that stores
name-value pairs. By default, there are three such name-value pairs: State, Msg, and TS.
State indicates the status of the information contained in the ResourceInfo attribute;
Msg indicates the output of the info entry point, in any; TS indicates the timestamp of
when the ResourceInfo attribute was last modied.
The entry point can optionally modify a resources ResourceInfo attribute by adding or
updating other name-value pairs using the following commands:
hares -modify res ResourceInfo -add attribute value
or
hares -modify res ResourceInfo -update attribute value
For a description of the ResourceInfo attribute, see ResourceInfo on page 107. Refer
also to the manual page for the hares command.
For input, the info entry point receives as arguments the resource name, the value of
resinfo_op, and the ArgList attribute values. In the case of C++ implementation, the
output of the entry point is returned in info_output. Any optional name-value pairs are
returned in either opt_add_args or opt_update_args two-dimensional character
arrays. See the C++ example, Example, Info Entry Point Implementation in C++ on
page 39. For the script example, see info on page 65.
Return Values
If the info entry point exits with 0 (success), the output captured on stdout for the
script entry point, or the contents of the info_output argument for C++ entry point,
is dumped to the Msg key of the ResourceInfo attribute. The Msg key is updated
only when the info entry point is successful. The State key is set to the value: Valid.
If the entry point exits with a non-zero value, ResourceInfo is updated to indicate
the error; output of the scripts stdout or the C++ entry points info_output is
ignored. The State key is set to the value: Invalid. The error message is written to
the agents log le.
If the info entry point times out, output from the entry point is ignored. The State
key is set to the value: Invalid. The error message is written to the agents log le.
If the info entry point is killed by a user (for example, kill -15 pid), the State
key is set to the value: Invalid. The error message is written to the agents log le.
If the resource for which the entry point is invoked goes ofine or faults, the State key
is set to the value: Stale.
If the info entry point is not implemented, the State key is set to the value: Stale.
The error message is written to the agents log le.
The info entry point can be invoked from the command line for a given online resource
using the hares -refreshinfo command. See the hares manual page.
online
The online entry point typically contains the code to bring a resource online. For
example, the online entry point for an IP agent congures an IP address. When the
online procedure completes, the monitor entry point is automatically called by the
framework to verify that the resource is online.
The online entry point receives a resource name and ArgList attribute values as input.
It returns an integer indicating the number of seconds to wait for the online to take effect.
The typical return value is 0. If the return value is not zero, the agent framework
schedules the monitor to begin only after this time has elapsed.
ofine
The offline entry point is called to take a resource ofine. For example, the offline
entry point for an IP agent removes an IP address from the system. When the ofine
procedure completes, the monitor entry point is automatically called by the framework
to verify that the resource is ofine.
The offline entry point receives a resource name and ArgList attribute values as
input. It returns an integer indicating the number of seconds to wait for the ofine to take
effect. The typical return value is 0. If the return value is not zero, the agent framework
schedules the monitor to begin only after this time has elapsed.
clean
The clean entry point is called automatically by the agent framework when all ongoing
tasks associated with a resource must be terminated and the resource must be taken
ofine, perhaps forcibly. The entry point receives as input the resource name, an encoded
reason describing why the entry point is being called, and the ArgList attribute values.
It must return 0 if the operation is successful, and 1 if unsuccessful.
The reason for calling the entry point is encoded according to the following enum type:
enum VCSAgWhyClean {
VCSAgCleanOfflineHung,
VCSAgCleanOfflineIneffective,
VCSAgCleanOnlineHung,
VCSAgCleanOnlineIneffective,
VCSAgCleanUnexpectedOffline,
VCSAgCleanMonitorHung
};
VCSAgCleanOfineHung
The offline entry point did not complete within the expected time.
(See OfineTimeout on page 105.)
VCSAgCleanOfineIneffective
The offline entry point was ineffective.
VCSAgCleanOnlineHung
The online entry point did not complete within the expected time.
(See OnlineTimeout on page 105.)
VCSAgCleanOnlineIneffective
The online entry point was ineffective.
VCSAgCleanUnexpectedOfine
The online resource faulted because it was taken ofine unexpectedly.
VCSAgCleanMonitorHung
The online resource faulted because the monitor entry point consistently failed to
complete within the expected time.
(See FaultOnMonitorTimeouts on page 101.)
The agent supports the following tasks when the clean entry point is implemented:
Automatically restarts a resource on the local system when the resource faults. (See
the RestartLimit attribute for the resource type.)
Automatically retries the online entry point when the attempt to bring a resource
online fails. (See the OnlineRetryLimit attribute for the resource type.)
Enables the VCS engine to bring a resource online on another system when the
online entry point for the resource fails on the local system.
For the above actions to occur, the clean entry point must return 0.
action
The command hares with the -action option invokes the action entry point.
Administrators can issue the command to bring about a specic action with respect to a
specied resource on a given system within a given cluster. Actions are designated by a
the action_token argument. Typically, such actions are those that can be completed in a
short time and do not involve onlining or ofining the resource. The following shows the
syntax for the -action option used with the hares command:
hares -action res_name action_token [-actionargs arg1 arg2 ... ]
The actions specied by the action token correspond to actions dened in the static
attribute SupportedActions in the resource type denition le (see
SupportedActions on page 108). Such actions may include getting the name of a
database instance (in the case of a database-related agent, for example), putting a database
in the restricted mode, taking a database out of restricted mode, backing up a database,
and so on.
For a script-based implementation of the action entry point, a directory named actions
within /opt/VRTSvcs/bin/agent must contain scripts named for each action
indicated by the action token. For example, the RVG agent could have the scripts named:
demote, split_dg, and promote in directory /opt/VRTSvcs/bin/RVG/actions.
The agent framework invokes the script directly. (See action on page 64.)
For C++-based implementation of the action entry point, case statements correspond to
actions, one for each action_token. See action on page 44.
Return Values
The action entry point exits with a 0 if it is successful, or 1 if not successful. The
command hares -action exits with 0 if the action entry point exits with a 0 and 1 if
the action entry point is not successful.
ActionTimeout
The default value of the static resource type attribute, ActionTimeout, is 20 seconds.
This attribute can be overridden for specic resources. See ActionTimeout on page 98.
attr_changed
The attr_changed entry point is called when a resource attribute is modied, and only
if that resource is registered with the agent framework for notication. See the primitives
VCSAgRegister on page 54 and VCSAgUnregister on page 55 for details. To register
automatically, see RegList on page 108. This entry point receives as input the resource
name registered with the agent framework for notication, the name of the changed
resource, the name of the changed attribute, and the new attribute value. It does not
return a value. This entry point provides a way to respond to resource changes. Most
agents do not require this functionality and will not implement this entry point.
open
The open entry point is called when the VCS agent starts managing a resource; for
example, when the agent starts, or when the value of the Enabled attribute is changed
from 0 to 1. It receives a resource name and ArgList attribute values as input and returns
no value. This entry point typically initializes the resource.
Note A resource can be brought online, taken ofine, and monitored only if it is managed
by a VCS agent. The value of the resources Enabled attribute must be set to 1.
When a VCS agent is started, the open entry point of each resource is guaranteed to be
called before its online, offline, or monitor entry points are called. This allows you
to include initializations for specic resources. Most agents do not require this
functionality and will not implement this entry point.
close
The close entry point is called when the VCS agent stops managing a resource. For
example, it is called when the value of the Enabled attribute is changed from 1 to 0. It
receives a resource name and ArgList attribute values as input and returns no value.
This entry point typically deinitializes the resource if implemented. Most agents do not
require this functionality and will not implement this entry point.
Note A resource is monitored only if it is managed by a VCS agent. The value of the
resources Enabled attribute must be set to 1.
shutdown
The shutdown entry point is called before the VCS agent shuts down. It receives no input
and returns no value. Most agents do not require this functionality and will not
implement this entry point.
Online Integer specifying number of seconds to wait before monitor can check the state of
the resource; typically 0, i.e., check resource immediately.
Ofine Integer specifying number of seconds to wait before monitor can check the state of
the resource; typically 0, i.e., check resource immediately.
Attr_changed None
Open None
Close None
Shutdown None
</agent_description>
<platform>Solaris</platform>
<agenttype>Binary</agenttype>
<info_implemented>No</info_implemented>
<minvcsversion>4.0</minvcsversion>
<vendor>VERITAS</vendor>
<attributes>
displayname="PathName">
</attr_description>
</PathName>
</attributes>
<agentfiles>
</agentfiles>
</agent>
Agent Information
The information describing the agent is contained in the rst section of the XML le. The
following table describes this information, which is also contained in the previous le
example:
Agent name
name="FileOnOff"
Version
version="4.0"
Agent description
<agent_description>Creates, removes, and
monitors files.</agent_description>
Script or Mixed
Argument Description
type Possible values for attribute type, such as str for strings; see Attribute Data
Types on page 12
Argument Description
dimension Values for the attribute dimension, such as Scalar;" see Attribute
Dimensions on page 13 for more information on dimensions
persistent Possible Values = True. This argument should always be set to True; it is
reserved for future use.
range Denes the acceptable range of the attribute value. GUI or any other client can
use this value for attribute value validation.
Value Format: The range is specied in the form {a,b} or [a,b]. Square brackets
indicate that the adjacent value is included in the range. The curly brackets
indicate that the adjacent value is not included in the range. For example, {a,b]
indicates that the range is from a to b, contains b, and excludes a. In cases
where the range is greater than a and does not have an upper limit, it can be
represented as {a,] and, similarly, as {,b] when there is no minimum value.
displayname It is used by GUI or clients to show the attribute in user friendly manner. For
example, for FsckOpt its value could be fsck option.
Data Structures
// Values for the state of a resource - returned by the
enum VCSAgResState {
};
31
Data Structures
// is called.
enum VCSAgWhyClean {
// expected time.
// was ineffective.
// expected time.
// was ineffective.
// offline unexpectedly.
// expected time.
};
typedef struct {
void **attr_val);
void **attr_val);
char *action_output);
} VCSAgV40EntryPointStruct;
ArgList Attribute
The ArgList attribute is a predened static attribute that species the list of attributes
whose values are passed to the open, close, online, offline, action, info, and
monitor entry points. The values of the ArgList attributes are passed through a
parameter of type void **. For example, the signature of the online entry point is:
unsigned int
The parameter attr_val is an array of character pointers that contains the ArgList
attribute values. The last element of the array is a NULL pointer. Attribute values in
attr_val are listed in the same order as attributes in ArgList.
The values of scalar attributes (integer and string) are each contained in a single element
of attr_val. The values of non-scalar attributes (vector, keylist, and association) are
contained in one or more elements of attr_val. If a non-scalar attribute contains N
components, it will have N+1 elements in attr_val. The rst element is N, and the
remaining N elements correspond to the N components. SeeArgList on page 99 for more
information. See the chapter describing the VCS conguration language in the VERITAS
Cluster Server Users Guide for attribute denitions.
str Name
int IntAttr
str StringAttr
str VectorAttr[]
str AssocAttr{}
VectorAttr, AssocAttr }
IntAttr = 100
StringAttr = "Oracle"
// ArgList attribute.
attr_val[10]===> "512"
VCSAgStartup
void VCSAgStartup();
#include "VCSAgApi.h"
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
ep.open = NULL;
ep.close = NULL;
ep.monitor = res_monitor;
ep.online = res_online;
ep.offline = res_offline;
ep.action = NULL;
ep.info = NULL;
ep.attr_changed = NULL;
ep.clean = NULL;
ep.shutdown = NULL;
VCSAgRegisterEPStruct(V40, &ep);
...
void **attr_val) {
...
void **attr_val) {
...
monitor
VCSAgResState
*conf_level);
VCSAgResState
*conf_level)
if (res_state == VCSAgResOnline) {
*conf_level = ...
else {
*conf_level = 0;
return res_state;
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.monitor = res_monitor;
...
VCSAgRegisterEPStruct(V40, &ep);
info
unsigned int (*info) (const char *res_name,
***opt_add_args);
resinfo_op
The resinfo_op parameter indicates whether to initialize or update the data in the
ResourceInfo attribute. The values of this eld and their signicance are described in
the following table:
Value of Signicance
resinfo_op
info_output
The parameter info_output is a character string that stores the output of the info entry
point. The output value could be any summarized data for the resource. The Msg key in
the ResourceInfo attribute is updated with info_output. If the info entry point exits
with success (0), the output stored in info_output is dumped into the Msg key of the
ResourceInfo attribute.
The info entry point is responsible for allocating memory for info_output. The agent
framework handles the deletion of any memory allocated to this argument. Since memory
is allocated in the entry point and deleted in the agent framework, the entry point needs
to pass the address of the allocated memory to the agent framework.
opt_update_args
The opt_update_args parameter is an array of character strings that represents the
various name-value pairs in the ResourceInfo attribute. This argument is allocated
memory in the info entry point, but the memory allocated for it will be freed in the agent
framework. The ResourceInfo attribute is updated with these name-value pairs. The
names in this array must already be present in the ResourceInfo attribute.
For example:
ResourceInfo = { State = Valid, Msg = "Info entry point output",
opt_add_args
opt_add_args is an array of character strings that represent the various name-value
pairs to be added to the ResourceInfo attribute. The names in this array represent keys
that are not already present in the ResourceInfo association list and have to be added to
the attribute. This argument is allocated memory in the info entry point, but this
memory is freed in the agent framework. The ResourceInfo attribute is populated with
these name-value pairs.
For example:
ResourceInfo = { State = Valid, Msg = "Info entry point output",
"FileSize", "100" }
This array of name-value pairs adds to and initializes the static and dynamic data stored
in the ResourceInfo attribute.
An invalid opt_add_args array would be one that species a key that is already present
in the ResourceInfo attribute, or one that species any of the keys State, Msg, or TS;
these are keys that can be updated only by the agent framework, not by the entry point.
char ***opt_add_args) {
int i;
*output = out;
VCSAgSnprintf(out, 80,
attribute");
// Use the stat system call on the file to get its information
if (resinfo_op == VCSAgResInfoAdd) {
args[6] = NULL;
*opt_add_args = args;
else {
args[2] = NULL;
*opt_update_args = args;
else {
*attr_val);
return 1;
else {
VCSAgSnprintf(out, 80,
point");
return 1;
return 0;
online
unsigned int
unsigned int
...
// calling monitor.
return 0;
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.online = res_online;
...
VCSAgRegisterEPStruct(V40, &ep);
ofine
unsigned int
unsigned int
...
// calling monitor.
return 0;
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.offline = res_offline;
...
VCSAgRegisterEPStruct(V40, &ep);
clean
unsigned int
**attr_val);
unsigned int
void **attr_val) {
...
// return 1.
return 0;
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.clean = res_clean;
...
VCSAgRegisterEPStruct(V40, &ep);
action
unsigned int
//
//
//
//
if (!strcmp(token, "token1")) {
//
//
//
//
} else {
//
//
VCSAgSnprintf(ep_output, MAXBUFFER,
token);
//
//
//
// not:
// return 0 on success
//
if (success)
return 0;
else
return 1;
attr_changed
void
*changed_res_name,
void **new_val);
The parameter new_val contains the attributes new value. The encoding of new_val is
similar to the encoding of the ArgList Attribute on page 33.
You may select any name for the function.
The attr_changed eld of VCSAgV40EntryPointStruct passed to
VCSAgRegisterEPStruct() must be assigned a pointer to this function.
Note This entry point is called only if you register for change notication using the
primitive VCSAgRegister on page 54, or the agent parameter RegList (see
RegList on page 108).
For example:
#include "VCSAgApi.h"
void
void **new_val) {
// to be a string.
...
// assumed to be an integer.
...
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.attr_changed = res_attr_changed;
...
VCSAgRegisterEPStruct(V40, &ep);
open
void res_open(const char *res_name, void **attr_val);
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.open = res_open;
...
VCSAgRegisterEPStruct(V40, &ep);
close
void res_close(const char *res_name, void **attr_val);
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.close = res_close;
...
VCSAgRegisterEPStruct(V40, &ep);
shutdown
void res_shutdown();
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
...
ep.shutdown = res_shutdown;
...
VCSAgRegisterEPStruct(V40, &ep);
VCS Primitives
Primitives are C++ methods implemented by the VCS agent framework. Beginning with
the primitive VCSAgRegisterEPStruct() below, each VCS primitive is listed and
dened in the following sections.
VCSAgRegisterEPStruct
void VCSAgRegisterEPStruct (VCSAgAgentVersion version, void *
entry_points);
This primitive requests that the VCS agent framework use the entry point
implementations designated in entry_points. It must be called only from the
VCSAgStartup entry point.
For example:
// This example shows how to use VCSAgRegisterEPStruct()
#include "VCSAgApi.h"
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
ep.open = NULL;
ep.close = NULL;
ep.monitor = res_monitor;
ep.online = res_online;
ep.offline = res_offline;
ep.action = NULL;
ep.info = NULL;
ep.attr_changed = NULL;
ep.clean = NULL;
ep.shutdown = NULL;
VCSAgRegisterEPStruct(V40, &ep);
VCSAgSetCookie
void VCSAgSetCookie(const char *name, void *cookie);
This primitive requests that the VCS agent framework store a cookie. This value is
transparent to the VCS agent framework, and can be obtained later by calling the
primitive VCSAgGetCookie(). Note that a cookie is not stored permanently; it is lost
when the VCS agent process exits. This primitive can be called from any entry point.
For example:
#include "VCSAgApi.h"
...
//
// terminated.
//
//
// name.
//
void *get_key() {
...
if (VCSAgGetCookie(res_name) == NULL) {
VCSAgSetCookie(res_name, key);
*conf_level_ptr = 0;
if (key == NULL) {
key = get_key();
VCSAgSetCookie(res_name, key);
...
return state;
VCSAgRegister
void
This primitive requests that the VCS agent framework notify the resource
notify_res_name when the value of the attribute attr_name of the resource
res_name is modied. The notication is made by calling the attr_changed entry
point for notify_res_name. Note that notify_res_name can be the same as
res_name. This primitive can be called from any entry point, but it is useful only when
the attr_changed entry point is implemented.
For example:
#include "VCSAgApi.h"
...
"CriticalAttr");
VCSAgUnregister
void
This primitive requests that the VCS agent framework stop notifying the resource
notify_res_name when the value of the attribute attr_name of the resource
res_name is modied. This primitive can be called from any entry point.
For example:
#include "VCSAgApi.h"
...
attr_val[0], "CriticalAttr");
VCSAgGetCookie
void *VCSAgGetCookie(const char *name);
This primitive requests that the VCS agent framework get the cookie set by an earlier call
to VCSAgSetCookie(). It returns NULL if cookie was not previously set. This primitive
can be called from any entry point.
For example:
#include "VCSAgApi.h"
...
//
//
//
//
void *get_key() {
...
if (VCSAgGetCookie(res_name) == NULL) {
VCSAgSetCookie(res_name, key);
*conf_level_ptr = 0;
if (key == NULL) {
key = get_key();
VCSAgSetCookie(res_name, key);
...
return state;
VCSAgEncodeString
int VCSAgEncodeString(VCSAgEncodingType from_encoding,
VCSAgEncodingType to_encoding,
VCSAgStr /* OS encoding */
};
This primitive is used to encode a string from one encoding format to another. The
encoding formats are limited to UTF-8 and the default OS encoding formats for UNIX
agents.
This API allocates the required amount of memory for the output encoded string. The
caller is responsible for freeing this memory. The function stores a pointer to the encoded
string in the variable output_string and sets ouput_string_length to the number of
characters (ASCII or UCS-2) in this newly encoded string.
The return values of this primitive are 0 on success, 1 on failure.
This API is needed as part of the localization changes in the agent framework. The agent
entry points written in C++ receive the arguments in UTF-8 encoding format. If the entry
points need the localized values for these arguments, they must convert the arguments,
using the VCSAgEncodeString API, into the OS_encoding or the UCS-2 encoding
format.
Currently, the VCS engine does not accept localized values as input for arguments. Also,
any output captured from the script entry points run in a locale other than C are
converted into the UTF-8 encoding format by the agent framework and logged in the VCS
engine log, also in the UTF-8 encoding format. To view the output in the appropriate
locale, use the hamsg utility. Please refer to the VCS Users Guide for more on the hasmg
utility.
Example: VCSAgEncodeString
//
//
//
// VCSAgEncodeString.
//
len = strlen(utf8_string);
(void *)utf8_string,
len,
(void **)&out_string,
&out_string_len);
return out_string;
int *conf_level_ptr)
{ ...
...
//
//
*)attr_val[0]);
...
if (os_encoded_string) {
delete[] os_encoded_string;
os_encoded_string = NULL;
...
VCSAgStrlcpy
void VCSAgStrlcpy(CHAR *dst, const CHAR *src, int size)
This primitive copies the contents from the input buffer src to the output buffer dst
up to a maximum of size number of characters. Here, size refers to the size of the
output buffer dst. This helps prevent any buffer overow errors. The output contained
in the buffer dst may be truncated if the buffer is not big enough.
VCSAgStrlcat
void VCSAgStrlcat(CHAR *dst, const CHAR *src, int size)
This primitive concatenates the contents of the input buffer src to the contents of the
output buffer dst up to a maximum such that the total number of characters in the
buffer dst do not exceed the value of size. Here, size refers to the size of the output
buffer dst.
This helps prevent any buffer overow errors. The output contained in the buffer dst
may be truncated if the buffer is not big enough.
VCSAgSnprintf
int VCSAgSnprintf(CHAR *dst, int size, const char *format, ...)
This primitive accepts a variable number of arguments and works just like the C library
function sprintf. The difference is that this primitive takes in, as an argument, the size of
the output buffer dst. The primitive stores only a maximum of size number of
characters in the output buffer dst. This helps prevent any buffer overow errors. The
output contained in the buffer dst may be truncated if the buffer is not big enough.
61
ArgList Attributes
ArgList Attributes
The open, close, online, offline, monitor, action, info, and clean scripts
receive the resource name and values of the ArgList attributes. The values of scalar
ArgList attributes (integer and string) are each contained in a single command-line
argument. The values of complex ArgList attributes (vector and association) are
contained in one or more command-line arguments.
If a vector or association attribute contains N components, it is represented by N+1
command-line arguments. The rst command-line argument is N, and the remaining N
arguments correspond to the N components. (For more information, see ArgList on
page 99. See the chapter on the VCS conguration language in the VERITAS Cluster Server
Users Guide for attribute denitions.)
If Type Foo is defined in types.cf as:
Type Foo (
str Name
int IntAttr
str StringAttr
str VectorAttr[]
str AssocAttr{}
VectorAttr, AssocAttr }
IntAttr = 100
StringAttr = "Oracle"
monitor
monitor resource_name ArgList_attribute_values
A script entry point combines the status and the condence level in the exit value. For
example:
100 indicates ofine.
101 indicates online and condence level 10.
102109 indicates online and condence levels 2090.
110 indicates online and condence level 100.
If the exit value falls outside the range 100110, the status is considered unknown. For
example, if the exit value equals 99, the status of the resource is considered UNKNOWN.
online
online resource_name ArgList_attribute_values
The exit value is interpreted as the expected time (in seconds) for the online procedure to
be effective. The exit value is typically 0.
ofine
offline resource_name ArgList_attribute_values
The exit value is interpreted as the expected time (in seconds) for
0.
clean
clean resource_name ArgList_attribute_values
The variable clean_reason equals one of the following values:
0 - The offline entry point did not complete within the expected time. (See
OfineTimeout on page 105.)
1 - The offline entry point was ineffective.
2 - The online entry point did not complete within the expected time. (See
OnlineTimeout on page 105.)
3 - The online entry point was ineffective.
4 - The resource was taken ofine unexpectedly.
5 - The monitor entry point consistently failed to complete within the expected time.
(See FaultOnMonitorTimeouts on page 101.)
The exit value is 0 (successful) or 1.
action
action resource_name ArgList_attribute_values_AND_action_arguments
For example:
#!/bin/ksh
ResName = $1
ArgListattr1 - $2
ArgListattr2 = $3
ArgListattrn = $n+1
NumActionArgs - $n+2
Actionarg1 = $n+3
Actionarg2 = $n+4
attr_changed
attr_changed resource_name changed_resource_name
changed_attribute_name new_attribute_value
Note This entry point is called only if you register for change notication using the
primitive VCSAgRegister() (see VCSAgRegister on page 54), or the agent
parameter RegList (see RegList on page 108).
info
info resource_name resinfo_op ArgList_attribute_values
The attribute resinfo_op can be have the values 1 or 2.
Values of Signicance
resinfo_op
1 Add and initialize static and dynamic name-value data pairs in the
ResourceInfo attribute.
This entry point can add and update static and dynamic name-value pairs to the
ResourceInfo attribute. The info entry point has no specic output, but rather, it
updates the ResourceInfo attribute (see ResourceInfo on page 107).
ResName=$1;
ResInfo_op=$2;
PathName=$3;
LS="/usr/bin/ls";
HARES="/opt/VRTSvcs/bin/hares";
HAGRP="/opt/VRTSvcs/bin/hagrp";
ResourceInfo attribute";
if [ -z "$PathName" ]
then
exit 1;
else
res = echo $?
if [ $res -ne 0 ]
then
exit 1
fi
if [ $ResInfo_op -eq 1 ]
then
# ResourceInfo attribute
{ print $5 }
res=0
"$size"
res=echo $?
if [ $res -ne 0 ]
then
exit 1
fi
then
{ print $5 }
grep FileSize
res=0
then
"FileSize" "$size"
res=echo $?
if [ $res -ne 0 ]
then
exit 1
fi
fi
fi
exit 0
fi
open
open resource_name ArgList_attribute_values
The exit value is ignored.
close
close resource_name ArgList_attribute_values
The exit value is ignored.
shutdown
shutdown
This chapter describes the APIs and functions that developers can use within their agents
to generate log le messages that conform to a standard message logging format.
For information on creation and management of messages for internationalization,
see VCS Internationalized Message Catalogs on page 137.
For information on APIs used by VCS 3.5 and earlier, see How the VCS 4.0 Agent
Framework Works with VCS 2.0 and 3.5 Agents on page 145.
the attempt to create the file (/tmp/MyFile) failed with error (Is
a Directory)
The rst four elds of the message above is composed of the timestamp, an uppercase
mnemonic that represents the product (VCS, in this case), the severity, and the UMI (unique
message ID). The subsequent lines contain the message text.
69
Logging in C++ and Script-based Entry Points
Timestamp
The timestamp indicates when the message was generated. It is formatted according to
the locale.
Mnemonic
The mnemonic eld is used to indicate the product. The mnemonic, such as VCS, must
use all capital letters. All VCS bundled agents, enterprise agents, and custom agents use
the mnemonic: VCS.
Severity
The severity of each message is displayed in the third eld of the message (Critical, Error,
Warning, Notice, or Information for normal messages; 1-21 for debug messages). All C++
logging macros and script-based logging functions provide a means to dene the severity
of messages, both normal and debugging.
UMI
The UMI (unique message identier) includes an originator ID, a category ID, and a
message ID.
The originator ID is a decimal number preceded by a V- assigned by VERITAS.
The category ID is a number in the range of 0 to 65536 assigned by VERITAS. For each
custom agent, VERITAS must be contacted so that a unique category ID can be
registered for the agent.
For C++ messages, the category ID is dened in the VCSAgStartup entry point
(see Log Category on page 76).
For script-based entry points, the category is set within the VCSAG_SET_ENVS
function (see VCSAG_SET_ENVS on page 81).
For debug messages, the category ID, which is 50 by default, need not be dened
within logging functions.
Message IDs can range from 0 to 65536 for a category. Each normal message (that is,
non-debug message) generated by an agent must be assigned a message ID. For C++
entry points, the msgid is set as part of the VCSAG_LOG_MSG and
VCSAG_CONSOLE_LOG_MSG macros. For script-based entry points, the msgid is set
using the VCSAG_LOG_MSG function. The msgid eld is not used by debug
functions or required in debug messages.
Message Text
The message text is a formatted message string preceded by a dynamically generated
header consisting of three colon-separated elds. namely, <name of the
agent>:<resource>:<name of the entry point>:<message>. For example:
FileOnOff:MyFile:online:Resource could not be brought up because,
the attempt to create the file (/tmp/MyFile) failed with error (Is
a Directory)
The arguments of these APIs are described, briey described in the tables that, are
described in detail in the following paragraphs:
sev Severity of the message from the application. The values of sev are
macros VCS_CRITICAL, VCS_ERROR, VCS_WARNING, VCS_NOTICE,
and VCS INFORMATION; see Severity Arguments for C++ Macros on
page 74.
In the following example, both macros are used to log an error message to the agent log
and to the console:
.
dbgsev Debug severity of the message. The values of dbgsev are macros
ranging from VCS_DBG1 to VCS_DBG21; see Severity Arguments for
C++ Macros on page 74.
For example:
VCSAG_RES_LOG_MSG(VCS_DBG4, VCS_DEFAULT_FLAGS, "PathName is (%s)",
(CHAR *)(*attr_val));
For the example shown, the specied message is logged to the agent log if the specic
resource has been enabled (that is, the LogDbg attribute is set) for logging of debug
messages at the severity level DBG4.
AG_CRITICAL,
AG_ERROR,
AG_WARNING,
AG_NOTICE,
AG_INFORMATION
};
enum VCSAgDbgSev {
DBG1,
DBG2,
DBG3,
DBG21,
AG_DBG_SEV_End
};
With the severity macros, agent developers need not specify the name of the function, the
le name, and the line number in each log call. The name of the function, however, must
be initialized by using the macro VCSAG_LOG_INIT. See Initializing function_name
Using VCSAG_LOG_INIT on page 75.
VCSAG_LOG_INIT(file_offline);
Note If the function name is not initialized with the VCSAG_LOG_INIT macro, when the
agent is compiled, errors indicate that the name of the function is not dened.
See the Examples of Logging APIs Used in a C++ Agent on page 77 for more examples
of the VCSAG_LOG_INIT macro.
Log Category
The log category for the agent is dened using the primitive VCSAgSetLogCategory
(cat_ID) within the VCSAgStartup entry point.The log category is set to 2001 in the
following example:
VCSEXPORT void VCSDECL VCSAgStartup()
VCSAG_LOG_INIT("VCSAgStartup");
VCSAgV40EntryPointStruct ep;
ep.open
= NULL;
ep.close
= NULL;
ep.monitor
= file_monitor;
ep.online
= file_online;
ep.offline
= file_offline;
ep.clean
= file_clean;
ep.attr_changed
= NULL;
ep.shutdown
= NULL;
ep.action
= NULL;
ep.info
= NULL;
VCSAgSetLogCategory(2001);
%s", s);
VCSAgRegisterEPStruct(V40, &ep);
The log category for debug messages is by default 50, and does not need to be set.
#include <locale.h>
#include "VCSAgApi.h"
**new_val)
/*
*/
VCSAG_LOG_INIT("file_attr_changed");
**attr_val)
VCSAG_LOG_INIT("file_clean");
return 1; // Failure
VCSAG_LOG_INIT("file_close");
//
//
*conf_level)
VCSAG_LOG_INIT("file_monitor");
*conf_level = 0;
/*
* logged only for that resource that has the dbg level
* VCS_DBG4 enabled
*/
else {
state = VCSAgResOffline;
*conf_level = 0;
(%d)", (int)state);
return state;
int fd = -1;
VCSAG_LOG_INIT("file_online");
VCSAG_CONSOLE_LOG_MSG(VCS_WARNING, 3001,
VCS_DEFAULT_FLAGS,
return 0;
VCSAG_CONSOLE_LOG_MSG(VCS_ERROR, 3002,
VCS_DEFAULT_FLAGS,
return 0;
close(fd);
return 0;
VCSAG_LOG_INIT("file_offline");
VCSAG_CONSOLE_LOG_MSG(VCS_ERROR, 14002,
return 0;
VCSAG_LOG_INIT("file_open");
VCSAG_LOG_INIT("VCSAgStartup");
VCSAgV40EntryPointStruct ep;
ep.open = NULL;
ep.close = NULL;
ep.monitor = file_monitor;
ep.online = file_online;
ep.offline = file_offline;
ep.clean = file_clean;
ep.attr_changed = NULL;
ep.shutdown = NULL;
ep.action = NULL;
ep.info = NULL;
VCSAgSetLogCategory(2001);
%s", s);
VCSAgRegisterEPStruct(V40, &ep);
VCSAG_SET_ENVS
The VCSAG_SET_ENV function is used in each script-based entry point le. Its purpose is
to set and export environment variables that identify the agents category ID, the agents
name, the resources name, and the entry points name. With this information set up in the
form of environment variables, the logging functions can handle messages and their
arguments in the unied logging format without repetition within the scripts.
The VCSAG_SET_ENV function sets the following environment variables for a resource:
VCSAG_LOG_SCRIPT_NAME The absolute path to the entry point script. For example:
/opt/VRTSvcs/bin/Application/online
Since the entry points are invoked using their absolute
paths, this environment variable is set at invocation. The
script name variable is overridable.
Or,
VCSAG_SET_ENVS ${resource_name} ${category_id} ${script_name}
Or,
VCSAG_SET_ENVS ($resource_name, $category_id, $script_name);
VCSAG_LOG_MSG
The VCSAG_LOG_MSG function can be used to pass normal agent messages to the
halog utility. At a minimum, the function must include the severity, the message within
quotes, and a message ID. Optionally, the function can also include parameters and
specify an encoding format.
Message (msg) A text message within quotes; for example: One le copied
"<param1>"
"$count"
Note that if encoding format and parameters are passed to the functions, the encoding
format must be passed before any parameters.
"<param1>");
"$count");
Note that if encoding format and parameters are passed to the functions, the encoding
format must be passed before any parameters.
VCSAG_LOGDBG_MSG
This function can be used to pass debug messages to the halog utility. At a minimum, the
severity must be indicated along with a message. Optionally, the encoding format and
parameters may be specied.
utf8", "$count");
ResName=$1
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
#is 10061
"$ResName"
exit 0
The VRTSvcs package installed by the VCS installation program includes the following
les to facilitate agent development. Note that custom agents are not supported by
VERITAS Technical Support.
Script Agents
Description Pathname
implementation of the
C++ Agents
Description Pathname
87
Compiling is not required if all entry points are implemented using scripts. A copy of
ScriptAgent is sufcient.
Compiling is required to build the agent if any entry points are implemented using C++.
We recommend the following procedures for developers implementing entry points using
C++:
2. After completing the changes to agent.C, invoke the make command to build the
agent. The command is invoked from $VCS_HOME/src/agent/Sample, where the
Makele is located.
Additional Recommendations
We also recommend naming the agent binary resource_typeAgent. Place the agent in
the directory $VCS_HOME/bin/resource_type.
The agent binary for Oracle would be $VCS_HOME/bin/Oracle/OracleAgent, for
example. If the agent le is different, for example /foo/ora_agent, the types.cf le
must contain the following entry:
...
Type Oracle (
...
...
If entry points are implemented using scripts, the script le must be placed in the
directory $VCS_HOME/bin/resource_type. It must be named correctly (if necessary,
review Script Agents on page 16).
If all entry points are scripts, all scripts should be in the directory
$VCS_HOME/bin/resource_type. Copy the ScriptAgent into the agent directory as
$VCS_HOME/bin/resource_type/resource_typeAgent.
type MyFile (
str PathName;
include MyFileTypes.cf
MyFile MyFileRes (
PathName = "/tmp/VRTSvcs_file1"
Enabled = 1
The resource name and ArgList attribute values are passed to the script entry points as
command-line arguments. For example, in the preceding conguration, script entry
points receive the resource name as the rst argument, and PathName as the second.
/opt/VRTSvcs/bin/MyFile/MyFileAgent
/opt/VRTSvcs/bin/MyFile/MyFileAgent
3. Implement the online, offline, and monitor entry points using scripts.
touch $2
rm $2
if test -f $2
fi
4. Additionally, you can implement the info and action entry points. For the action
entry point, create a subdirectory named actions under the agent directory, and
create scripts with the same names as the action_tokens within the subdirectory.
/opt/VRTSvcs/src/agent/MyFile
4. Edit the le agent.C and modify the VCSAgStartup() function (the last several
lines) to match the following example:
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
// using C++.
ep.open = NULL;
ep.close = NULL;
ep.monitor = NULL;
ep.online = NULL;
ep.offline = NULL;
ep.action = NULL;
ep.info = NULL;
ep.attr_changed = NULL;
ep.clean = NULL;
ep.shutdown = NULL;
VCSAgRegisterEPStruct(V40, &ep);
5. Compile agent.C and build the agent by invoking make. (Makefile is provided.)
# make
8. Implement the online, offline, and monitor entry points, as instructed in step 3
on page 90.
/opt/VRTSvcs/src/agent/MyFile
4. Edit the le agent.C and modify the VCSAgStartup()function (the last several
lines) to match the following example:
void VCSAgStartup() {
VCSAgV40EntryPointStruct ep;
ep.open = NULL;
ep.close = NULL;
ep.monitor = res_monitor;
ep.online = NULL;
ep.offline = NULL;
ep.action = NULL;
ep.info = NULL;
ep.attr_changed = NULL;
ep.clean = NULL;
ep.shutdown = NULL;
VCSAgRegisterEPStruct(V40, &ep);
**attr_val,int *conf_level) {
*conf_level = 0;
if (attr_val) {
if (stat(path_name, &stat_buf) == 0) {
state = VCSAgResOnline;
*conf_level = 100;
else {
state = VCSAgResOffline;
*conf_level = 0;
return state;
6. Compile agent.C and build the agent by invoking make. (Makefile is provided.)
# make
9. Implement the online, offline, action, and info entry points, as instructed in
step 3 on page 90.
VCSAgV40EntryPointStruct ep;
ep.open = NULL;
ep.close = NULL;
ep.monitor = res_monitor;
ep.online = res_online;
ep.offline = res_offline;
ep.action = res_action;
ep.info = res_info;
ep.attr_changed = NULL;
ep.clean = NULL;
ep.shutdown = NULL;
VCSAgSetLogCategory(2001);
VCSAgRegisterEPStruct(V40, &ep);
// ArgList attribute.
unsigned int
VCSAG_LOG_INIT(res_online);
if (attr_val) {
if (fd < 0) {
// the console.
else {
close(fd);
// was successful.
return 0;
// ArgList attribute.
unsigned int
VCSAG_LOG_INIT("res_offline");
if (attr_val) {
attr_val[0];
remove (path_name);
// was successful.
return 0;
4. Compile agent.C and build the agent by invoking make. (Makefile is provided.)
# make
The VCS agents can be customized for a resource type by setting the values of the agent
attributes. Agent attributes are predened static attributes of the resource type. They can
be assigned values when dening the resource type in types.cf, and they can be set
dynamically using the command hatype -modify (described in the VERITAS Cluster
Server Users Guide).
Note VCS allows you to specify priorities and scheduling classes for VCS processes. For
details on the additional attributes included with this feature, and for instructions
on initializing them in the types.cf le or setting them from the command line,
see Scheduling Class and Priority Conguration Support on page 109.
97
Agent Attribute Definitions
ActionTimeout
After the hares -action command has instructed the agent to perform a specied
action, the action entry point has the time specied by the ActionTimeout attribute
(scalar-integer) to perform the action. The value of ActionTimeout may be set for
individual resources. The default is 40 seconds. The ActionTimeout attribute value can
be overridden.
AgentFile
The default name of the agent le to be executed is:
$VCS_HOME/bin/resource_type/resource_typeAgent.
The AgentFile attribute value cannot be overridden.
AgentReplyTimeout
The engine restarts the agent if it has not received the periodic heartbeat from the agent
for the number of seconds specied by this attribute. The default value of 130 seconds
works well for most congurations. Increase this value if the engine is restarting the
agent. This may occur when the system is heavily loaded or if the number of resources
exceeds three or four hundred. (See the command haagent -display in the chapter on
administering VCS from the command line in the VERITAS Cluster Server Users Guide.)
Note that the engine will also restart a crashed agent. The AgentReplyTimeout attribute
value cannot be overridden.
AgentStartTimeout
After the engine has started the agent, this is the amount of time the engine waits for the
initial agent handshake before attempting to restart. Default is 60 seconds. The
AgentStartTimeout attribute value cannot be overridden.
ArgList
An ordered list of attributes whose values are passed to the open, close, online,
offline, monitor, and clean entry points. Default is empty list. The ArgList
attribute value cannot be overridden.
AttrChangedTimeout
Maximum time (in seconds) within which the attr_changed entry point must complete
or else be terminated. Default is 60 seconds. The AttrChangedTimeout attribute value
can be overridden.
CleanTimeout
Maximum time (in seconds) within which the clean entry point must complete or else be
terminated. Default is 60 seconds. The CleanTimeout attribute value can be overridden.
CloseTimeout
Maximum time (in seconds) within which the close entry point must complete or else be
terminated. Default is 60 seconds.The CloseTimeout attribute value can be overridden.
ComputeStats
An attribute that indicates whether or not VCS is to keep track of monitor statistics for a
given resource. A value of 1 indicates VCS is to keep track of the monitor time for the
resource. A value of 0 indicates that VCS is not keep track of monitor statistics for a
resource. See MonitorStatsParam on page 104.
The default is 0.
ConfInterval
Species an interval in seconds. When a resource has remained online for the designated
interval (all monitor invocations during the interval reported ONLINE), any earlier faults
or restart attempts of that resource are ignored. This attribute is used with ToleranceLimit
to allow the monitor entry point to report OFFLINE several times before the resource is
declared FAULTED. If monitor reports OFFLINE more often than the number set in
ToleranceLimit, the resource is declared FAULTED. However, if the resource remains online
for the interval designated in ConfInterval, any earlier reports of OFFLINE are not counted
against ToleranceLimit.
The agent framework uses the values of MonitorInterval (MI), MonitorTimeout (MT), and
ToleranceLimit (TL) to determine how low to set the value of ConfInterval. The agent
framework ensures that ConfInterval (CI) cannot be less than that expressed by the
following relationship:
(MI + MT) * TL + MI + 10
Lesser specied values of ConfInterval are ignored. For example, assume that the values
are 60 for MI, 60 for MT, and 0 for TL. If you specify any value lower than 70 for CI, the
agent framework ignores the specied value and sets the value to 70. However, you can
successfully specify and set CI to any value over 70.
ConfInterval is also used with RestartLimit to prevent VCS from restarting the resource
indenitely. VCS attempts to restart the resource on the same system according to the
number set in RestartLimit within ConfInterval before giving up and failing over.
However, if the resource remains online for the interval designated in ConfInterval, earlier
attempts to restart are not counted against RestartLimit. Default is 600 seconds. The
ConfInterval attribute value can be overridden.
FaultOnMonitorTimeouts
Indicates the number of consecutive monitor failures to be treated as a resource fault.
A monitor attempt is considered a failure if it does not complete within the time specied
by the MonitorTimeout attribute. When a monitor fails as many times as the value
specied by this attribute, the corresponding resource is brought down by calling the
clean entry point. The resource is then marked FAULTED, or it is restarted, depending on
overridden.
Note This attribute applies only to online resources. If a resource is ofine, no special
action is taken during monitor failures.
FireDrill
A re drill refers to the process of bringing up a database or application on a secondary
or standby system for the purpose of doing some processing on the secondary data, or to
verify that the application is capable of onlining on the secondary in case of a primary
fault. The FireDrill attribute species whether a resource type has re drill enabled or
not. A value of 1 for the FireDrill attribute indicates a re drill is enabled. A value of 0
indicates a re drill is not enabled. The default is 0.
Refer to the VERITAS Cluster Server Users Guide for details of how to set up and
implement a re drill.
The FireDrill attribute cannot be overridden.
InfoInterval
Species the interval, in seconds, between successive invocations of the info entry point
for a given resource. The default value of the InfoInterval attribute is 0, which
species that the agent framework is not to schedule the info entry point periodically;
the entry point can be invoked, however, by the user from the command line. The
InfoInterval attribute value can be overridden.
InfoTimeout
A scalar integer specifying the time the agent framework is to allow for completion of the
info entry point. The InfoTimeout attribute value can be overridden. The default is 30
seconds.
LogDbg
LogDbg is a resource type-level attribute that species which debug messages are to be
logged to the agent log. The LogDbg attribute applies only for those agent entry points
written in C++.
By default, LogDbg is an empty list, meaning that no debug messages are logged for a
resource type. Users can modify this attribute for a given resource type, specifying that
debug messages of specic severities be printed to the agent log.
For example, if you want to log debug messages for the FileOnOff resource type with
severity levels DBG_3 and DBG_4, use the hatype command:
# hatype -modify FileOnOff LogDbg -add DBG_3 DBG_4
The FileOnOff agent entry points can now log debug messages with severity DBG_3 and
DBG_4. They are printed to the agent log le. An example line in the agent log would now
resemble:
.
is a debug message
FileOnOff.C:file_monitor[28]
LogDbg is an overrideable attribute. For example, for a specic critical resource, the
attribute value can be set to obtain debug messages of particular severity level in addition
to those severity levels already set for the resource type. From the command line, this can
be done using the hares command. For example:
# hares -override f1 LogDbg
The FileOnOff agent log would now include debug messages for the f1 resource at
severity level DBG_5 in addition to debug messages at the severity levels DBG_3 and
DBG_4 enabled for the resource type.
The LogDbg attribute value can be overridden.
Note Values of LogDbg overridden for a resource are effective only if the agent uses the
macro VCSAG_RES_LOG_MSG, which is the only macro that checks if a particular
debug severity is enabled for the resource before writing the message to the log le.
Please refer to Logging Agent Messages on page 69 for more information.
LogFileSize
Sets the size of an agent log le. Value must be specied in bytes. Minimum is 65536 bytes
(64KB). Maximum is 134217728 bytes (128MB). Default is 33554432 bytes (32MB). For
example,
# hatype -modify FileOnOff LogSize 2097152
Values specied less than the minimum acceptable value will be changed 65536 bytes.
Values specied greater than the maximum acceptable value will be changed to 134217728
bytes. Therefore, out-of-range values displayed for the command:
# hatype -display restype -attribute LogSize
will be those entered with the -modify option, not the actual values. The LogFileSize
attribute value cannot be overridden.
ManageFaults
A service group level attribute. ManageFaults species if VCS manages resource
failures within the service group by calling clean entry point for the resources. This
attribute value can be set to ALL or NONE. Default = ALL.
If set to NONE, VCS does not call clean entry point for any resource in the group. User
intervention is required to handle resource faults/failures. When ManageFaults is set to
NONE and one of the following events occur, the resource enters the ADMIN_WAIT state:
1 - The offline entry point did not complete within the expected time. Resource
state is ONLINE|ADMIN_WAIT
2 - The offline entry point was ineffective. Resource state is
ONLINE|ADMIN_WAIT
3 - The online entry point did not complete within the expected time. Resource state
is OFFLINE|ADMIN_WAIT
4 - The online entry point was ineffective. Resource state is
OFFLINE|ADMIN_WAIT
5 - The resource was taken ofine unexpectedly. Resource state is
OFFLINE|ADMIN_WAIT
6 - For the online resource the monitor entry point consistently failed to complete
within the expected time. Resource state is ONLINE| MONITOR_
TIMEDOUT|ADMIN_WAIT
MonitorInterval
Duration (in seconds) between two consecutive monitor calls for an ONLINE or
transitioning resource. Default is 60 seconds. The MonitorInterval attribute value can
be overridden.
MonitorStatsParam
Refer to the VERITAS Cluster Server Users Guide for details about the
MonitorStatsParam attribute, and the MonitorTimeStats attribute that is updated
by VCS. See also ComputeStats on page 100.
MonitorStatsParam is a resource type-level attribute, which stores the required
parameter values for calculating monitor time statistics.
static str MonitorStatsParam = { Frequency = 10, ExpectedValue =
Frequency: Denes the number of monitor cycles after which the average monitor
cycle time should be computed and sent to the engine. The value for this attribute is
must be between 1 and 30 and is set to 0 by default.
ExpectedValue: The expected monitor time in milliseconds for all resources of this type.
Default=3000.
ValueThreshold: The acceptable percentage difference between the expected monitor
cycle time (ExpectedValue) and the actual monitor cycle time. Default=100.
AvgThreshold: The acceptable percentage difference between the benchmark average
and the moving average of monitor cycle times. Default=40.
The MonitorStatsParam attribute values can be overridden.
MonitorTimeout
Maximum time (in seconds) within which the monitor entry point must complete or else
be terminated. Default is 60 seconds. The MonitorTimeout attribute value can be
overridden.
The determination of the value of the MonitorTimeout attribute can be assisted by the
use of the MonitorStatsParam attribute.
NumThreads
Number of threads used within the agent process for managing resources. This number
does not include the three threads used for other internal purposes. Default is 10 threads.
The NumThreads attribute value cannot be overridden.
OfineMonitorInterval
Duration (in seconds) between two consecutive monitor calls for an OFFLINE resource. If
set to 0, OFFLINE resources are not monitored. Default is 300 seconds. The
OfflineMonitorInterval attribute value can be overridden.
Note In previous releases, agents monitored ofine resources once every minute by
default. To reduce monitoring overhead, this frequency was changed to once every
ve minutes. This interval may be adjusted to meet specic conguration
requirements.
OfineTimeout
Maximum time (in seconds) within which the offline entry point must complete or else
be terminated. Default is 300 seconds. The OfflineTimeout attribute value can be
overridden.
OnlineRetryLimit
Number of times to retry online, if the attempt to online a resource is unsuccessful. This
attribute is meaningful only if clean is implemented. Default is 0. The
OnlineRetryLimit attribute value can be overridden.
OnlineTimeout
Maximum time (in seconds) within which the online entry point must complete or else
be terminated. Default is 300 seconds. The OnlineTimeout attribute value can be
overridden.
OnlineWaitLimit
Number of monitor intervals to wait after completing the online procedure, and before the
resource becomes online. If the resource is not brought online after the designated monitor
intervals, the online attempt is considered ineffective. This attribute is meaningful only if
the clean entry point is implemented.
If clean is not implemented, the agent continues to periodically run monitor until the
resource comes online.
If clean is implemented, when the agent reaches the maximum number of monitor
intervals it assumes that the online procedure was ineffective and runs clean. The agent
then noties the engine that the online failed, or retries the procedure, depending on
whether or not the OnlineRetryLimit is reached. Default is 2. The OnlineWaitLimit
attribute value can be overridden.
OpenTimeout
Maximum time (in seconds) within which the open entry point must complete or else be
terminated. Default is 60 seconds. The OpenTimeout attribute value can be overridden.
Operations
Indicates the valid operations of resources of the resource type. The values are OnOff (can
be onlined and ofined), OnOnly (can be onlined only), and None (cannot be onlined or
ofined). Default is OnOff. The Operations attribute value cannot be overridden.
ResourceInfo
The ResourceInfo (association-string) is a temporary attribute, the scope of which is set
by the engine to be global for failover groups or local for parallel groups. Because
ResourceInfo is a temporary attribute, its values are never dumped to the main.cf
le.
The values of the ResourceInfo attribute are expressed in three mandatory keys:
State, Msg, and TS.For State, the possible values are Valid, (the default),
Invalid, and Stale). Msg (default is , a null string) contains the output from the entry
point. TS contains the time at which the attribute is has been updated or modied. These
mandatory keys are updated only by the agent framework, not the entry point. The entry
point can dene and add other keys (name-value pairs) and update them.
The value of the ResourceInfo attribute can be displayed using the hares command.
The output of hares -display shows the rst 20 characters of the current value; the
output of hares -value resource ResourceInfo shows all name-value pairs in the
keylist.
The resource for which the info entry point is invoked must be online. When a resource
goes ofine or faults, the State key is marked Stale because the information is not
current. If the info entry point exits abnormally, the State key is marked Invalid
because not all of the information is known to be valid. The other key data, including Msg
and TS keys, are not touched. The values of the ResourceInfo attribute can be manually
cleared using the hares -flushinfo command. This command deletes any optional
keys for the ResourceInfo attribute and sets the three mandatory keys to their default
values.
See the hares manual page.
RestartLimit
Affects how the agent responds to a resource fault (seeFaultOnMonitorTimeouts on
page 101 and ToleranceLimit on page 108). A non-zero RestartLimit causes VCS to
invoke the online entry point instead of failing over the service group to another system.
VCS attempts to restart the resource according to the number set in RestartLimit before it
gives up and fails over. However, if the resource remains online for the interval
designated in ConfInterval, earlier attempts to restart are not counted against
RestartLimit. Default is 0. The RestartLimit attribute value can be overridden.
Note The agent will not restart a faulted resource if the clean entry point is not
implemented. Therefore, the value of the RestartLimit attribute applies only if
clean is implemented.
RegList
Keylist of attribute names. All resources are automatically registered for change
notication for specied attributes. Default is empty list. The RegList attribute value
cannot be overridden.
SupportedActions
The SupportedActions (string-keylist) attribute lists all possible actions dened for an
agent, including those dened by the agent developer. The engine validates the
action_token value specied in the hares -action resource action_token
command against the SupportedActions attribute. It is the responsibility of the agent
developer to initialize the SupportedActions attribute in the resource type denition and
update the denition for each new action added to the action entry point code or script.
See action on page 25. This attribute serves as a reference for users of the command line
or the graphical user interface.
An example denition of a resource type may resemble:
Type DBResource (
ShutOpt }
str Sid
str Owner
str Home
str User
str Pword
str StartOpt
str ShutOpt
ToleranceLimit
A non-zero ToleranceLimit allows the monitor entry point to return OFFLINE several
times before the ONLINE resource is declared FAULTED. If the monitor entry point reports
OFFLINE more times than the number set in ToleranceLimit, the resource is declared
FAULTED. However, if the resource remains online for the interval designated in
ConfInterval, any earlier reports of OFFLINE are not counted against ToleranceLimit.
Default is 0. The ToleranceLimit attribute value can be overridden.
Priority Ranges
The following table displays the platform-specic priority range for RealTime,
TimeSharing, and SRM scheduling (SHR) processes.
Agent TS 60 N/A 0
Script TS 60 N/A 0
AgentClass
Indicates the scheduling class for the VCS agent process. TS is default.
AgentPriority
Indicates the priority in which the agent process runs. 0 is default.
ScriptClass
Indicates the scheduling class of the script processes (for example, online) created by the
agent. TS is default.
ScriptPriority
Indicates the priority of the script processes created by the agent. 0 is default.
str PathName
Type:
hatype -modify resource_type AgentClass value
For example, to set the AgentClass attribute of the FileOnOff resource to Realtime, type:
hatype -modify FileOnOff AgentClass "RT"
Type:
hatype -modify resource_type AgentPriority value
For example, to set the AgentPriority attribute of the FileOnOff resource to 10, type:
hatype -modify FileOnOff AgentPriority "10"
Type:
hatype -modify resource_type ScriptClass value
For example, to set the ScriptClass of the FileOnOff resource to RealTime, type:
hatype -modify FileOnOff ScriptClass "RT"
For example, to set the ScriptClass of the FileOnOff resource to RealTime, type:
hatype -modify FileOnOff ScriptPriority "40"
Note: For the attributes AgentClass and AgentPriority, changes are effective immediately.
For ScriptClass and ScriptPriority, changes become effective for scripts issued after the
execution of the hatype command.
115
Using the VCS Engine Process
Oracle AgentFile
Oracle Faults 0
Test Commands
The following examples show how VCS commands can be used to test the agent:
To activate agent debug messages for C++ agents, type:
hatype -modify resource_type LogDbg -add DBG-AGINFO
Output resembles:
The following commands are supported.(Use help for more
addattr
addres
addstaticattr
addtype
debughash
debugmemory
debugtime
delete
deleteres
modifyres
modifytype
offlineres
onlineres
proberes
quit
startagent
stopagent
2. The following are examples of type.cf and main.cf conguration les that can be
referred to when testing the FileOnOff agent:
Example types.cf denition for the FileOnOff agent:
type FileOnOff (
str PathName
group ga (
...
FileOnOff file1 (
Enabled = 1
PathName = "/tmp/VRTSvcsfile001"
3. Complete step a through step f to pass this sample conguration to the VCS agent.
a. Add a type:
>addtype FileOnOff FileOnOff
vector PathName
d. Add the LogLevel attribute to see the debug messages from the
VCS agent:
>addstaticattr FileOnOff FileOnOff LogLevel str info
e. Add a resource:
>addres FileOnOff file1 FileOnOff
/tmp/VRTSvcsfile001
4. After adding and modifying resources, type the following command to obtain the
status of a resource:
>proberes FileOnOff file1
You will receive the following messages indicating the resource status:
Resource(file1) is OFFLINE
This calls the online entry point of the FileOnOff agent. The following message
is displayed when file1 is brought online:
Resource(file1) is ONLINE
This calls the offline entry point of the FileOnOff agent. A status message
similar to the example in step a is displayed when file1 is taken ofine.
FileOnOff
This chapter illustrates the state transitions within the agent framework. State transition
diagrams are shown separately for the following behaviors:
Opening a resource
Resource in a steady state
Onlining a resource
Ofining a resource
Resource fault (without automatic restart)
Resource fault (with automatic restart)
Monitoring of persistent resources
Closing a resource
In addition, state transitions are shown for the handling of resources with respect to the
ManageFaults service group attribute. By default, ManageFaults is set to NONE, in
which case the clean entry point is not called by VCS. See ManageFaults on
page 103.The diagrams cover the following conditions:
Onlining a resource when the ManageFaults attribute is set to NONE
Ofining a resource when the ManageFaults attribute is set to NONE
Resource fault when ManageFaults attribute is set to ALL
Resource fault (unexpected offline) when ManageFaults attribute is set to NONE
Resource fault (monitor is hung) when ManageFaults attribute is set to ALL
Resource fault (monitor is hung) when ManageFaults attribute is set to NONE
The states shown in these diagrams are associated with each resource by the agent
framework. These states are used only within the agent framework and are independent
of the IState resource attribute values indicated by the engine.
The VCS agent writes resource state transition information into the agent log le when the
LogDbg parameter, a static resource type attribute, is set to the value DBG_AGINFO. Agent
developers can make use of this information when debugging agents.
121
Opening a resource
timed out or
enabled=1 unknown status Online
monitor
status Ofine
Detached Monitoring Ofine
PM - Periodic Monitoring
When the agent starts up, each resource starts with the initial state of Detached. In the
Detached state (Enabled=0), the agent rejects all commands to online or ofine the
resource.
When the resource is enabled (Enabled=1), the open entry point is invoked. Periodic
Monitoring begins after open times out or succeeds. Depending on the return value of
monitor, the resource transitions to either the Online or the Ofine state. In the unlikely
event that monitor times out or returns unknown, the resource stays in a Probing state.
monitor
Ofine Monitoring
status Ofine (Ofine)
status Online
monitor
Monitoring
Online
(Online) status Online
When resources are in a steady state of Online or Ofine, they are monitored at regular
intervals. The intervals are specied by the MonitorInterval parameter for a resource
in the Online state and the OfflineMonitorInterval parameter for a resource in the
Ofine state. An Online resource that is unexpectedly detected as Ofine is considered to
be faulted. Refer to diagrams describing faulted resources.
When the agent receives a request from the VCS engine to online the resource, the
resource enters the Going Online state, where the online entry point is invoked. If
online completes successfully, the resource enters the Going Online Waiting state where
it waits for the next monitor cycle.
If monitor returns a status of online, the resource moves to the Online state.
If, however, the monitor times out, or returns a status of not Online (that is, unknown
or ofine), the agent returns the resource to the Going Online Waiting state and waits for
the next monitor cycle.
When the OnlineWaitLimit is reached, the clean entry point is invoked.
If clean times out or fails, the resource again returns to the Going Online Waiting
state and waits for the next monitor cycle. The agent again invokes the clean entry
point if the monitor reports a status of not Online.
If clean succeeds with the OnlineRetryLimit reached, and the subsequent
monitor reports ofine status, the resource transitions to the ofine state and is
marked FAULTED.
If clean succeeds and the ORL is not reached, the resource transitions to the Going
Online state where the online entry point is retried.
ofine / success /
cleaned = true status not ofine
stop PM
start PM And cleaned is
false
Online Ofine
done /
start PM timed out Or
cleaned is false /
start PM
status Ofine
Going monitor
Ofine Monitoring
Waiting timed out Or
status not Ofine
And cleaned is true /
UNABLE_TO_OFFLINE ag set,
start PM
PM - Periodic Monitoring
Upon receiving a request from the VCS engine to ofine a resource, the agent places the
resource in a Going Ofine state and invokes the offline entry point.
If offline succeeds, the resource enters the Going Ofine Waiting state where it waits
for the next monitor.
If monitor returns a status of ofine, the resource is marked Ofine.
If the monitor times out or return a status not ofine, the agent invokes the clean entry
point. Also, if, in the Going Ofine state, the offline entry point times out, the agent
invokes clean entry point.
If clean fails or times out, the resource is placed in the Going Ofine Waiting state
and monitored. If monitor reports not ofine, the agent invokes the clean entry
point, where the sequence of events repeats.
If clean returns success, the resource is placed in the Going Ofine Waiting state and
monitored. If monitor times out or reports not ofine, the resource returns to the
GoingOfineWaiting state. The UNABLE _TO_OFFLINE ag is sent to engine.
status Ofine
And TL reached
monitor And RL reached
Online Monitoring timed out Cleaning
timed out And FMT And FMT reached
not reached, And RL reached
Or, status Ofine
and TL not reached,
Or, Clean succeeds, but clean
monitor returns Online succeeds /
start PM
monitor
Clean Clean
succeeds, succeeds,
monitor returns monitor times
Ofine / Start PM out or returns
unknown
Going
Ofine
Waiting
FMT - FaultOnMonitorTimeout
RL - RestartLimit Ofine
TL - ToleranceLimit
PM - Periodic Monitoring
This diagram describes the activity that occurs when a resource faults and the
RestartLimit is reached. When the monitor entry point times out successively and
FaultOnMonitorTimeout is reached, or monitor returns ofine and the
ToleranceLimit is reached, the agent invokes the clean entry point.
If clean fails, or if it times out, the agent places the resource in the Online state as if no
fault occurred.
If clean succeeds, the resource is placed in the Going Ofine Waiting state, where the
agent waits for the next monitor.
If monitor reports Online, the resource is placed back Online as if no fault occurred.
If monitor reports Ofine, the resource is placed in an Ofine state and marked as
FAULTED.
If monitor reports unknown or times out, the agent places the resource back into the
Going Ofine Waiting state, and sets the UNABLE_TO_OFFLINE ag in the engine.
Going Cleaning
Online success,
start Online
FMT - FaultOnMonitorTmeout
RC - RestartCount
RL - RestartLimit
TC - ToleranceCount
PM - Periodic Monitoring
TL - ToleranceLimit
This diagram describes the activity that occurs when a resource faults and the
RestartLimit is not reached. When the monitor entry point times out successively
and FaultOnMonitorTimeout is reached, or monitor returns ofine and the
ToleranceLimit is reached, the agent invokes the clean entry point.
If clean succeeds, the resource is placed in the Going Online state and the online
entry point is invoked to restart the resource; refer to the diagram, Onlining a
resource.
If clean fails or times out, the agent places the resource in the Online state as if no
fault occurred.
Refer to the diagram Resource fault without automatic restart, for a discussion of
activity when a resource faults and the RestartLimit is reached.
monitor
Monitoring Ofine
(Ofine) status Ofine
For a persistent resource in the Online state, if monitor returns a status of ofine and the
ToleranceLimit is not reached, the resource stays in an Online state. If monitor
returns ofine and the ToleranceLimit is reached, the resource is placed in an Ofine
state and noted as FAULTED. If monitor returns not ofine, the resource stays in an
Online state.
Likewise, for a persistent resource in an Ofine state, if monitor returns ofine, the
resource remains in an Ofine state. If monitor returns a status of online, the resource is
placed in an Online state.
Online
Ofine
When the resource is disabled (Enabled=0), the agent stops Periodic Monitoring and the
the close entry point is invoked. When the close entry point succeeds or times out, the
resource is placed in the Detached state.
Ofine
online /
stop PM
ONH - Online Hang
Going ONI - Online Ineffective
ORC - Online Retry Count
Online ORL - Online Retry Limit
OWC - Online Wait Count
OWL - Online Wait Limit
PM - Periodic Monitoring
timed out / done /
set ADMIN-WAIT; insert
start PM monitor;
clean reason = ONH start PM
status =
online
Monitoring Online
monitor
status = ofine
MSG_RES_ or unknown
CLRADMINWAIT_ or monitor timed out
FAULT / reset
ADMIN_WAIT;
ORC = ORL
Is
Going Online OWL
Waiting reached
NO /
start PM ?
YES /
reset OWC
MSG_RES_CLRADMINWAIT
or MSG_RES_RESET_MF /
reset ADMIN_WAIT;
ManageFaults = 1 Is
ORL
NO / set reached
ADMIN-WAIT; ?
clean reason =
ONI
YES
Is
status= Ofine
NO (status Ofine YES /
unknown or ? start PM
monitor timed out) /
start PM
Online Going
ofine / Ofine
stop PM
done /
insert monitor;
start PM
timed out /
set ADMIN_WAIT; status = ofine
clean reason = OFH
monitor
Monitoring
Ofine
status =
online or
unknown or
monitor
timed out
MSG_RES_CLRADMIN_WAIT
or MSG_RES_RESET_MF / NO / set
clear ADMIN_WAIT; ADMIN_WAIT;
insert monitor clean reason = Is
OFI
Going Ofine Ofine
Waiting cleaned
?
PM - Periodic Monitoring
Status = ofine
monitor start PM
Online Monitoring
Status = online /
start PM
Status = ofine
NO / increment Ofine
tolerance count Is TL
reached
?
status unknown
Cleaning or monitor timed out
clean timed out or failed /
Start PM
clean not
implemented
or persistent
resource /
Clean success / ofine_cleaned = 0
ofine_cleaned = 1; reset clean_count
increment restart count;
reset tolerance count
Going Ofine
Waiting
Is RL
reached
YES
?
NO /
call online;
set FSTATE_RESTARTING
Going Online
PM - Periodic Monitoring
RL - Restart Limit
See Onlining a resource with TL - Tolerance Limit
ManageFaults = ALL
MSG_RES_ Is TL
CLEARADMIN_WAIT or
MSG_RES_RESET_MF; reached
NO
reset ADMIN_WAIT; ?
insert monitor
status = online /
reset faulted; reset clean count;
reset ofine-cleaned;
start PM
Going Ofine
MSG_RES_CLEARADMINWAIT_FAULT / Waiting
/reset ADMIN_WAIT; faulted = 1;
insert monitor
PM - Periodic Monitoring
TL - Tolerance Limit
status = ofine /
start PM
Ofine
monitor monitor
Online Monitoring Going Ofine
status = online / status = unknown or
Waiting
reset consecutive monitor timed out / set
monitor timeout count UNABLE_TO_OFFLINE
status = unknown /
set MONITOR_UNKNOWN
monitor timed
out / set
MONITOR_TIMEDOUT
status = online
reset faulted;
reset clean count;
reset consecutive monitor
timeout count
Is
FOMT
NO / reached
increment consecutive ?
monitor timeout count
YES /
stop PM;
increment clean count;
call clean (MH);
faulted = 1 YES /
insert monitor /
start PM
clean success /
increment consecutive
monitor timeout count Is RL
Cleaning reached
clean failed or
timed out / ?
start PM
NO / call online;
set FSTATE_RESTARTING
MSG_RES_CLEARADMINWAIT or
MSG_RES_RESET_MF /
MSG_RES_CLRADMIN_WAIT_FAULT /
reset ADMIN_WAIT
reset ADMIN_WAIT;
ManageFaults = 1
faulted = 1
monitor monitor
Online Monitoring Going Ofine
status = online / status = unknown or
Waiting
reset consecutive monitor timed out / set
monitor timeout count UNABLE_TO_OFFLINE
status = unknown /
set MONITOR_UNKNOWN
status = online
reset faulted; status = ofine /
reset clean count; start PM
reset consecutive monitor Ofine
timeout count
monitor timed
out / set
MONITOR_TIMEDOUT
NO /
increment consecutive Is
monitor timeout count FOMT
reached
?
FOMT - Fault On Monitor Timeout
MH - Monitor Hung
YES / PM - Periodic Monitoring
set ADMIN_WAIT;
clean reason = MH
137
Creating SMC Files
SMC Format
#!language = language_ID
#!module = module_name
#!version = version
#!category = category_ID
# comment
message_ID1 {%s:msg}
message_ID2 {%s:msg}
message_ID3 {%s:msg}
# comment
message_ID4 {%s:msg}
message_ID5 {%s:msg}
...
#!module = HAD
#!version = 4.0
#!category = 203
# common library
The name of the SMC le used to generate the BMC le for the preceding example is
VRTSvcsHPOracle.smc.
Message Examples
An illegal message, with hard carriage returns embedded with the message:
201 {%s:To be or not to be!
In a language where the position of message arguments need to switch, the same entry in
the SMC le for that language might resemble:
301 {%s:Setting cookie for process with PID = %3$s, name = %2$s"}
VCS Languages
The languages supported by VCS are listed as subdirectories, such as /ja (Japanese) and
/en (English), in the directory /opt/VRTSvcs/messages.
2. Change to the directory containing the BMC le and run the bmcmap utility. For
example:
# cd /opt/VRTSvcs/messages/en
The bmcmap utility scans the contents of the directory and dynamically generates the
BMC map. In this case, HAD.bmcmap is created.
Language=en
# VCS
VRTSvcsHad.version=1.0
VRTSvcsHad.IDstart=0
VRTSvcsHad.IDend=16501
VRTSvcsHad.Category=__________
# HP Bundled Agents
VRTSvcsHPAgent.version=1.0
VRTSvcsHPAgent.IDstart=100001
VRTSvcsHPAgent.IDend=113501
VRTSvcsHPAgent.Category=__________
# HP NewCustomAgent
VRTSvcsHPNewCustomAgent.version=1.0
VRTSvcsHPNewCustomAgent.IDstart=2017001
VRTSvcsHPNewCustomAgent.IDend=2017040
VRTSvcsHPNewCustomAgent.Category=_________
1. If the original SMC le for a given BMC le exists, you can edit it using a text editor.
Otherwise create a new SMC le.
b. Change the minor number of the version number in the header. For example,
change the version from 2.0 to 2.1.
2. Generate the new BMC le using the bmcgen command; place the new BMC le in
the corresponding language directory.
3. In the directory containing the BMC le, run the bmcmap command to create a new
BMC map le.
The agent framework is the component of VCS that supports all VCS agents by enabling
them to communicate with the engine about the denitions of resource types, the values
congured for the resource attributes, and entry points they use.
Note Agents developed on the 4.0 agent framework are not compatible with the 2.0 or the
3.5 framework.
145
Log Messages in pre-VCS 4.0 Agents
Log Tag (Pre-VCS 4.0) Log Severity (VCS 4.0 and later)
TAG_A
VCS_CRITICAL
TAG_B
VCS_ERROR
TAG_C
VCS_WARNING
TAG_D
VCS_NOTE
TAG_E
VCS_INFORMATION
FsckOpt is incomplete
NULL,NULL,NULL,LOG_DEFAULT);
Appendix A, How the VCS 4.0 Agent Framework Works with VCS 2.0 and 3.5 Agents 147
Pre-VCS 4.0 Message APIs
VCSAgLogConsoleMsg
void
This primitive requests that the VCS agent framework write message to the agent log le,
$VCS_LOG/log/resource_type_A.log. The message must not exceed 4096 bytes. A
message greater that 4096 bytes is truncated.
tag can be any value from TAG_A to TAG_Z. Tags AE are enabled by default. To enable
other tags, use the halog command. flags can be zero or more of LOG_NONE,
LOG_TIMESTAMP (prints date and time), LOG_NEWLINE (prints a new line), and LOG_TAG
(prints tag). This primitive can be called from any entry point.
For example:
#include "VCSAgApi.h"
...
LOG_TAG|LOG_TIMESTAMP);
...
VCSAgLogI18NMsg
void
This primitive requests that the VCS agent framework write an internationalized
message with a message ID and four string arguments to the agent log le,
$VCS_LOG/log/resource_type_A.log. The message must not exceed 4096 bytes. A
message greater that 4096 bytes is truncated. The size of all argument strings combined
must not exceed 4096 bytes. If the argument string total exceeds 4096 bytes, then each
argument is allowed an equal portion of 4096 bytes and truncated if it exceeds the allowed
portion.
tag can be any value from TAG_A to TAG_Z. Tags A through H are enabled by default.
To enable other tags, modify the LogTags attribute of the corresponding resource type.
flags can be zero or more of LOG_NONE, LOG_TIMESTAMP (prints date and time),
LOG_NEWLINE (prints a new line), and LOG_TAG (prints tag). This primitive can be called
from any entry point.
For example:
#include "VCSAgApi.h"
...
char buffer[256];
Appendix A, How the VCS 4.0 Agent Framework Works with VCS 2.0 and 3.5 Agents 149
Pre-VCS 4.0 Message APIs
VCSAgLogI18NMsgEx
void
This primitive requests that the VCS agent framework write an internationalized
message with a message ID and six string arguments to the agent log le,
$VCS_LOG/log/resource_type_A.log. The message must not exceed 4096 bytes. A
message greater that 4096 bytes is truncated. The size of all argument strings combined
must not exceed 4096 bytes. If the argument string total exceeds 4096 bytes, then each
argument is allowed an equal portion of 4096 bytes and truncated if it exceeds the allowed
portion.
tag can be any value from TAG_A to TAG_Z. Tags A through H are enabled by default.
To enable other tags, modify the LogTags attribute of the corresponding resource type.
flags can be zero or more of LOG_NONE, LOG_TIMESTAMP (prints date and time),
LOG_NEWLINE (prints a new line), and LOG_TAG (prints tag). This primitive can be called
from any entry point.
For example:
#include "VCSAgApi.h"
...
char buffer[256];
VCSAgLogI18NConsoleMsg
void
VCSAgLogI18NConsoleMsg(int tag,
This primitive requests that the VCS agent framework write an internationalized
message with a message ID and four string arguments to the agent log le,
$VCS_LOG/log/resource_type_A.log. The message must not exceed 4096 bytes. A
message greater that 4096 bytes is truncated. The size of all argument strings combined
must not exceed 4096 bytes. If the argument string total exceeds 4096 bytes, then each
argument is allowed an equal portion of 4096 bytes and truncated if it exceeds the allowed
portion.
tag can be any value from TAG_A to TAG_Z. Tags A through E are enabled by default. To
enable other tags, use the halog command. flags can be zero or more of LOG_NONE,
LOG_TIMESTAMP (prints date and time), LOG_NEWLINE (prints a new line), and LOG_TAG
(prints tag). This primitive can be called from any entry point.
For example:
#include "VCSAgApi.h"
...
char buffer[256];
Appendix A, How the VCS 4.0 Agent Framework Works with VCS 2.0 and 3.5 Agents 151
Pre-VCS 4.0 Message APIs
VCSAgLogI18NConsoleMsgEx
void
VCSAgLogI18NConsoleMsgEx(int tag,
This primitive requests that the VCS agent framework write an internationalized
message with a message ID and six string arguments to the agent log le,
$VCS_LOG/log/resource_type_A.log. The message must not exceed 4096 bytes. A
message greater that 4096 bytes is truncated. The size of all argument strings combined
must not exceed 4096 bytes. If the argument string total exceeds 4096 bytes, then each
argument is allowed an equal portion of 4096 bytes and truncated if it exceeds the allowed
portion.
tag can be any value from TAG_A to TAG_Z. Tags A through E are enabled by default. To
enable other tags, use the halog command. flags can be zero or more of LOG_NONE,
LOG_TIMESTAMP (prints date and time), LOG_NEWLINE (prints a new line), and LOG_TAG
(prints tag). This primitive can be called from any entry point.
For example:
#include "VCSAgApi.h"
...
...
char buffer[256];
A D
action entry point debug message severity level 73
C++ syntax 44
E
ActionTimeout 98
entry points
agent messages
attr_changed 26
formatting 69
clean 23
AgentClass parameter 111
close 26
AgentFile parameter 98
definition 2, 15
AgentPriority parameter 111
info 21
AgentReplyTimeout parameter 98
monitor 20
AgentStartTimeout parameter 98
offline 22
ArgList parameter 99
online 22
ArgList reference attributes 99
open 26
attr_changed entry point 26
sample structure 17
C++ syntax 46
shutdown 26
script syntax 65
enum types for clean
AttrChangedTimeout parameter 99
VCSAgCleanMonitorHung 23
B VCSAgCleanOfflineHung 23
Binary Message Catalog (BMC) files VCSAgCleanOfflineIneffective 23
converting from SMC files 141 VCSAgCleanOnlineHung 23
displaying contents 141 VCSAgCleanOnlineIneffective 23
updating 143 VCSAgCleanUnexpectedOffline 23
bmcgen utility 141
F
bmcread utility 141
FaultOnMonitorTimeouts parameter 101
153
LogFileSize parameter 103 CloseTimeout 99
FaultOnMonitorTimeouts 101
M
FireDrill 101
message format 69
LogDbg 102
script syntax 63
OfflineMonitorInterval 105
N OnlineWaitLimit 106
O Operations 106
function 80
ScriptPriority parameter 111
function 80
shutdown entry point 26
Index 155