cancel
Showing results for 
Search instead for 
Did you mean: 

Use of event triggers not working

Yet
Level 5
Partner Accredited

Hi,

My environment,

SFW-HA 6.0.1 & Windows 2008 R2

node 1 & node 2 in one cluster with EV service group

server 3 (not part of cluster) has CIFS shared folder \fileshare

 

I need to have \\server3\fileshare mounted as drive Z: on active node before EV service group goes online. From CLI I can issue "net use Z: \\server3\fileshare" and the share is mounting OK, so i added this to preonline.pl script thinking that it will run just like on CLI. I tried to online service group with that trigger but it seems to be not working though engine_A log shows it was executed successfully. 

This is what I've added on preonline.pl script,

$group = $ARGV[1];
if ($group eq "EV") {
    VCSAG_SYSTEM("net use Z: \\server3\fileshare");
}
 
i tried using preonline.bat instead of perl script with just one line command "net use Z: \\server3\fileshare". first, i tried to just double-click on batch file to make sure its working and it did mount fine, 2nd, i tried onlining the service group, this time it somehow mounted the share but on My Computer it shows disconnected though I can read/write the drive, but the service group did not go online. I cannot dismount it anymore unless i reboot the active node. 
 
Any idea why it's not mounting through perl, and why it behaves like that through batch file?
 
If the same syntax run manually it's fine but if its part of the trigger it's not workiing.
 
35 REPLIES 35

mikebounds
Level 6
Partner Accredited

Can you provide out of following:

hagrp -display

Mike

mikebounds
Level 6
Partner Accredited

Sorry, in perl "\" is a special character which means ignore meaning of next character, so for example if you want to use a double quote you use:

\"

so the double quote is not interpreted as the end of the string, so if you want to use a \ you have to use \\, so you code needs to be:

VCSAG_SYSTEM("net use Z: \\\\server3\\fileshare");

 

You can test trigger script as follows:

C:\>cd "\Program Files\VERITAS\cluster server\bin\Triggers"

 

C:\Program Files\VERITAS\cluster server\bin\Triggers>"\Program Files\VERITAS\VRTSPerl\bin\perl.exe" preonline.pl node1 EV MANUAL

 
The 3 passed args of "node1 EV MANUAL" are case sensistive and arg1 and arg2 should be what are displayed by "hagrp -list"
 
I have tested this on VCS running in VMWare and it works fine.
You should put your code just before the line:
# give control back to HAD.
 
Mike
 
 

mikebounds
Level 6
Partner Accredited

Your batch file did not work properly as you must do a hagrp -online -nopre at the end of the script as in the perl script:

 

`\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0]`;
 
So you would need to do something like:
hagrp online -nopre %2 -sys %1
 
But if you do use a batch file then I would add messages to engine log like the perl script does - example:
halog -add "Invoked with system %1, group %2 for reason %3" -sev I -sys %1
and other messages to say you are mounting network drive
 
Mike

Yet
Level 5
Partner Accredited

Thanks again Mike. I'm not much of perl scripter. :)

I modified and tried to run first form CLI like below, and it worked fine, share got mounted and SG onlined.

C:\Program Files\VERITAS\cluster server\bin\Triggers>"\Program Files\VERITAS\VRTSPerl\bin\perl.exe" preonline.pl node1 EV MANUAL

However, when I online SG from JAva Console, mounting behaves like running batch file i mentioned before, it mounted share drive but shows disconnected from My Computer though I can access it and SG got onlined.

Tried using vmware environment, results still the same. could it be credential issue?

Also, i tried using postoffline.pl to unmount after offline and it offlined SG but did not unmount (when i mount it using CLI above). I just appended below lines to postoffline.pl script, the syntax running from CLI is "net use Z: /DELETE".

# put your code here...
$group = $ARGV[1];
if ($group eq "EV") {
    VCSAG_SYSTEM("net use Z: \/DELETE");
}
 
any ideas? I really need a help on this.

Yet
Level 5
Partner Accredited

I tried to run postoffline.pl script manually from CLI (after mounting it via preonline.pl using CLI as well) and it did unmount the drive properly, though it did not offline SG but that's OK since i don't have offline command onpostoffline.pl.

