/*
* Copyright 1992-1999 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/* The main routine for the availabiity plugin */
#include "availability.h"
static const char szLynxAutoEmailRadioFormat[] = "
Automatic e-mail distribution : Enable Disable ";
static const char szLynxShutDownRadioFormat [] = "
Display reason for shutdown : Enable Disable ";
static const char szLynxHinvRadioFormat [] = "
Include HINV information in the e-mail : Yes No ";
static const char szLynxSysMsgRadioFormat [] = "
Capture important system messages : Enable Disable ";
static const char szLynxUpTimeRadioFormat [] = "
Start uptime daemon : Yes No ";
static const char szLynxNumDaysInputFormat [] = "
Number of days between status updates : days ";
static const char szLynxUptimeCheckFormat [] = "
Interval in seconds between uptime checks : seconds ";
static const char szLynxInTextEmailFormat [] = " in text form : ";
static const char szLynxInCompEmailFormat [] = " in compressed form : ";
static const char szLynxInEncrEmailFormat [] = " in compressed encrypted form : ";
static const char szLynxInTextDiagFormat [] = " in text form : ";
static const char szLynxInCompDiagFormat [] = " in compressed form : ";
static const char szLynxInEncrDiadFormat [] = " in compressed encrypted form : ";
static const char szLynxInPagerAmailFormat [] = "
Enter email addresses for chatty pager: ";
/* Some Lynx related Helpers */
static int IsStrBlank ( const char * str )
{
if ( str == NULL || str[0] == 0 || (strspn ( str," ") == strlen (str)))
return 1;
else
return 0;
}
static int IsAnyBadChars ( const char * str )
{
if ( strpbrk( str, " " ) != NULL )
return 1;
if ( strchr ( str, '"' ) != NULL )
return 1;
return 0;
}
static int IsValidInt ( const char * str, int min, int max )
{
int val;
if ( strspn ( str, "0123456789" ) != strlen(str))
return 0;
if ( sscanf ( str, "%d", &val ) != 1 )
return 0;
if ( val < min || val > max )
return 0;
return 1;
}
int addresscompare(const void *address1, const void *address2)
{
return(strcmp(*(char **)address1, *(char **)address2));
}
static void updateemailconfig_availmon(ssdb_Error_Handle Error, ssdb_Request_Handle Request,
int num_records, char *newconfig, char *tag)
{
char *nc[128];
char *oc[128];
int numnc = 0;
int numoc = 0;
char *tmpaddr = NULL;
char *p = NULL;
int i = 0, j = 0, k = 0;
char regist[1024];
char deregist[1024];
int regbytes = 0, deregbytes = 0;
int adds = 0;
int deletes = 0;
const char **vector;
char **ap;
char **ap1;
if ( !Request || !Error || !tag ) return;
regbytes += snprintf(®ist[regbytes], sizeof(regist),
"/usr/etc/amformat -r -E %s:", tag);
deregbytes += snprintf(&deregist[deregbytes], sizeof(deregist),
"/usr/etc/amformat -d -E %s:", tag);
if ( newconfig && strlen(newconfig) ) {
tmpaddr = strdup(newconfig);
p = strtok(tmpaddr, " ,");
while (p) {
nc[numnc] = p;
numnc++;
p = strtok(NULL, " ,");
}
}
if ( numnc ) {
qsort(nc, numnc, sizeof(char *), addresscompare);
}
nc[numnc] = NULL;
ssdbRequestSeek(Error, Request, 0, 0);
for ( i = 0; i < num_records; i++ ) {
vector = ssdbGetRow(Error, Request);
if ( vector && vector[0] && vector[0][0] ) {
oc[numoc] = strdup(vector[0]);
numoc++;
}
}
oc[numoc] = NULL;
if ( numoc ) {
qsort(oc, numoc, sizeof(char *), addresscompare);
}
if ( !numnc && !numoc ) goto end;
/* Start the comparision */
ap = nc;
ap1= oc;
while ( *ap && *ap1) {
i = strcmp(*ap, *ap1);
if ( i == 0 ) {
ap++;
ap1++;
} else if ( i < 0 ) {
regbytes += snprintf(®ist[regbytes], sizeof(regist), "%s,", *ap);
ap++;
adds++;
} else {
deregbytes += snprintf(&deregist[deregbytes], sizeof(deregist), "%s,", *ap1);
ap1++;
deletes++;
}
}
while (*ap) {
regbytes += snprintf(®ist[regbytes], sizeof(regist), "%s,", *ap);
ap++;
adds++;
}
while (*ap1) {
deregbytes += snprintf(&deregist[deregbytes], sizeof(deregist), "%s,", *ap1);
ap1++;
deletes++;
}
snprintf(®ist[regbytes], sizeof(regist), " 2>&1 >/dev/null &");
snprintf(&deregist[deregbytes], sizeof(deregist), " 2>&1 >/dev/null &");
if ( adds ) system(regist);
if ( deletes ) system(deregist);
end:
free(tmpaddr);
if ( numoc )
for ( i = 0; i < numoc; i++ ) free(oc[i]);
return;
}
static void updatert_availmon(ssdb_Error_Handle Error, ssdb_Connection_Handle Connection,
int av_autoemail, int av_shutdown, int av_uptimed, int av_daysupdate,
int av_tickduration)
{
const char **vector;
ssdb_Request_Handle Request = 0;
int numrows = 0;
int i = 0;
int runcommand = 0;
char systemcmd[1024];
int tickerddone = 0;
if ( !Error || !Connection ) return;
if ( !(Request = ssdbSendRequest(Error, Connection, SSDB_REQTYPE_SELECT,
"select tool_option, option_default from tool where tool_name = 'AVAILMON'")))
{
return;
}
if ( !(numrows = ssdbGetNumRecords(Error, Request))) return;
ssdbRequestSeek(Error, Request, 0, 0);
for ( i = 0; i < numrows; i++ ) {
runcommand = 0;
vector = ssdbGetRow(Error, Request);
if ( vector ) {
if ( !strcmp(vector[0], "autoemail") ) {
if ( vector[1] && vector[1][0] != '\0' && atoi(vector[1]) != av_autoemail)
{
/* Detected a change in autoemail from saved one !! Send report */
if ( av_autoemail ) snprintf(systemcmd, sizeof(systemcmd), "/usr/etc/amformat -A -a -r 2>&1 >/dev/null &");
else snprintf(systemcmd, sizeof(systemcmd), "/usr/etc/amformat -A -a -d 2>&1 >/dev/null &");
runcommand = 1;
}
} else if ( !strcmp(vector[0], "shutdownreason") ) {
if ( vector[1] && vector[1][0] != '\0' && atoi(vector[1]) != av_shutdown ) {
snprintf(systemcmd, sizeof(systemcmd), "echo %d > /var/adm/avail/.save/shutdownreason 2>/dev/null" ,
av_shutdown);
runcommand = 1;
}
} else if ( !strcmp(vector[0], "tickerd") && !tickerddone ) {
if ( vector[1] && vector[1][0] != '\0' && atoi(vector[1]) != av_uptimed ) {
snprintf(systemcmd, sizeof(systemcmd), "/usr/etc/eventmond -a off 2>/dev/null");
if ( av_daysupdate > 0 ) {
system(systemcmd);
if ( av_uptimed ) {
snprintf(systemcmd, sizeof(systemcmd), "/usr/etc/eventmond -a on -j %d -e %d 2>/dev/null",
(av_tickduration > 0 ? av_tickduration:300), av_daysupdate*24 );
runcommand = 1;
} else
runcommand = 0;
} else {
system(systemcmd);
}
tickerddone = 1;
}
} else if ( !strcmp(vector[0], "statusinterval") && !tickerddone ) {
if ( vector[1] && vector[1][0] != '\0' && atoi(vector[1]) != av_daysupdate) {
snprintf(systemcmd, sizeof(systemcmd), "/usr/etc/eventmond -a off 2>/dev/null");
if ( av_daysupdate > 0 ) {
system(systemcmd);
if ( av_uptimed ) {
snprintf(systemcmd, sizeof(systemcmd), "/usr/etc/eventmond -a on -j %d -e %d 2>/dev/null",
(av_tickduration > 0 ? av_tickduration:300), av_daysupdate*24 );
runcommand = 1;
} else runcommand = 0;
} else {
system(systemcmd);
}
tickerddone = 1;
}
}
}
if ( runcommand ) {
system(systemcmd);
}
}
ssdbFreeRequest(Error, Request);
return;
}
void display_param_missing_errors ( const char *szParam )
{
Body("\n");
Body("\n");
Body("\n");
Body("Embedded Support Partner - ver.1.0 \n");
Body("\n");
Body("\n");
FormatedBody(" SETUP > Availmon Monitor > Configuration ");
Body(" \n");
FormatedBody("Parameter "%s" is missing or empty.",szParam);
Body("\n");
Body("\n");
}
void display_param_str_errors ( const char *szParam )
{
Body("\n");
Body("
\n");
Body("\n");
Body("Embedded Support Partner - ver.1.0 \n");
Body("\n");
Body("\n");
FormatedBody(" SETUP > Availmon Monitor > Configuration ");
Body(" \n");
FormatedBody(""%s" should not contain '"' character",szParam);
Body("\n");
Body("\n");
}
void display_param_int_errors ( mySession *sess, const char *szParam, const char *szLimit )
{
Body("\n");
Body("
\n");
Body("\n");
Body("Embedded Support Partner - ver.1.0 \n");
Body("\n");
Body("\n");
FormatedBody(" SETUP > Availmon Monitor > Configuration ");
Body(" \n");
FormatedBody("Parameter "%s" must be %s",szParam,szLimit);
Body("\n");
Body("\n");
}
int CheckInputFieldForBlank (CMDPAIR *cmdp, const char * szFieldName, const char *szParamName )
{
int idx;
idx = sscFindPairByKey ( cmdp, 0, szFieldName );
if ( idx >= 0 )
{
if ( IsStrBlank ( cmdp[idx].value ))
{
display_param_missing_errors ( szParamName );
return 0;
}
}
return 1;
}
int CheckInputFieldForBadChars (CMDPAIR *cmdp, const char * szFieldName, const char *szParamName )
{
int idx;
idx = sscFindPairByKey ( cmdp, 0, szFieldName );
if ( idx >= 0 )
{
if ( IsAnyBadChars ( cmdp[idx].value ))
{
display_param_str_errors ( szParamName );
return 0 ;
}
}
return 1;
}
/* End of Some Lynx Related Helpers */
void availmon_config(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle)
{
ssdb_Request_Handle req_handle;
int number_of_records;
const char **vector;
help_create(hError,"setup_availmon_configuration");
if ( session->textonly == 0 )
{
TableBegin("border=0 cellpadding=0 cellspacing=0");
RowBegin("");
CellBegin("");
Body("Automatic e-mail distribution:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'autoemail' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
if (atoi(vector[0]))
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Enable\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Disable\n");
CellEnd();
}
else
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Enable\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Disable\n");
CellEnd();
}
}
else
{
if (atoi(vector[0]))
FormatedBody(szLynxAutoEmailRadioFormat,"checked","");
else
FormatedBody(szLynxAutoEmailRadioFormat,"","checked");
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Display reason for shutdown:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'shutdownreason' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
if (atoi(vector[0]))
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Enable\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Disable\n");
CellEnd();
}
else
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Enable\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Disable\n");
CellEnd();
}
}
else
{
if (atoi(vector[0]))
FormatedBody(szLynxShutDownRadioFormat,"checked","");
else
FormatedBody(szLynxShutDownRadioFormat,"","checked");
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Include HINV information in the e-mail:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'hinvupdate' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
if (atoi(vector[0]))
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Yes\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("No\n");
CellEnd();
}
else
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Yes\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("No\n");
CellEnd();
}
}
else
{
if (atoi(vector[0]))
FormatedBody(szLynxHinvRadioFormat,"checked","");
else
FormatedBody(szLynxHinvRadioFormat,"","checked");
}
}
ssdbFreeRequest(error_handle,req_handle);
#if 0
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Capture important system messages:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'livenotification' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
if (atoi(vector[0]))
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Enable\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Disable\n");
CellEnd();
}
else
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Enable\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Disable\n");
CellEnd();
}
}
else
{
if (atoi(vector[0]))
FormatedBody(szLynxSysMsgRadioFormat,"checked","");
else
FormatedBody(szLynxSysMsgRadioFormat,"","checked");
}
}
ssdbFreeRequest(error_handle,req_handle);
#endif
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Start uptime daemon:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'tickerd' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
if (atoi(vector[0]))
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Yes\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("No\n");
CellEnd();
}
else
{
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("Yes\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
Body("No\n");
CellEnd();
}
}
else
{
if (atoi(vector[0]))
FormatedBody(szLynxUpTimeRadioFormat,"checked","");
else
FormatedBody(szLynxUpTimeRadioFormat,"","checked");
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Number of days between status updates (default = 60) (0 - 300):\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("colspan=5");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'statusinterval' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
FormatedBody(" days",vector[0]);
CellEnd();
}
else
{
FormatedBody(szLynxNumDaysInputFormat,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly != 0 ) {
Body("
(0 - 300) \n");
}
#if 0
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Filename for last uptime write (default = /var/adm/avail/.save/lasttick):\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("colspan=5");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'tickfile' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
FormatedBody(" ",vector[0]);
CellEnd();
}
else
{
FormatedBody("
Filename for last uptime write : ",vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
#endif
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Interval in seconds between uptime checks (default = 300 seconds):\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("colspan=5");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'tickduration' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
sscError(hError,"Configuration Missing for availmon\n");
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
if ( session->textonly == 0 )
{
FormatedBody(" seconds",vector[0]);
CellEnd();
}
else
{
FormatedBody(szLynxUptimeCheckFormat,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
RowEnd();
RowBegin("");
CellBegin("colspan=7");
Body(" \n");
CellEnd();
RowEnd();
TableEnd();
}
else
{
Body(" (default - 300 seconds) \n");
}
}
void availmon_config_confirm(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle,CMDPAIR *cmdp)
{
ssdb_Request_Handle req_handle;
int number_of_records;
const char **vector;
char av_autoemail[10],av_shutdown[10],av_hinv[10],av_sysmsg[10],av_uptimed[10];
char av_daysupdate[10],av_lasttick[255],av_tickduration[10],common_string[2];
int common_int,pageselect;
int EnblVal;
char VectBuf[256];
if (!get_variable(hError,cmdp,INTTYPE,"pageselect",common_string,&pageselect,600))
return;
if(!pageselect)
help_create(hError,"setup_availmon_viewcurr");
if(pageselect)
{
if ( session->textonly )
{ /* we must validate input parameters and generate page if error */
int idx = 0;
idx = sscFindPairByKey ( cmdp, 0, "av_daysupdate" );
if ( idx >= 0 )
{ /* Found let's try */
if ( IsStrBlank ( cmdp[idx].value ))
{
display_param_missing_errors ( "Number of days between status updates" );
return ;
}
if ( !IsValidInt ( cmdp[idx].value, 0, 300 ))
{
display_param_int_errors ( session, "Number of days between status updates", "non-negative, less then 300 integer value." );
return;
}
}
idx = sscFindPairByKey ( cmdp, 0, "av_tickduration" );
if ( idx >= 0 )
{ /* Found let's try */
if ( IsStrBlank ( cmdp[idx].value ))
{
display_param_missing_errors ( "Interval between update check" );
return ;
}
if ( !IsValidInt ( cmdp[idx].value, 0, 600 ))
{
display_param_int_errors ( session, "Interval between update check", "non-negative, less then 600 integer value." );
return;
}
}
#if 0
idx = sscFindPairByKey ( cmdp, 0, "av_lasttick" );
if ( idx >= 0 )
{
if ( IsStrBlank ( cmdp[idx].value ))
{
display_param_missing_errors ( "Filename for last uptime write" );
return ;
}
if ( !CheckInputFieldForBadChars(cmdp, "av_lasttick", "Filename for last uptime write" ))
return;
}
#endif
}
if (!get_variable(hError,cmdp,CHARTYPE,"av_autoemail",av_autoemail,&common_int,601))
return;
if (!get_variable(hError,cmdp,CHARTYPE,"av_shutdown",av_shutdown,&common_int,602))
return;
if (!get_variable(hError,cmdp,CHARTYPE,"av_hinv",av_hinv,&common_int,603))
return;
#if 0
if (!get_variable(hError,cmdp,CHARTYPE,"av_sysmsg",av_sysmsg,&common_int,604))
return;
#endif
if (!get_variable(hError,cmdp,CHARTYPE,"av_uptimed",av_uptimed,&common_int,605))
return;
if (!get_variable(hError,cmdp,CHARTYPE,"av_daysupdate",av_daysupdate,&common_int,606))
return;
#if 0
if (!get_variable(hError,cmdp,CHARTYPE,"av_lasttick",av_lasttick,&common_int,607))
return;
#endif
if (!get_variable(hError,cmdp,CHARTYPE,"av_tickduration",av_tickduration,&common_int,608))
return;
/* Added by sri to update availmon daemon real-time before configuration is written to DB */
updatert_availmon(error_handle, connection, atoi(av_autoemail), atoi(av_shutdown), atoi(av_uptimed),
atoi(av_daysupdate), atoi(av_tickduration));
if(!(ssdbLockTable(error_handle,connection,"tool")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='autoemail'",av_autoemail)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='shutdownreason'",av_shutdown)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='hinvupdate'",av_hinv)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
#if 0
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='livenotification'",av_sysmsg)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
#endif
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='tickerd'",av_uptimed)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='statusinterval'",av_daysupdate)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
#if 0
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='tickfile'",av_lasttick)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
#endif
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE,
"update tool set option_default = '%s' where tool_name = 'AVAILMON' and tool_option='tickduration'",av_tickduration)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0)
{
Body(" SGI Embedded Support Partner - ver.1.0 \n");
Body("\n");
Body("\n");
Body("\n");
} else {
Body("\n");
}
}
if(!pageselect)
{
if ( session->textonly == 0 )
{
RowBegin("");
CellBegin("");
Body(" \n");
CellEnd();
RowEnd();
} else {
Body(" \n");
}
availmon_mail_confirm_html(hError,session,connection,error_handle,pageselect);
}
}
void availmon_mail(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle,CMDPAIR *cmd)
{
ssdb_Request_Handle req_handle;
int number_of_records,rec_sequence;
const char **vector;
char email_list[1024];
help_create(hError,"setup_availmon_email");
if ( session->textonly == 0 )
{
Body("\n");
RowBegin("");
CellBegin("colspan=3");
Body("E-mail list for availability report: \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter e-mail addresses that receive availability report in text form: \n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
else
{
Body("
E-mail list for availability report: \n");
Body("
Enter e-mail addresses that receive availability report \n");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'AVAILABILITY' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
Body(" \n");
}
else
{
FormatedBody(szLynxInTextEmailFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInTextEmailFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter e-mail addresses that receive availability report in compressed form:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'AVAILABILITY_COMP' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
Body(" \n");
}
else
{
FormatedBody(szLynxInCompEmailFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInCompEmailFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter e-mail addresses that receive availability report in compressed encrypted form:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'AVAILABILITY_CENCR' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
Body(" \n");
}
else
{
FormatedBody(szLynxInEncrEmailFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInEncrEmailFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3 ");
Body("E-mail list for diagnostic report: \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter e-mail addresses that receive diagnostic report in text form:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
else
{
Body("
E-mail list for diagnostic report: \n");
Body("
Enter e-mail addresses that receive diagnostic report \n");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'DIAGNOSTIC' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
Body(" \n");
}
else
{
FormatedBody(szLynxInTextDiagFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if (session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInTextDiagFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter e-mail addresses that receive diagnostic report in compressed form:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'DIAGNOSTIC_COMP' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
Body(" \n");
}
else
{
FormatedBody(szLynxInCompDiagFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInCompDiagFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter e-mail addresses that receive diagnostic report in compressed encrypted form:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'DIAGNOSTIC_CENCR' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0)
{
Body(" \n");
}
else
{
FormatedBody(szLynxInEncrDiadFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInEncrDiadFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body("E-mail list for chatty pager \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=3");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Enter email addresses for chatty pager:\n");
CellEnd();
CellBegin("");
Body(" \n");
CellEnd();
CellBegin("");
}
else
{
Body("
E-mail list for chatty pager \n");
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'PAGER' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
Body(" \n");
}
else
{
FormatedBody(szLynxInPagerAmailFormat,"");
}
}
else
{
for (rec_sequence=0; rec_sequence < number_of_records; rec_sequence++)
{
if(rec_sequence > 0)
strcat(email_list,",");
else
memset(email_list,0,1024);
vector = ssdbGetRow(error_handle,req_handle);
if(vector)
{
strcat(email_list,vector[0]);
}
}
ssdbFreeRequest(error_handle,req_handle);
if ( session->textonly == 0 )
{
FormatedBody(" ",email_list);
}
else
{
FormatedBody(szLynxInPagerAmailFormat,email_list);
}
}
if ( session->textonly == 0 )
{
CellEnd();
RowEnd();
TableEnd();
}
}
void availmon_mail_confirm(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle,CMDPAIR *cmdp)
{
ssdb_Request_Handle req_handle;
int number_of_records,rec_sequence,common_int,pageselect;
const char **vector;
char *p;
char email_list[1024],common_string[2];
if (!get_variable(hError,cmdp,INTTYPE,"pageselect",common_string,&pageselect,609))
return;
if ( session->textonly )
{
/* Avail Report */
if ( !CheckInputFieldForBadChars ( cmdp, "av_text", "E-mail addresses that receive availability report in text form" ))
return ;
if ( !CheckInputFieldForBadChars ( cmdp, "av_compressed", "E-mail addresses that receive availability report in compressed form" ))
return ;
if ( !CheckInputFieldForBadChars ( cmdp, "av_encrypted", "E-mail addresses that receive availability report in compressed encrypted form" ))
return ;
/* Diagnostic report */
if ( !CheckInputFieldForBadChars ( cmdp, "av_diag_text", "E-mail addresses that receive diagnostic report in text form" ))
return ;
if ( !CheckInputFieldForBadChars ( cmdp, "av_diag_compressed","E-mail addresses that receive diagnostic report in compressed form" ))
return ;
if ( !CheckInputFieldForBadChars ( cmdp, "av_diag_encrypted", "E-mail addresses that receive diagnostic report in compressed encrypted form" ))
return ;
/* Pager report */
if ( !CheckInputFieldForBadChars ( cmdp, "av_pager", "E-mail address for chatty pager" ))
return ;
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_text",email_list,&common_int,610))
return;
if(!(ssdbLockTable(error_handle,connection,"tool")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'AVAILABILITY' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "AVAILABILITY");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option = 'AVAILABILITY' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','AVAILABILITY','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','AVAILABILITY','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_compressed",email_list,&common_int,611))
{
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'AVAILABILITY_COMP' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "AVAILABILITY_COMP");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option='AVAILABILITY_COMP' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','AVAILABILITY_COMP','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','AVAILABILITY_COMP','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_encrypted",email_list,&common_int,612))
{
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'AVAILABILITY_CENCR' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "AVAILABILITY_CENCR");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option = 'AVAILABILITY_CENCR' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','AVAILABILITY_CENCR','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','AVAILABILITY_CENCR','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_diag_text",email_list,&common_int,613))
{
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'DIAGNOSTIC' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "DIAGNOSTIC");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option = 'DIAGNOSTIC' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','DIAGNOSTIC','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','DIAGNOSTIC','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_diag_compressed",email_list,&common_int,614))
{
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'DIAGNOSTIC_COMP' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "DIAGNOSTIC_COMP");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option = 'DIAGNOSTIC_COMP' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','DIAGNOSTIC_COMP','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','DIAGNOSTIC_COMP','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_diag_encrypted",email_list,&common_int,615))
{
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'DIAGNOSTIC_CENCR' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "DIAGNOSTIC_CENCR");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option = 'DIAGNOSTIC_CENCR' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','DIAGNOSTIC_CENCR','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','DIAGNOSTIC_CENCR','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!get_variable_variable(hError,cmdp,CHARTYPE,"av_pager",email_list,&common_int,616))
{
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_option = 'PAGER'and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
number_of_records = getnumrecords(hError,error_handle,req_handle);
updateemailconfig_availmon(error_handle, req_handle, number_of_records, email_list, "PAGER");
ssdbFreeRequest(error_handle,req_handle);
if(number_of_records)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE,
"delete from tool where tool_option = 'PAGER' and tool_name='AVAILMON'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
if (!strlen(email_list))
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values ('AVAILMON','PAGER','')")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
}
else
{
p = strtok(email_list," ,");
while (p)
{
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT,
"insert into tool values('AVAILMON','PAGER','%s')",p)))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
if (!ssdbUnLockTable(error_handle,connection))
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
ssdbFreeRequest(error_handle,req_handle);
p = strtok(NULL," ,");
}
}
if (!ssdbUnLockTable(error_handle,connection))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
availmon_mail_confirm_html(hError,session,connection,error_handle,pageselect);
}
void availmon_mail_confirm_html(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle, int pageselect)
{
ssdb_Request_Handle req_handle;
int i,number_of_records;
const char **vector;
if(pageselect == 2)
{
if ( session->textonly == 0 )
{
Body("SGI Embedded Support Partner - ver.1.0 \n");
Body("\n");
} else {
Body("\n");
}
}
}
void global_setup(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle,CMDPAIR *cmdp)
{
ssdb_Request_Handle req_handle;
int number_of_records,rec_sequence;
const char **vector;
int action_id,logging_event,filter_event,action_event;
help_create(hError,"setup_global_event_cfg");
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_name = 'SEM' and tool_option = 'GLOBAL_LOGGING_FLAG'")))
{
sscError(hError,"Database API Error: \"%s\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
print_error();
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if (vector)
{
logging_event = atoi(vector[0]);
ssdbFreeRequest(error_handle,req_handle);
}
else
{
print_error();
ssdbFreeRequest(error_handle,req_handle);
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_name = 'SEM' and tool_option = 'GLOBAL_THROTTLING_FLAG'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
print_error();
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if (vector)
{
filter_event = atoi(vector[0]);
ssdbFreeRequest(error_handle,req_handle);
}
else
{
print_error();
ssdbFreeRequest(error_handle,req_handle);
return;
}
if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT,
"select option_default from tool where tool_name = 'SEM' and tool_option = 'GLOBAL_ACTION_FLAG'")))
{
sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle));
return;
}
if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0)
{
print_error();
ssdbFreeRequest(error_handle,req_handle);
return;
}
vector = ssdbGetRow(error_handle,req_handle);
if (vector)
{
action_event = atoi(vector[0]);
ssdbFreeRequest(error_handle,req_handle);
}
else
{
print_error();
ssdbFreeRequest(error_handle,req_handle);
return;
}
TableBegin("border=0 cellpadding=0 cellspacing=0");
RowBegin("");
CellBegin("");
Body("Log events \n");
CellEnd();
CellBegin("align=right");
if (logging_event)
Body(" Yes No\n");
else
Body(" Yes No\n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2");
Body("This parameter enables or disables global event logging. Select \"Yes\" to log events in the SGI Embedded Support Partner database. Select \"No\" if you do not want to log any events in SGI Embedded Support Partner database.\n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan = 2");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Throttle events \n");
CellEnd();
CellBegin("align=right");
if(filter_event)
Body(" Yes No\n");
else
Body(" Yes No\n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2");
Body("This parameter enables or disables event throttling for all events. Select \"Yes\" to require that a specific number of events must occur before the event is registered in the SGI Embedded Support Partner database. Select \"No\" to register every event in the SGI Embedded System Partner database. \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("");
Body("Act on events \n");
CellEnd();
CellBegin("align=right");
if(action_event)
Body(" Yes No\n");
else
Body(" Yes No\n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2 ");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan=2 ");
Body("This parameter enables or disables SGI Embedded Support Partner actions in response to events. Select \"Yes\" to specify that the SGI Embedded Support Partner should perform actions in response to all events that occur. Select \"No\" to specify that the SGI Embedded Support Partner should not respond to events that occur.\n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("colspan = 2");
Body(" \n");
CellEnd();
RowEnd();
RowBegin("");
CellBegin("align=right colspan=2");
Body(" \n");
CellEnd();
RowEnd();
TableEnd();
}
void globalconfirm(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection,
ssdb_Error_Handle error_handle,CMDPAIR *cmdp)
{
ssdb_Request_Handle req_handle;
int number_of_records,rec_sequence;
const char **vector;
int action_id,key,common_int,global_flag,global_throttle,global_logging;
char logging_event[10],filter_event[10],action_event[10],common_string[2],buffer[32];
Body("SGI Embedded Support Partner - ver.1.0 \n");
Body("\n");
Body("\n");
Body("\n");
}
void print_error(void)
{
CellBegin("colspan=2");
Body("No parameters for global setup in the database. \n");
RowEnd();
TableEnd();
Body("