martes, 27 de febrero de 2018

WINDOWS. PS. NAGIOS. Check my remote Nagios server

To verify my Nagios Sever I need monitoring it from other server. With this script you can monitoring any server (external or internal)

The result will be send one email and write one event.

For this task I have created this script:

=========================================

$pingCount = 3
#Server Nagios
$server = '10.10.10.10'
# La siguiente linea solo hay que ejecutarla la primera vez
# New-EventLog –LogName Application –Source “MyMonitoringSystem”

$pingStatus = Test-Connection $server -Count $pingCount -ErrorAction SilentlyContinue

$pingsLost = $pingCount - ($pingStatus).Count

if ($pingsLost -eq $pingCount) 
{
  #Write one event to eventviwer
  Write-EventLog -LogName Application -Source "MyMonitoringSystem" -EntryType Error -EventId 001 -Message "El servidor Nagios no responde"

 #Send one email to inform
 $PSEmailServer = "10.10.10.99"
 Send-MailMessage -From "MyServer@MyDom.com" -To "infrastructure@mycompany.es" -Subject " !!NAGIOS DOWN!!! ** Moritorizacion parada **   --ALERTA--" -Body "Se ha perdido el ping contra el servidor XXXXXXXX"

}


=========================================

I have been scheduler this task to execute each minute





To check the event: 



Check at Windows 2012
by GoN | Published: February 27, 2018 | Last Updated:

viernes, 23 de febrero de 2018

LINUX. HowTo attribute execute file

To assign the execution attribute to a file:

Command: chmod +x




Sometimes is necessary change the owner of the file to can execute it, for this task:

Command: chown user:group



by GoN | Published: February 23, 2018 | Last Updated:

miércoles, 21 de febrero de 2018