Why is it that when it executed from CLI it works but not from VC Manager Java Console? any difference there?

mikebounds
Level 6
Partner Accredited

The PreOnline can used to make a decision about whether to online the service group, so suppose EV will not work without Z been mounted then the code can be something like:

 

$return_code=0;
$group = $ARGV[1];
if ($group eq "EV") {
    $return_code=VCSAG_SYSTEM("net use Z: \\server3\fileshare");
}

if ($return_code eq 0) {
    if (defined $ARGV[3]) {
        `\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0] -checkpartial $ARGV[3]`;
        exit;
    }
    `\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0]`;
}
else {
    VCSAG_LOG_MSG ("E", "Mount of Z: failed, so not onlining EV",9000 )
}
exit;

 

 


So that is why Preonline requires "hagrp -online -nopre" in the code and why if you run manually the group will be onlined.  All other trigger scripts just run and do not effect onlining or offlining service groups,  so don't required any "hagrp" commands which is why if you run a postoffline manually, it will not offline the group.

The difference in running script manually and through VCS, is that manually you are running script as a "logged in user" to your session, whereas when VCS runs it, it is being run by the "non-logged in user" that the "had" service runs as.

I have seen before that if you are using Terminal services that if a drive is assigned by VCS, My Computer doesn't see it but it is there and if you log out of terminal services session and back in, then it sees it.  I guess this is an issue with terminal services, something like, where it doesn't expect a drive to arrive where a command was not issued in it's session.  I think when a drive is assigned via the MountV resource, Terminal serivce DOES see it, so there is probably some extra coding to make this happen in the MountV agent.

Mike

Yet
Level 5
Partner Accredited

Thanks Mike for the script. I supposed i can just cut & paste this to preonline.pl and test.

mikebounds
Level 6
Partner Accredited

This code was an example if EV MUST have Z:

So if EV will work partially without Z: then I would not fail the online of the EV group if mount Z: fails, but if EV will not work at all without Z:, then yes you should copy this code into your script.

If mount does fail, I would give error code in log, like:

 

VCSAG_LOG_MSG ("E", "Mount of Z: failed with error code $return_code so not onlining EV",9000);
 
Mike
 
 
 

Yet
Level 5
Partner Accredited

Thanks Mike, I tried but same thing. When I online via Java SG went online but the drive was mounted with a red x & shows disconnected and yet it can be accessed normally. At this point it cannot be unmounted and have to reboot to clear the mount. If I execute the online trigger via CLI it went perfectly fine. I have to use Java of course, and this is my dilema now.

 

 

mikebounds
Level 6
Partner Accredited

Are you using terminal services or do you have console access  - I have only seen this sort of behaviour with terminal server access.   If you are using terminal services, try logging user out and logging back in again.

Have you tried umounting by implementing postoffline trigger so that trigger is called when you offline service group?

What shows red x - is this VEA?

Mike

 

Yet
Level 5
Partner Accredited

I access server via remote desktop connection. I tried logging out but when I login again the share still there showing disconnected but I can read/write on it.

I did try postoffline but nothing. I cannot even unmount it via CLI or from My Computer because it shows disconnected to nothing to unmount. I have to reboot the server to clear the mount.

When you map a network share from My Computer it will appear with the drive letter along with the local drives, on my case it appears but with red x and along with the drive letter display "Disconnected Network", though i can go to that drive and access the files.

I cannot keep the connection even after failover, it has to failover as well and I have to put this as part of the failover process.

I want to attach screenshot so you can see but I cannot do along with this post. Can i attach a file on this post as well?

mikebounds
Level 6
Partner Accredited

You should be able to attached a screenshot  just select "Insert an Image" icon (looks like a picture frame)

I don't know why you are have issues on your system.  On my VMWare workstation, I have 5.1 SFWHA on Windows 2003 and this is output:

 

C:\>find /v "#" "\Program Files\VERITAS\cluster server\bin\Triggers\preonline.pl"
 
---------- \PROGRAM FILES\VERITAS\CLUSTER SERVER\BIN\TRIGGERS\PREONLINE.PL
 
