This translation is older than the original page and might be outdated.

XOneMonitor




The XOne Monitor is a service that aims to cover a very common need in the computer world, make sure everything goes as it should go.

Therefore, it is a service that will allow us checking that certain functions of our server works properly.

Besides, some functionalities have been added used for any specific case, which perhaps do not comply only with the objective of checking that something is working correctly, but can be useful..

Functionalities
Checking if any service is stopped, start it again and send an email warning us of the event.
Send us an email with some parameters that are indicative of the status of the project.
Execute periodic maintenances of the application tables and from the replica if there were.
Send emails warning us about any wrong behavior.
Creation of log of any of the previous errors for further supervision.
Creation, copy and file transfer from a location into another one.
Compression of files.
Deleting updates already confirmed.


The data included in the configuration file are the following ones:

Attribute Description
Xml Path Path of the XML file where the monitor checks are in.
servername Name of the Server
appname Name of the App
interval Time interval to review by default, as long as there is not defined. Expressed in seconds .
PARAMETERS OF EMAIL
smtpserver Address of the email server
displayUserName Name to display as email sender.
mailfrom Address of the email sender.
smtpuser User which we connect with to send the emails.
smtppwdr Password of the email user.
smtpport Port to send the email.
smtpusessl If it is true, it specifies that we are going to use SSL to send smtp.
PARAMETERS OF LOG
log If we want to leave log in the events display (true/false).
log file If we want leave log in an external txt file (true/false).
path log file Path of the external txt log file if we put to true the previous option.
PARAMETERS OF EMAIL FORMAT
Format Html The email format is simple text, if we want to give it html format we must enable this option (true/false). By default, if nothing is put, it will be returned in the new format.
Title Size Size text for the email title. If no value is specifed , the value by default is 24.
Title Forecolor Text color for the email title. If no value is specified, the value by default is #042244.
Title Font family Type of the text font for the email title. If no value is specified, the value by default is Calibri.
Text Size Text size for the email body. If no value is specified, the value by default is 14.
Text Forecolor Text color for the email body. If no value is specify, the value by default is #052b57.
Text Font family Type of text font for the email body. If no value is specified the value by default is Calibri.
Firm Name Initial name of the signature. TEXT, SIZE,COLOR and FONT TYPE for the signature title. I.e.: “Xonemonitor,14,#df2c28,Calibri”.
Firm Email Email of the person who send the email, we can put whatever, if nothing is specified, will be put that one configured in the checking or maintenance. TEXT,SIZE,COLOR amd FONT TYPE for the email of the signature. I.e.: “direccion@servidor.es,14,#df2c28,Calibri”.
Firm Image Path Path where the image to associate to the signature is placed in. The images type accepted are: .jpg .png .tif. WARNING: It is advisable that the image size is not very big since it could take a long time to set the message.
Firm Address TEXT,SIZE,COLOR and FONT TYPE for the address it appears in the signature.
Firm Image Size It specifies the width and height of the image of the signature. The structure is : Value:“Width, Height”.
Firm Zipcode TEXT,SIZE,COLOR and FONT TYPE for the zip code that appears in the signature.
Firm City TEXT,SIZE,COLOR and FONT TYPE for the city that appears in the signature.
Firm Phone TEXT,SIZE,COLOR and FONT TYPE for the phone that appears in the signature.
Firm Web Address TEXT,SIZE,COLOR and FONT TIPE for the web address that appears in the signature.
PARAMETERS OF DATABASES
ROWID Field Name Name of the ROWID field in the tables of the DB.
SQL Field Name Name of the SQL field in the MASTER_REPLICA_QUEUE table.
Date Format Date format of the DB.
MID Number MID we want to use if we are going to write something in the QUEUE.
<add key="Xml Path" value="C:\monitor.xml" />
 
<add key="servername" value="XOne"/>
<add key="appname" value="Aplicacion"/>
<add key="interval" value="500"/>
 
<!-- EMAIL KEYS -->
<add key="smtpserver" value = "www.servidor.es"/>
<add key="displayUserName" value="XOneManager"/>
<add key="mailfrom" value="cuenta@servidor.es"/>
<add key="smtpuser" value ="cuentacorreo"/>
<add key="smtppwdr" value ="contraseña"/>
<add key="smtpport" value ="587"/>
<add key="smtpusessl" value="false"/>
 
<!-- LOG KEYS -->
<add key="log" value="true" />
<add key="log file" value="false"/>
<add key="path log file" value="C:\Archivos de programa\XOne\Monitor\"/>
 
<!-- EMAIL FORMAT KEYS -->
<add key="Format Html" value="true"/>
 
<add key="Title Size" value="24"/>
<add key="Title Forecolor" value="#df2c28"/>
<add key="Title Font family" value="Calibri"/>
 
<add key="Text Size" value="14"/>
<add key="Text Forecolor" value="#000000"/>
<add key="Text Font family" value="Calibri"/>
 
<add key="Firm Name" value="Xonemonitor,14,#df2c28,Calibri" />
<add key="Firm Email" value="Xonemonitor@xone.es,14,#df2c28,Calibri"/>
<add key="Firm Image Path" value="C:\Archivos de programa\XOne\Monitor\image.jpg"/>
<add key="Firm Address" value="Direccion avenida sin nombre s/n.,14,#df2c28,Calibri"/>
<add key="Firm Zipcode" value=""/>
<add key="Firm City" value=""/>
<add key="Firm Phone" value="900123456,14,#000000,Calibri"/>
<add key="Firm Web Address" value="http://www.direccionweb.com,14,#df2c28,Calibri"/>
 
 
<!-- DATABASE KEYS -->
<add key="ROWID Field Name" value="ROWID" />
<add key="SQL Field Name" value="CGSSQL" />
<add key="Date Format" value="yyyy/MM/dd" />
<add key="MID Number" value="9999" />
 
