{{indexmenu_n>1}} ====== XOneMonitor ====== \\ ===== Introduction ===== \\ \\ 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.| | ...| ===== Configuration File ===== \\ 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. | ===== Structure===== \\ Our XML file will have an 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. | ==== Types of Checkings (checking) ==== \\ 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: ^ 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. | ===== Actions ===== \\ 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). \\ ==== sendmail ==== \\ It sends an email with the data from the **email and errormessage** nodes. \\ 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. ====startservice==== \\ 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. \\ ====stopservice==== \\ 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. \\ \\ ====restartservice==== \\ 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. \\ \\ ====savetofile==== \\ 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. \\ ====move-file==== \\ 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. \\ ===== Macros ===== \\ ^ 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 | ===== Nodes ===== \\ 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** | \\ ==== SQL node ==== \\ 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. \\ ==== errormessage node ==== \\ 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. 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: \\ ==== email node ==== \\ 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.\\ \\ === 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. | ==== service node ==== \\ 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.) \\ ==== table node ==== \\ It allows us to specify the table we want to check (__value__), used with the //checktable// type.
\\ \\ ==== pdf node ==== \\ 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. | ===== Example of use=====
>