$vcs_home = $ENV{"VCS_HOME"};
if (!defined ($vcs_home)) {
        $vcs_home="C:\\Program Files\\VERITAS\\Cluster Server";
}
 
use ag_i18n_inc;
VCSAG_SET_ENVS();
 
if (!defined $ARGV[0]) {
        VCSAG_LOG_MSG ("W", "Failed to continue; undefined system name", 15028);
        exit;
} elsif (!defined $ARGV[1]) {
        VCSAG_LOG_MSG ("W", "Failed to continue; undefined group name", 15031);
        exit;
} elsif (!defined $ARGV[2]) {
        VCSAG_LOG_MSG ("W", "Failed to continue; undefined whyonlining", 15032);
        exit;
}
 
 
$group = $ARGV[1];
if ($group eq "testsg") {
        $return_code=VCSAG_SYSTEM("net use Z: \"\\\\.host\\Shared Folders\\unix-transfer\"");
        VCSAG_LOG_MSG ("I", "Mount of Z: has return code code $return_code",10000,$return_code);
}
 
if (defined $ARGV[3]) {
    `\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0] -checkpartial $ARGV[3]`;
    exit;
}
 
`\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0]`;
exit;
 
C:\>find /v /c "&*fake&*" "\Program Files\VERITAS\cluster server\log\engine_A.txt"
 
---------- \PROGRAM FILES\VERITAS\CLUSTER SERVER\LOG\ENGINE_A.TXT: 2635
 
C:\>net use
New connections will not be remembered.
 
There are no entries in the list.
 
 
C:\>hagrp -online testsg -sys W23-CMC
 
C:\>more +2635 "\Program Files\VERITAS\cluster server\log\engine_A.txt"
2013/09/18 23:50:22 VCS INFO V-16-1-50135 User Administrator fired command: hagrp -online testsg  W23-CMC  from 127.0.0.1
2013/09/18 23:50:22 VCS NOTICE V-16-1-10166 Initiating manual online of group testsg on system W23-CMC
2013/09/18 23:50:22 VCS NOTICE V-16-1-10233 Clearing Restart attribute for group testsg on all nodes
2013/09/18 23:50:22 VCS INFO V-16-6-10000 (W23-CMC) preonline:Mount of Z: has return code code 0
2013/09/18 23:50:22 VCS INFO V-16-1-50135 User Administrator fired command: hagrp -online testsg  W23-CMC  from 127.0.0.1
2013/09/18 23:50:23 VCS NOTICE V-16-1-10166 Initiating manual online of group testsg on system W23-CMC
2013/09/18 23:50:23 VCS NOTICE V-16-1-10233 Clearing Restart attribute for group testsg on all nodes
2013/09/18 23:50:23 VCS NOTICE V-16-1-10187 Received -nopre online command for group testsg on system W23-CMC
2013/09/18 23:50:23 VCS NOTICE V-16-1-10301 Initiating Online of Resource sharedfoldermount_mnt (Owner: unknown, Group: testsg) on System W23-CMC
2013/09/18 23:50:23 VCS INFO V-16-6-15002 (W23-CMC) hatrigger:hatrigger executed C:\Program Files\Veritas\Cluster Server\bin\triggers\preonline.pl successfully
 
C:\>net use
New connections will not be remembered.
 
 
Status       Local     Remote                    Network
 
-------------------------------------------------------------------------------
             Z:        \\.host\Shared Folders\unix-transfer
                                                 VMware Shared Folders
The command completed successfully.
 
 
C:\>z:
 
Z:\>c:
 
C:\>net use Z: /DELETE
Z: was deleted successfully.
 
 
C:\>
 
 
Mike

Yet
Level 5
Partner Accredited

Thanks Mike for very detailed reply.

One thing I have not tried is to online SG via CLI not JAVA, i resumed its the same. I will also mimic the setup to my VMware workstation and see how it behaves.

mikebounds
Level 6
Partner Accredited

It shouldn't make any difference if you use CLI or Java as in both cases the preonline script is called by hatrigger.pl which is called by "had" service.

Mike

Yet
Level 5
Partner Accredited

I mimic the setup to VMware workstation. SG is SQL-1. sys is SQL2