<!-- 
Connection string of the DB we are going to monitor. \\ 
This is the connection by default, if we want to specify another one, we will put another name and we can instance it from any checking node of the connection="NOMBRECONEXION" attribute.
-->
<add name="monitordb" connectionString="Persist Security Info=False;database=BASEDATOS;server=SERVIDOR;user id=USUARIO;Password=CLAVE" 
	providerName="MySql.Data.MySqlClient" />


Our XML file will have an <xml> node and within this we will have the different ‘checking’ nodes (The actions are only executed if the condition is met) or ‘maintenance’ executed always according the chronology defined in the cron-expression attribute.

Within a checking node or maintenance we can use the following nodes:

sql Is the attribute where the SQL query we want launch is defined in.
service Used exclusively in the checking with type=“checkservice”
table Used exclusively in the checking with type=“checktable”
errormessage Message we want to show in the email sent
email Recipient of the email.
actions Actions to execute in sequential order.


All types of checking are case-sensitive in lowercase.
Each checking node has the checking name (name), the type (type) and optionally, an alternative connection (The connection is in case we want to use a different one that the one that comes by default monitordb (In the configuration file).
Also, optionally we can specify a chron expression to program the checking.
The checking nodes have the following structure:

<!-- ***********************************************************
    name:		Nombre que le queramos dar al checking.
    type:		Tipo de checking, para ver qué condición debe cumplirse.
    connection:		Opcional. "name" de la conexión a BD que queramos utilizar para el checking ("monitordb" por defecto),
    			esta conexión se define en el fichero de configuración.
    cron-expression: 	Opcional. Expresión cron para programar el checking con una cierta periodicidad diferente 
    			de la especificada en la clave "interval" del fichero de configuración.
 *********************************************************** -->
 
<checking name=" " type=" " connection=" " cron-expression=" ">
count A query is sent to the database which is composed only of a count of a table that we want to monitor.
If the value returned by the count is bigger than the specified in the count attribute of the sql node the specified action will be made.
groupby A query is sent to take data from several grouped logs (ie. Grouped by users).
If the specified SQL returns any row then the action specified is executed
checktable Comprobar si hay registros en una tabla que no están en el master_replica_queue o master_replica_queue_history.
(Por defecto, esta opción inserta esos registros en el queue).
Adicionalmente se puede ejecutar una acción al encontrar registros.
checkservice This option checks that a service is run.
If the service is stopped we can use one of the actions specified below.
filejob This option is to make a maintenance of files. Only is made if the SQL returns any value. Previous versions to 4.0.5.0 did use “filejop” instead “filejob”
pdf This option generates a PDF file. Only is made if the SQL returns any value.
<!-- 
	A query is sent to the database which is made up of only one COUNT of a table we want to monitor.  
	If the value returned in the SQL is bigger than the specified one in the count attribute, the specified action will be made. 
-->
<checking name="Comprobar IQUEUE" type="count">
    <sql value="SELECT COUNT(ID) FROM master_replica_iqueue" count="20" />
    <errormessage subject="Error" body="Hay mas de 20 operaciones en el IQUEUE"  header="" />
    <email to="email@xone.es" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
        <action name="sendmail" />
    </actions>
</checking>
 
<!--
	This option checks that a service is started. 
	If the service is stopped we can use one of the actions specified below. 
--> 
<checking name="Comprobar replicador" type="checkservice">
    <service value="CGSRepServer2" />
    <errormessage subject="Error" body="El replicador estaba parado y se ha arrancado."  header="" />
    <email to="email@xone.es" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
	<action name="startservice" value="CGSRepServer2" />
    </actions>
</checking>
 
<!--
	Checking if there are records in a table that are NOT in the master_replica_queue or master_replica_queue_history.
	(By default, this option inserts that records in the queue). 
	Additionally, an action can be executed when finding records. 
--> 
<checking name="Comprobar usuarios" type="checktable">
    <table value="gen_usuarios">
    <errormessage subject="Error" body="Se han reparado ##CHECKCOUNT## registros en gen_usuarios"  header="" />
    <email to="email@xone.es" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
	<action name="sendmail" />
    </actions>
</checking>
 
<!--
	A query is sent to take data from several grouped records.  
	If the specified SQL returns some row, then the specified action will be executed.  
-->
<checking name="Comprobar tareas" type="groupby">
    <sql value="......." />
    <email to="##ROW_MAP_CORREO##" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
        <action name="sendmail" />
    </actions>
</checking>


We can define the actions to execute in case the conditions of the checking nodes are met or for the maintenance nodes that are not conditionals and are executed when indicates in the chron-expression that have defined.
All the actions are case-sensitive in lowercase and can be written also with a hyphen, i.e: send-mail, execute-query, etc…

sendmail A query is sent to the database which is made up only of a count of a table we want to monitor.
If the value returned by the count is bigger than the specified one in the count attribute of the sql node where the specified action is made.
executequery A query is sent to take data from several grouped records(i.e. Grouped by user).
If the specified SQL returns any row, then the specified action is executed.
startservice Checking if there are records in a table that are not in the master_replica_queue or master_replica_queue_history.
(By default, this option inserts that records in the queue).
Additionally an action can be executed when finding records.
stopservice This option checks that a service is started.
If the service is stopped we can use one of the actions specified below.
restartservice This option is to make a file maintenance. Only is made if the SQL returns any value. Prior versions to the 4.0.5.0 did use “filejop” instead “filejob”
savetofile Experimental.
deletefile Experimental.
copyfile This option copies a file.
movefile This option changes the place of a file. See example below.
movedirectory Experimental.
createfolder Experimental.
compressfiles Experimental.
cleanupdates It specifies to delete updates of the repository. See example below.


By default, if the previous action has failed, it does not continue executing the following ones. In case we want to execute always the actions, although the previous action has failed, we have to specify the execute-always=true attribute (by default is false).

	<action name="sendmail" /> 	<!-- Utilizado junto con el nodo email -->
 
	<action name="executequery" value="DELETE FROM MASTER_REPLICA_SQUEUE WHERE SENT=1" />
	<action name="executequery" execute-always="true" value="ALTER INDEX IX_T1_RL REBUILD" />  <!-- Aunque falle el anterior, se ejecuta -->
 
	<action name="startservice" value="XOneRepServer" />
	<action name="stopservice" value="XOneRepServer" />
	<action name="restartservice" value="Xone Replicator Client Advanced" />
 
	<action name="move-file" from="##ROW_MAP_FILENAMEFROM##" to="##ROW_MAP_FILENAMETO##" 
		sql="UPDATE GEN_FOTOSTAREA SET MOVEFILE=1 WHERE ID='##ROW_MAP_ID##'"/>
 
 
<!--
	Acción para eliminar las actualizaciones que se van poniendo a los dispositivos, una vez que se han descargado y confirmado.
	PARAMETROS:
 
	path: 			Ruta hasta la licencia dentro de la carpeta del repositorio.
	version-folder: 	Nombre de la carpeta donde se ponen las actualizaciones del XOneManager.
	licenses-folder: 	Nombre de la carpeta donde se ponen las actualizaciones que se descargan los dispositivos (gzip).
	last-version-file:	Nombre del fichero que contiene las actualizaciones que se van confirmando.
	clean-version-folder:	****** Para eliminar las carpetas de las licencias que ya se hayan confirmado. ********
-->
	<action name="cleanupdates" path="C:\XOneRepository\Updates\10000168" version-folder="Actualizaciones" licenses-folder="Licencias" 
		last-version-file="lastversion" clean-version-folder="true" />


It sends an email with the data from the email and errormessage nodes.

<action name="sendmail" />


Within Sendmail has been implemented an “after-action” sub node (From the 3.0.4.9 version), to make any action after sending the email.

<action name="sendmail" >
	<after-action>
		<action name="executequery" value="UPDATE GEN_ADJUNTOS SET ENVIADO=5 WHERE ID=##ROW_ID##" />
		<action name="executequery" execute-if-error="true" value="UPDATE GEN_ADJUNTOS SET ENVIADO=3 WHERE ID=##ROW_ID##" />
	</after-action>
</action>


It starts the service specified in the value attribute.

  • The value we must specify in the value attribute is the name of the service (Service Name), not the name that appears in the services window (Display Name). If we go to the services console, we make right click on one of them, and if we go to the properties option, it would be the first one to appear.
<action name="startservice" value="CGSRepServer2" />



It stops the service specified in the value attribute.

  • The value we must specify in the value attribute is the name of the service. (Service Name), not the name that appears in the services window (Display Name). If we go to the services console, we make right click on one of them and if we go to the properties option it would be the first one to appear.


<action name="stopservice" value="CGSRepServer2" />



It restarts the service specified in the value attribute.

  • The value we must specify in the value attribute is the name of the service. (Service Name), not the name that appears in the services window (Display Name). If we go to the services console, we make right click on one of them and if we go to the properties option it would be the first one to appear.
<action name="restartservice" value="CGSRepServer2" />



It saves the structure of the errormessage node in a file.

  • In the value attribute is specified the full path to the file we want to create (file name included). Besides, there is a append attribute, by default is true so that it adds to the end of the file, if we put it to false it would create a new file in each execution.
<action name="savetofile" value="c:\generated_file.txt" append="false" />



It moves the location of a file.

  • In the from attribute is specified the full path to the file we want to move. (file name included) and, in the to attribute the same thing but for the destination. Besides, there is an sql attribute to execute an SQL when the action takes place.


<actions>	
	<action name="move-file" from="##ROW_MAP_FILENAMEFROM##" to="##ROW_MAP_FILENAMETO##" sql="UPDATE GEN_FOTOSTAREA SET MOVEFILE=1 WHERE ID='##ROW_MAP_ID##'"/>
</actions>


MACROS DESCRIPTION
##NL## Lines Break
##TAB## Tabulation
##SRVNAME## Server name
##APPNAME## Application name
##SQL## SQL sent
##CHECKCOUNT## Rows counter that have been fixed (To use with checktable)
##ROW_NOMBRECAMPOQUESEA## We take the value of the field returned by the SQL


Different nodes we have available within the CHECKING node:

Nodes of the Checking Node
SQL
ERRORMESSAGE
EMAIL
SERVICE - Only for the checking of checkservice type
TABLE - Only for the checking of checktable type
PDF



It has the sql we want to sent (value) and two more attributes.

Within this node we have a COUNT attribute that indicates the number that must be overcome to make any action, and GROUPBY indicates the field or fields (separated by commas) by which we must group the query.

  <sql value=" " count="" groupby="" />



It has the email subject (subject), a message body (body) and a header that will be the first thing to be displayed. (header).
In the case of a checking of the groupby type, the header will be displayed once, and the body will be repeated by each one of the records grouped. Each and every one of the macros indicated before, can be used in the attributes of this node.

  <errormessage subject="" body=" "  header="" />

Example of use, in which are sent as many emails as users are grouped, by putting in each email every one of the tasks pending that have associated. The subject is put in the subject field, header in the header field and body in the body field:

<checking name="Tareas Pendientes" type="groupby" cron-expression="0 0 8 ? * MON,FRI">
    <sql value="SELECT (SELECT COUNT(dt1.ID) FROM GEN_DetTarea dt1,gen_usuarios u1,gen_tareas t1 WHERE
			u1.ID=dt1.IDUSUARIO and dt1.IDUSUARIO=u.ID and dt1.IDTAREA=t1.ID and (u1.BAJA=0 AND u1.EMAIL IS NOT NULL) 
			and ((dt1.OPCIONES &amp; POWER(2,0))/POWER(2,0)) = 0
			and ((t1.OPCIONES &amp; POWER(2,0))/POWER(2,0)) = 0) as MAP_TOTALTAREAS,
    		u.LOGIN AS MAP_LOGIN,dt.*,dt.DESCRIPCION AS MAP_DESCRIPCION,
			t.IDEMPRESA AS MAP_IDEMPRESA,t.DESCRIPCION AS MAP_PROYECTO,t.IDCLIENTE AS MAP_IDCLIENTE,
			u2.LOGIN AS MAP_CREADOR,
			t2.SIMBOLO AS MAP_ESTADO,
			t3.ETIQUETA AS MAP_TIPOTAREA,t3.DESCRIPCION AS MAP_TIPOTAREADES,
			c.OPCIONES AS MAP_OPCIONES,
      		d.NUMCOMPLETO AS MAP_PRESUPUESTO,
      		u.EMAIL AS MAP_CORREO,
      		dt.IDUSUARIO AS MAP_USUARIO
			FROM (((((((GEN_DetTarea dt 
			LEFT OUTER JOIN gen_Tareas t ON dt.IDTAREA=t.ID)
			LEFT OUTER JOIN gen_Clientes c ON t.IDCLIENTE=c.ID)
			LEFT OUTER JOIN gen_Usuarios u2 ON dt.IDASIGNA=u2.ID)
			LEFT OUTER JOIN gen_Usuarios u ON dt.IDUSUARIO=u.ID)
			LEFT OUTER JOIN gen_Estados t2 ON dt.IDESTADO=t2.ID)
			LEFT OUTER JOIN gen_Documentos d ON dt.IDDOCUMENTO=d.ID)
			LEFT OUTER JOIN gen_tiposervicio t3 ON dt.IDTIPOTAREA=t3.ID)   
			WHERE (u.BAJA=0 AND u.EMAIL IS NOT NULL) 
			and ((t.OPCIONES &amp; POWER(2,0))/POWER(2,0)) = 0 AND
			((dt.OPCIONES &amp; POWER(2,0))/POWER(2,0)) = 0  ORDER BY t.DESCRIPCION,dt.FECHA" groupby="MAP_USUARIO" />
    <errormessage subject="Tareas Pendientes de '##APPNAME##'" 
     body="##NL##PROYECTO: '##ROW_MAP_PROYECTO##'##NL##FECHA INICIO: '##ROW_FECHA##'##NL##FECHA MAXIMA: '##ROW_FECHAINICIO##'##NL##DESCRIPCION: '##ROW_DESCRIPCION##'##NL##----------------------------##NL##" 
     header="Tareas Pendientes de: '##ROW_MAP_LOGIN##'.##NL##*Servidor:##SRVNAME####NL##*Aplicacion: ##APPNAME##.##NL##*Tareas Pendientes: ##ROW_MAP_TOTALTAREAS####NL##----------------------------##NL##----------------------------##NL##" />
    <email to="##ROW_MAP_CORREO##" cc="pepitogrillo@xone.es" />    
    <actions>
      <action name="sendmail" />
    </actions>
  </checking>