kindly see below, you can see at the bottom drive Z: is accessible. from My Computer this drive has red x and has status Disconnected Network Drive (Z:). To get rid of this I have to reboot.

**************************

C:\Program Files\Veritas\cluster server\bin\Triggers>find /v "#" preonline.pl

---------- PREONLINE.PL

$vcs_home = $ENV{"VCS_HOME"};
if (!defined ($vcs_home)) {
        $vcs_home="C:\\Program Files\\VERITAS\\Cluster Server";
}

use ag_i18n_inc;
VCSAG_SET_ENVS();

if (!defined $ARGV[0]) {
        VCSAG_LOG_MSG ("W", "Failed to continue; undefined system name", 15028);

        exit;
} elsif (!defined $ARGV[1]) {
        VCSAG_LOG_MSG ("W", "Failed to continue; undefined group name", 15031);
        exit;
} elsif (!defined $ARGV[2]) {
        VCSAG_LOG_MSG ("W", "Failed to continue; undefined whyonlining", 15032);

        exit;
}


$group = $ARGV[1];
if ($group eq "SQL-1") {
    VCSAG_SYSTEM("net use Z: \\\\DC\\Fileshare");
}


if (defined $ARGV[3]) {
    `\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0] -checkparti
al $ARGV[3]`;
    exit;
}

`\"$vcs_home\\bin\\hagrp\" -online -nopre $ARGV[1] -sys $ARGV[0]`;
exit;

C:\Program Files\Veritas\cluster server\log>net use
New connections will not be remembered.

There are no entries in the list.


C:\Program Files\Veritas\cluster server\log>find /v /c "&*fake&*" engine_A.txt

---------- ENGINE_A.TXT: 5109

C:\Program Files\Veritas\cluster server\log>z:
The system cannot find the drive specified.

C:\Program Files\Veritas\cluster server\log>hagrp -online SQL-1 -sys SQL2

C:\Program Files\Veritas\cluster server\log>more +5109 engine_A.txt
2013/09/19 22:14:24 VCS INFO V-16-1-50135 User (sql2\Administrators):EVADMIN@ABC
 fired command: hagrp -online SQL-1  SQL2  from ::1
2013/09/19 22:14:24 VCS NOTICE V-16-1-10166 Initiating manual online of group SQ
L-1 on system SQL2
2013/09/19 22:14:24 VCS NOTICE V-16-1-10233 Clearing Restart attribute for group
 SQL-1 on all nodes
2013/09/19 22:14:24 VCS INFO V-16-1-50135 User (sql2\Administrators):SYSTEM@NT A
UTHORITY fired command: hagrp -online SQL-1  SQL2  from ::1
2013/09/19 22:14:24 VCS NOTICE V-16-1-10166 Initiating manual online of group SQ
L-1 on system SQL2
2013/09/19 22:14:24 VCS NOTICE V-16-1-10233 Clearing Restart attribute for group
 SQL-1 on all nodes
2013/09/19 22:14:24 VCS NOTICE V-16-1-10187 Received -nopre online command for g
roup SQL-1 on system SQL2
2013/09/19 22:14:24 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQL-1-
IP (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:24 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQL-1-
VMDg (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:25 VCS INFO V-16-1-10298 Resource SQL-1-VMDg (Owner: Unspecifie
d, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:25 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQL-1-
MountV (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:25 VCS INFO V-16-6-15002 (SQL2) hatrigger:hatrigger executed "C
:\Program Files\Veritas\VRTSPerl\\bin\perl.exe" "C:\Program Files\Veritas\Cluste
r Server\bin\triggers\preonline.pl" SQL2 SQL-1 MANUAL  successfully
2013/09/19 22:14:26 VCS INFO V-16-1-10298 Resource SQL-1-MountV (Owner: Unspecif
ied, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:26 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQL-1-
RegRep-MSSQL (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:27 VCS INFO V-16-1-10298 Resource SQL-1-RegRep-MSSQL (Owner: Un
specified, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:28 VCS INFO V-16-1-10298 Resource SQL-1-IP (Owner: Unspecified,
 Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:28 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQL-1-
Lanman (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:46 VCS INFO V-16-1-10298 Resource SQL-1-Lanman (Owner: Unspecif
ied, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:46 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQLSer
ver-NEW_INSTANCE (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:46 VCS NOTICE V-16-1-10301 Initiating Online of Resource MSOlap
-NEW_INSTANCE (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:52 VCS INFO V-16-1-10298 Resource MSOlap-NEW_INSTANCE (Owner: U
nspecified, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:55 VCS INFO V-16-1-10298 Resource SQLServer-NEW_INSTANCE (Owner:  Unspecified, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:55 VCS NOTICE V-16-1-10301 Initiating Online of Resource SQLSer
verAgent-NEW_INSTANCE (Owner: Unspecified, Group: SQL-1) on System SQL2
2013/09/19 22:14:56 VCS INFO V-16-1-10298 Resource SQLServerAgent-NEW_INSTANCE (
Owner: Unspecified, Group: SQL-1) is online on SQL2 (VCS initiated)
2013/09/19 22:14:56 VCS NOTICE V-16-1-10447 Group SQL-1 is online on system SQL2

C:\Program Files\Veritas\cluster server\log>net use
New connections will not be remembered.

There are no entries in the list.


C:\Program Files\Veritas\cluster server\log>z:

Z:\>dir
 Volume in drive Z has no label.
 Volume Serial Number is D8B6-478C

 Directory of Z:\

09/16/2013  11:17 PM    <DIR>          .
09/16/2013  11:17 PM    <DIR>          ..
09/18/2013  12:01 AM    <DIR>          New folder
               0 File(s)              0 bytes
               3 Dir(s)  19,664,412,672 bytes free

Z:\>

 

 

 

 

 

 

 

Yet
Level 5
Partner Accredited

I tried running the preonline.pl script via CLI alone, it works just fine.

C:\Users\evadmin>net use
New connections will not be remembered.

There are no entries in the list.

C:\Users\evadmin>cd C:\Program Files\Veritas\cluster server\bin\Triggers

C:\Program Files\Veritas\cluster server\bin\Triggers>"C:\Program Files\Veritas\V
RTSPerl\bin\perl.exe" preonline.pl SQL2 SQL-1 MANUAL
The command completed successfully.

C:\Program Files\Veritas\cluster server\bin\Triggers>net use
New connections will not be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           Z:        \\DC\Fileshare            Microsoft Windows Network
The command completed successfully.


C:\Program Files\Veritas\cluster server\bin\Triggers>net use Z: /DELETE
Z: was deleted successfully.

C:\Program Files\Veritas\cluster server\bin\Triggers>net use
New connections will not be remembered.

There are no entries in the list.

C:\Program Files\Veritas\cluster server\bin\Triggers>

Yet
Level 5
Partner Accredited

I tried to change the service logon of HAD service to user I'm currently logged and online SG but this time it seems did not run the script. it went online wihtout mounting the drive, unlike when the service logon is Local System it mount the drive but shows disconnected.

there's really no resource i can use to run a single command like translate the function of script to a resource.

 

Yet
Level 5
Partner Accredited

I tried capturing any error incase it shows and I got this from the log. What is error "512"

19:09 VCS INFO V-16-1-50135 User (sql2\Administrators):EVADMIN@ABC fired command: hagrp -online SQL-1  SQL2  from ::1
2013/09/20 11:19:09 VCS NOTICE V-16-1-10166 Initiating manual online of group SQL-1 on system SQL2
2013/09/20 11:19:09 VCS NOTICE V-16-1-10233 Clearing Restart attribute for group SQL-1 on all nodes
2013/09/20 11:19:09 VCS INFO V-16-6-10000 (SQL2) preonline:Mount of Z: has return code code 512
2013/09/20 11:19:10 VCS INFO V-16-1-50135 User (sql2\Administrators):SQLADMIN@ABC fired command: hagrp -online SQL-1  SQL2  from ::1
2013/09/20 11:19:10 VCS NOTICE V-16-1-10166 Initiating manual online of group SQL-1 on system SQL2

mikebounds
Level 6
Partner Accredited

If there is a typo (like you have missed a "\") then you get "The network name cannot be found" with return code 512.

Mike