It has the recipient of the email (to), the emails we want to add in copy (CC – Carbon Copy) and the ones we want to put as a hidden copy(BCC – Blind Carbon Copy).

The email addresses are specified separated by semicolons. In addition, an SQL statement can be used to rescue email addresses from the database, which must be enclosed in parentheses and can not contain a semicolon inside them. Below are a couple of examples.

  <email to=" " CC=" " BCC=" " />
  <email to="correo@nada.es" CC=" " BCC=" " />
  <email to="correo@nada.es;correo2@nada.es;correo@nada.es" CC=" " BCC=" " />
  <email to="(SELECT email FROM gen_correos)" CC=" " BCC=" " />
  <email to="(SELECT email FROM gen_correos);correo@nada.es;correo2@nada.es" CC=" " BCC=" " />


attach subnode


Within the “email” node there is an “attach” subnode (From the 3.0.4.9 version), to be able to attach files in the email to be sent.

Attribute Description
files Files listing we want to attach to the email separated by “;”. We can put files separated by semicolons or take them from the select we make, by using the macro ##ROW_CAMPOQUESEA##
compress true/false It indicates if we want the files are compressed or not in ZIP, NOTICE: all the files will be compressed in a single one, by default false.
  <email to="##ROW_MAP_CORREO##" cc="" bcc="" >
	<attach files="D:\Descargas\combo-box-hi.png" compress="false" />
  </email>
    <email to="##ROW_CORREO##" cc="" bcc="">
      <attach files="##ROW_FICHEROS_ADJUNTOS##" compress="true" />
    </email>


It has the name of the service we are going to check (value).
The required name is the name of the service installed, not the name to be diplayed. (This option only is used with the checkservice type.)

<service value=" " />



It allows us to specify the table we want to check (value), used with the checktable type.

<table value="gen_usuarios">




To create an PDF type action, it must be create a 'checking' de type=“pdf” and containing besides of the usual nodes (sql, email, actions…) an specific one to generate the PDF, the pdf node that will have all the configuration necessary to create and order the generated files.
All the attributes of the pdf node may have fixed values or captured at the sql through macros.

The macros allowed are:

ALLOWED MACROS
##ROW_XXXX## This macro takes the value of the XXXX field that we rescue at the SQL.
##NOW## This macro is replaced by the current date-time (dd-MM-yyyy_HH-mm-ss).
##DATE## This macro is replaced by the current date (dd-MM-yyyy).



It is appropriate to indicate that if the name of the PDF file is auto generated with the only differentiation between ones and others of the date, it is convenient to use the ##NOW## macro, since:

##DATE## It just would give identical files during the same day.
##NAMEPDF## File name (with no path) of the generated PDF. It can be used to generate a download link.
##SIZEPDF## It indicates the weight in Kbs of the file generated.


As well, are allowed the rest of macros used in another actions (##APPNAME##, ##SRVNAME##…)

Attributes of the Pdf node


In this case the monitor is in charge to set the PDF, based on images, 1 or 2 by page.

The images so that all the margins keep perfects will be:

To get 1 per page, of 538x765px
To get 2 per page, 538x382px


See example of checking pdf below.

pathpdf Mandatory. It indicates the path where the PDF file will be gererated. I.e.: “C:\inetpub\wwwroot\clientes”
pathpages Mandatory. It indicates the path where the images of the PDF will be placed in. I.e.: “C:\inetpub\wwwroot\catalogo\files\”
pages Mandatory. It indicates the name of the image to insert in the PDF. Usually it will be an sql field and will be read from each record of the sql, it must take its extension (.jpg, .png,…). I.e.: “pagina1.jpg”
namepdf Mandatory. Name of the PDF to generate. Usually it will be an sql field or a conjunction of macros. The file name must be unique, IT IS NOT NECESSARTY to put the .pdf extension.
sql Mandatory. It is an sql sent after reading each record. Its utility is send an UPDATE or a DELETE(it is not advisable) to a certain ID, ROWID
mailto Mandatory. Recipient of the pdf.
mailcc Optional. Email copy with the pdf.
mailbcc Optional. Hidden copy of email with the pdf.
mailsubject Optional. Title of the email.
mailbody Optional. Body of the email.
orientation Optional. It indicates the pdf orientation (vertical/horizontal). By default, vertical.
text Optional. It allows to put a text under the image.
attachpdf Optional. It allows to indicate if the PDF is sent or not to the email as attachment (true/false). By default, true.
attachsize Optional. It allows to indicate the maximum size in Bytes to send a file as attachment. Numeric value. If this value is indicated, only will be sent the attached PDF if attachpdf=true and the file occupies less than it is indicated in this value.
<!-- 
	Los checking con type COUNT, CHECKSERVICE, CHECKTABLE y GROUPBY son condicionales
 
	COUNT: 		Se ejecuta si el número devuelto es mayor que el especificado en el atributo count
	CHECKSERVICE:	Se ejecuta si el servicio estuviera detenido.
	CHECKTABLE:	Se ejecuta si la tabla *******
	GROUPBY: 	Se ejecuta y se realiza tantas veces como registros se devuelvan en la consulta.
 
	Si se desea hacer algún mantenimiento que no sea condicional, en lugar de CHECKING, utilizar el nodo MAINTENANCE.
-->
 
<!--	***********************************************************************************
		ALERTA DE MAS DE 10 OPERACIONES EN IQUEUE para un MID
		- Configurar numero de operaciones maximas para lanzar alerta
	***********************************************************************************	-->
<checking name="Comprobar IQUEUE" type="groupby" cron-expression="">
	<sql value="SELECT MID FROM master_replica_iqueue WHERE MID&gt;0 GROUP BY MID HAVING COUNT(ID)&gt;10" groupby="MID" />
	<errormessage subject="XOneMonitor IQUEUE" body="XOneMOnitor XONE" header="Hay mas de 10 operaciones en el IQUEUE para un MID" />
	<email to="quiensea@correo.es" cc="" bcc="" execute-if-error="true"/>
	<actions>
		<action name="sendmail" />
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_iqueue.txt" append="true" />
	</actions>
</checking>
 
<checking name="Comprobar replicador" type="checkservice">
    <service value="CGSRepServer2" />
    <errormessage subject="Error" body="El replicador estaba parado y se ha arrancado."  header="" />
    <email to="aquiencorresponda@elcorreo.es" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
        <action name="sendmail" />
        <action name="startservice" value="CGSRepServer2" />
    </actions>
</checking>
 
<checking name="Comprobar usuarios" type="checktable">
    <table value="gen_usuarios">
    <errormessage subject="Error" body="Se han reparado ##CHECKCOUNT## registros en gen_usuarios"  header="" />
    <email to="aquiencorresponda@elcorreo.es" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
        <action name="sendmail" />
    </actions>
</checking>
 
<checking name="Comprobar tareas" type="groupby">
    <sql value="SELECT u.LOGIN AS MAP_LOGIN,dt.*,dt.DESCRIPCION AS MAP_DESCRIPCION,
    u.EMAIL AS MAP_CORREO,
    dt.IDUSUARIO AS MAP_USUARIO
    FROM (gen_DetTarea dt 
    LEFT OUTER JOIN gen_Tareas t ON dt.IDTAREA=t.ID)
    WHERE t.TERMINADO=0 ORDER BY t.DESCRIPCION,dt.FECHA" groupby="MAP_USUARIO" />	
    <errormessage 	subject="Tareas Pendientes de '##APPNAME##' para '##ROW_MAP_LOGIN##'"
    body="PROYECTO: '##ROW_MAP_PROYECTO##'##NL##FECHA INICIO: '##ROW_FECHA##'##NL##FECHA MAXIMA: '##ROW_FECHAINICIO##'##NL##DESCRIPCION: '##ROW_DESCRIPCION##'##NL##----------------------------##NL##"
    header="Tareas Pendientes.##NL##*Servidor:##SRVNAME####NL##*Aplicacion: ##APPNAME####NL##----------------------------##NL##----------------------------##NL##" />
    <email to="##ROW_MAP_CORREO##" CC="carboncopy@xone.es" BCC="blindcarboncopy@xone.es" />
    <actions>
        <action name="sendmail" />
    </actions>
</checking>
 
<checking name="CopiarFichero" type="filejob" cron-expression="0 0 1 ? * *" >
	<sql value="SELECT ID AS MAP_ID,TAREAID AS MAP_TAREAID,'E:/ReplicaFiles/' || FOTO AS MAP_FILENAMEFROM,
	'E:/XoneUpdates/ReplicaFicheros/filesOLD/' || FOTO AS MAP_FILENAMETO FROM GEN_FOTOSTAREA 
	WHERE RESULTCODE=0 AND NINTENTOS&lt;=6 AND MOVEFILE=0 and to_date(fechar,'DD/MM/YY')&gt;to_date('4/12/13','DD/MM/YY')
	AND FOTO NOT LIKE '%_NOPRESENTA%'" />
		<errormessage subject="se han copiado los archivos." body=""  header="" />
		<email to="aquiensea@correo.es" cc="" bcc="" />
		<actions>	
			<action name="move-file" from="##ROW_MAP_FILENAMEFROM##" to="##ROW_MAP_FILENAMETO##" sql="UPDATE GEN_FOTOSTAREA SET MOVEFILE=1 WHERE ID='##ROW_MAP_ID##'"/>
	</actions>
</checking>
 
<!--	***********************************************************************************
	   MANTENIMIENTO PARA LIMPIAR ACTUALIZACIONES DESCARGADAS
	   - Sustituir rutas de Updates y numeros de licencia
	***********************************************************************************  -->
<maintenance name="Maintenance_Actualizaciones" cron-expression="0 05 3 * * ?">
	<errormessage subject="XOneMonitor XONE. Mantenimiento Actualizaciones" body="Se ha ejecutado correctamente el mantenimiento de limpieza de Actualizaciones descargadas de XONE" header="XOneMonitor XONE" />
	<email to="usuario@sucorreo.es" cc="" bcc="" execute-if-error="true"/>
	<actions>
		<action name="cleanupdates" path="X:\XOneRepository\########" version-folder="Actualizaciones" licenses-folder="Licencias" last-version-file="lastversion" clean-version-folder="true" />
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_Maintenance_Fich.txt" append="true" />
		<action name="sendmail"  />
	</actions>
</maintenance>	
 
<!--	***********************************************************************************
	*** ORACLE ***  
	Este nodo MAINTENANCE, NO es condicional y simplemente se ejecuta cuando lo diga el cron-expression.
	En éste caso, el cron está puesto para que haga todos los días a las 3 am.
	***********************************************************************************  -->
 
<maintenance name="Maintenance" cron-expression="0 0 3 * * ?">
	<errormessage subject="Mantenimiento" body="" header="" />
	<email to="quiensea@correo.es" cc="" bcc="" />
	<actions>
		<action name="stopservice" value="XOneITFBajada" />
		<action name="stopservice" value="XOneITFSubida" />>
		<action name="stopservice" value="XOneProvisioning" />
		<action name="stopservice" value="XOneRepServer" />
		<action name="executequery" value="DELETE FROM adm_xonelive_logs WHERE TIMESTAMP&lt;=TO_CHAR(sysdate - 15,'dd/mm/yyyy hh24:mi:ss')" />
	<action name="executequery" value="DELETE FROM adm_xonelive_errorlog WHERE TIMESTAMP&lt;=TO_CHAR(sysdate - 15,'dd/mm/yyyy hh24:mi:ss')" />
	<action name="executequery" value="DELETE FROM adm_provisioning_task WHERE STATUS=2 AND started&lt;=TO_CHAR(sysdate - 15,'dd/mm/yyyy hh24:mi:ss')" />
	<action name="executequery" value="DELETE FROM adm_provisioning_logs WHERE logcreated&lt;=TO_CHAR(sysdate - 15,'dd/mm/yyyy hh24:mi:ss')" />
	<action name="executequery" value="DELETE FROM MASTER_REPLICA_QUEUE_HISTORY WHERE TIMESTAMP&lt;=TO_CHAR(sysdate - 60,'dd/mm/yyyy hh24:mi:ss')" />
	<action name="executequery" value="INSERT INTO MASTER_REPLICA_QUEUE_HISTORY (CGSROWID,OPERID,TIMESTAMP,OPER,MID,SQL,DMID,IDORIGINAL,TBL) SELECT CGSROWID,OPERID,TIMESTAMP,OPER,MID,SQL,DMID,ID,TBL FROM MASTER_REPLICA_QUEUE WHERE  DMID IS NULL AND id NOT IN (SELECT QID FROM MASTER_REPLICA_SQUEUE) AND ID&lt;(SELECT MIN(LASTCID) FROM MASTER_REPLICA_SLAVE WHERE CONDITIONAL=1 AND PENDIENTE=0)" />
	<action name="executequery" value="DELETE FROM MASTER_REPLICA_QUEUE WHERE DMID IS NULL AND id NOT IN (SELECT QID FROM MASTER_REPLICA_sQUEUE) AND ID&lt;(SELECT MIN(LASTCID) FROM MASTER_rEPLICA_SLAVE WHERE CONDITIONAL=1 AND PENDIENTE=0)" />
	<action name="executequery" value="DELETE FROM MASTER_REPLICA_SQUEUE WHERE MID IN (SELECT S.MID FROM MASTER_REPLICA_SLAVE S WHERE S.PENDIENTE=1)" />
	<action name="executequery" value="DELETE FROM MASTER_REPLICA_SQUEUE WHERE SENT=1" />
	<!--mantenimientos de las tablas -->
	<action name="executequery" value="DELETE from gen_tareas where CGSROWID NOT IN (SELECT CGSROWID FROM MASTER_REPLICA_QUEUE) AND (estado&gt;=5 or estado&lt;0) and fechaverif&lt;=TO_CHAR(sysdate - 60,'dd/mm/yy')" />
	<action name="executequery" value="DELETE from gen_tareasd1 WHERE TAREAID NOT IN (SELECT TAREAID from gen_tareas) AND CGSROWID NOT IN (SELECT CGSROWID FROM MASTER_REPLICA_QUEUE)" />
 
	<action name="cleanupdates" path="C:\XOneRepository\Updates\10000168" version-folder="Actualizaciones" licenses-folder="Licencias" last-version-file="lastversion" clean-version-folder="true" />
	</actions>
</maintenance>
 
<maintenance name="Maintenance3" cron-expression="0 30 3 * * ?">
	<errormessage subject="Mantenimiento INDICES" body="Indices reconstruidos con exito." header="" />
	<email to="aquiensea@correo.es" cc="" bcc="" />
	<actions>
		<action name="executequery" execute-always="true" value="ALTER INDEX IX_GEN_TAREAS_TAREAID REBUILD" />
		<action name="executequery" execute-always="true" value="ALTER INDEX IX_GEN_TAREAS_ROWID REBUILD" />
		<action name="executequery" execute-always="true" value="ALTER INDEX IX_GEN_DANOS_TAREAID REBUILD" />
		<action name="sendmail" />	
	</actions>
</maintenance>
 
<!--	***********************************************************************************
	**** SQL SERVER ***
	   MANTENIMIENTO PARA LIMPIAR TABLAS MASTER_REPLICA
	   - Borrado de tabla master_replica_errorlog
	   - Limpieza de operaciones en master_replica_queue ya descargadas por todos los terminales
	   - Borrado de operaciones en master_replica_squeue de terminales desactivados y terminales que aun no han descargado la instalacion inicial.
	- Desactivacion de terminales con mas de 60 dias sin comunicar.
	***********************************************************************************	-->		
<maintenance name="Mantenimiento_master_replica_" cron-expression="0 05 1 * * ?">
	<errormessage subject="XOneMonitor XONE. Mantenimiento tablas master_replica_..." body="Se ha ejecutado correctamente el mantenimiento de las tablas master_replica_... de XONE" header="XOneMonitor XONE" />
	<email to="aquiencorresponda@elcorreo.es" cc="" bcc="" execute-if-error="true"/>
 	<actions>
		<action name="executequery" value="delete from master_replica_errorlog;" />			
		<action name="executequery" value="DELETE FROM MASTER_REPLICA_QUEUE WHERE ID&lt;(SELECT MIN(LASTID) FROM master_replica_slave WHERE PENDIENTE=0 AND SINCRONISMO IS NOT NULL);"/>			
		<action name="executequery" value="DELETE FROM master_replica_squeue WHERE QID NOT IN (SELECT ID FROM master_replica_queue) OR MID IN (SELECT MID FROM master_replica_slave WHERE PENDIENTE=1 OR SINCRONISMO IS NULL);"/>
		<action name="executequery" value="UPDATE MASTER_REPLICA_SLAVE SET PENDIENTE=1 WHERE DATEDIFF(CURDATE(),CONCAT(CONCAT(CONCAT(CONCAT(SUBSTR(SINCRONISMO,7,4),'-'),SUBSTR(SINCRONISMO,4,2)),'-'),SUBSTR(SINCRONISMO,1,2))) &gt;60;"/>
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_Maintenance_queue.txt" append="true" />				
		<action name="sendmail"  />
	</actions>
</maintenance>	
 
<!--	***********************************************************************************
	*** MYSQL ***
	   MANTENIMIENTO PARA LIMPIAR TABLAS MASTER_REPLICA
	   - Borrado de tabla master_replica_errorlog
	   - Limpieza de operaciones en master_replica_queue ya descargadas por todos los terminales
	   - Borrado de operaciones en master_replica_squeue de terminales desactivados y terminales que aun no han descargado la instalacion inicial
	- Desactivacion de terminales con mas de 60 dias sin comunicar
	***********************************************************************************  -->		
<maintenance name="Mantenimiento_master_replica_" cron-expression="0 05 1 * * ?">
	<errormessage subject="XOneMonitor XONE. Mantenimiento tablas master_replica_..." body="Se ha ejecutado correctamente el mantenimiento de las tablas master_replica_... de XONE" header="XOneMonitor XONE" />
	<email to="aquiencorresponda@elcorreo.es" cc="" bcc="" execute-if-error="true"/>
 	<actions>
		<action name="executequery" value="delete from master_replica_errorlog;" />			
		<action name="executequery" value="DELETE FROM MASTER_REPLICA_QUEUE WHERE ID&lt;(SELECT MIN(LASTID) FROM master_replica_slave WHERE PENDIENTE=0 AND SINCRONISMO IS NOT NULL);"/>			
			<action name="executequery" value="DELETE FROM master_replica_squeue WHERE QID NOT IN (SELECT ID FROM master_replica_queue) OR MID IN (SELECT MID FROM master_replica_slave WHERE PENDIENTE=1 OR SINCRONISMO IS NULL);"/>
		<action name="executequery" value="UPDATE MASTER_REPLICA_SLAVE SET PENDIENTE=1 WHERE DATEDIFF(CURDATE(),CONCAT(CONCAT(CONCAT(CONCAT(SUBSTR(SINCRONISMO,7,4),'-'),SUBSTR(SINCRONISMO,4,2)),'-'),SUBSTR(SINCRONISMO,1,2))) &gt;60;"/>
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_Maintenance_queue.txt" append="true" />				
		<action name="sendmail"  />
	</actions>
</maintenance>	
 
<!-- 	***********************************************************************************
	   ALERTA DE errores en ERRORLOG
	   - Ajustar numero de operaciones para alerta y Warnings que se quieran descargar del aviso
	***********************************************************************************  -->
<checking name="errorlog" type="count" cron-expression="">
	<sql value="SELECT count(ID) FROM master_replica_errorlog WHERE DESCRIPTION  DESCRIPTION NOT LIKE '%already%' " count="4" />		
	<errormessage subject="XOneMonitor XONE Errorlog" body="-"  header="Hay errores en el errorlog. Revisar el servidor." />		
	<email to="quiensea@correo.es" cc="" bcc="" execute-if-error="true"/>
	<actions>
		<action name="sendmail"  />
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_errorlog.txt" append="true" />
	</actions>
</checking>	
 
<!-- 	***********************************************************************************
	   Generación de PDF
	   En este caso el monitor se encarga de montar el PDF, basado en imágenes, 1 por página
	   pathpdf:	Ruta donde va a dejar el fichero generado en el servidor.
	   pathpages:	Ruta de las imágenes que van a formar el pdf. P.ej: C:\inetpub\wwwroot\catalogo\files\
	   pages:		Nombre de la imagen con su extensión. P.Ej: pagina1.jpg
	   namepdf:	Nombre final del fichero pdf.
	   orientation:	Por defecto vertical, puede ser también horizontal.
	   attachpdf:	true para que intente adjuntar el pdf al correo que se envía, se combina con el atributo attachsize.
	   attachsize:	Tamaño en bytes máximo para adjuntar el fichero al correo, si supera ésta cantidad, el fichero se genera en
			una carpeta accesible del servidor y se pone el enlace a la dirección del fichero pdf generado en el correo que se envía.
	   text:		En el pie de página se puede poner un texto, aquí es donde se define.
	   Nota: Las imágenes para que todos los márgenes aparezcan perfectas con los márgenes correspondientes serán: 
	         Para que salga 1 por pagina, de 538x765px, para que salgan 2 por pagina, 538x382px. 
	***********************************************************************************  -->
 
<checking name="CrearPDF" type="pdf" >
	<sql value="SELECT SENDID, ROWID,STRPRECIO, 'PruebaPDF' AS MAP_NAME,IMGNAME,NOMFOTO AS MAP_PAGES, EMAIL1 AS MAP_CORREO, EMAIL2 AS MAP_COPIA FROM view_clientescatalogosend" />
	<pdf pathpdf="C:\inetpub\wwwroot\clientes" 
	pathpages="##ROW_MAP_PAGES##" 
	pages="##ROW_IMGNAME##" 
	namepdf="##ROW_MAP_NAME##-##NOW##" 
	orientation="vertical"
	attachpdf="true"
	attachsize="2050"
	text="##ROW_STRPRECIO##"
	sql="UPDATE gen_clientescatalogosend SET ACTUALIZADO=10 WHERE ID=##ROW_SENDID##"
	mailto="##ROW_MAP_CORREO##" 
	mailcc="##ROW_MAP_COPIA##" mailbcc="" 
	mailsubject="Envío de catálogo adjunto PDF" 
	mailbody="PDF creado automáticamente para envío del Catálogo de Productos. Si no puede ver bien el fichero adjunto, acceda a la direccion  http://www.direccionweb.com/clientes/##NAMEPDF##"/>
	<errormessage subject="Error generando el catalogo" body="No se pudo crear pdf"  header="" />
	<email to="elquesea@sucorreo.es" cc="" bcc="" />
	<actions>
		<action name="sendmail" execute-always="true"/>
		<action name="executequery" execute-if-error="true" value="UPDATE gen_clientescatalogosend SET ACTUALIZADO=998,FECHAENVIO=GETDATE() WHERE ID=##ROW_SENDID##" />
		<action name="executequery" value="UPDATE gen_clientescatalogosend SET ACTUALIZADO=100,FECHAENVIO=GETDATE()  WHERE ID=##ROW_SENDID##" />
	</actions>
</checking>
 
<checking name="Notificar Error" type="groupby" cron-expression="0 0 8 ? * *">
	<sql value="SELECT ID AS SENDID,EMAIL1 AS MAP_CORREO, EMAIL2 AS MAP_COPIA FROM gen_clientescatalogosend WHERE ACTUALIZADO=998" groupby="SENDID" />
	<errormessage subject="Error generando el catalogo" body="No se pudo crear pdf ##ROW_SENDID## para ##ROW_MAP_CORREO## y ##ROW_MAP_COPIA##"  header=""/>
	<email to="quiensea@sucorreo.com" cc="" bcc="" />
	<actions>			
		<action name="sendmail" />
		<action name="executequery" value="UPDATE gen_clientescatalogosend SET ACTUALIZADO=999,FECHANOTIF=GETDATE()  WHERE ID=##ROW_SENDID##" />
	</actions>
</checking>
 
<!--	***********************************************************************************
	   ALERTA DE REPLICADOR DETENIDO
	***********************************************************************************   -->
<checking name="Comprobar replicador" type="checkservice" cron-expression="">
	<service value="CGSRepServer2" />
	<errormessage subject="XOneMonitor XONE CGSRepServer" body="El replicador estaba parado y se ha arrancado."  header="XOneMonitor XONE" />		
	<email to="aquiencorresponda@elcorreo.es" cc="" bcc=""  execute-if-error="true"/>
	<actions>
		<action name="sendmail"   />
		<action name="startservice" value="CGSRepServer2" />
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_replicator.txt" append="true" />
	</actions>
</checking>
 
 
<!--	***********************************************************************************
	   ALERTA DE PROVISIONING DETENIDO
	***********************************************************************************   -->
 
<checking name="Comprobar provisioning" type="checkservice" cron-expression="">
	<service value="XOneProvisioningService"/>
	<errormessage subject="XOneMonitor XONE Provisioning detenido" body="El Servicio XOneProvisioning esta detenido" header="XOneMonitor XONE" />		
	<email to="aquiencorresponda@elcorreo.es" cc="" bcc=""  execute-if-error="true"/>
	<actions>
		<action name="sendmail"  />
		<action name="startservice" value="XOneProvisioningService" />
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_Provisioning.txt" append="true" />
	</actions>
</checking>
 
 
<!--	***********************************************************************************
	   ALERTA DE INTEGRACION DETENIDO
	***********************************************************************************   -->
 
<checking name="Comprobar Integracion" type="checkservice" cron-expression="">
	<service value="Xone ITF Advanced" />
	<errormessage subject="XOneMonitor XONE Integracion detenida" body="El Servicio Xone ITF Advanced esta detenido" header="XOneMonitor XONE" />		
	<email to="aquiencorresponda@elcorreo.es" cc="" bcc=""  execute-if-error="true"/>
	<actions>
		<action name="sendmail"   />
		<action name="startservice" value="Xone ITF Advanced" />
		<action name="savetofile" value="X:\Logs\XOneMonitor\XOneMonitor_Integracion.txt" append="true" />
	</actions>
</checking>