Powershell + Nagios monitors VEEAM backup status

Source: Internet
Author: User

Beans are usually used to monitor the state of the system with Nagios. The usual company uses Veeam to manage backup and restore of files, and the results of backups are usually sent to beans via email. On a whim today, I want to show the status of this backup in Nagios's monitoring interface.


Because Veeam itself provides modules for PowerShell, beans can invoke custom PowerShell scripts through the nsclient++ client for monitoring purposes.


1) Custom PowerShell script Veeam_backup.ps1, the script is simple and returns different exit values based on different results.


The definition in Nagios is

    • 0-ok

    • 1-warning

    • 2-critial

    • 3-unknow


Param (    # Param1 help description    [string]      $name) add-pssnapin -name veeampssnapin -erroraction  Silentlycontinuedisconnect-vbrserverconnect-vbrserver -server drvbr01 -user omnicom\ yuan.li -password goat201510$job = get-vbrjob -name  $name $name =  "'"  +  $name  +  "'" if  ($job  -eq  $null) {write-host  "unknown! no  such a job:  $name. " EXIT 3} $status  =  $job. Getlastresult () if ($ ($job. Findlastsession ()). state -eq  "Working") {write-host  "ok - job:  $name  is currently in  progress. " exit 0}if  ($status  -eq  "Failed") {write-host  "critical! errors were  encountered during the backup process of the following job:  $name ." Exit 2}if ($status  -eq  "Success") {     $lastrun = $job .scheduleoptions.latestrunlocal     write-host  "ok - job:  $name  was completed succesfully,  lastrun finished at  $lastrun       exit 0}if  ($status  - ne  "Success") {     $statusWrite-host  "warning! job  $name  didn ' t  fully succeed. " EXIT 1}


Execute Look, Success!

PS c:\windows\system32> C:\veeam_backup.ps1-name "Finance servers-backup" ok-job: ' Finance servers-backup ' was Co mpleted succesfully, Lastrun finished at 11/12/2017 23:30:00


2) The second step is to modify the configuration file of our nsclient++ Nsclient.ini this place make sure the format is correct or Nagios does not recognize external commands that we write ourselves.


Nisclient.ini configuration file key configuration is as follows


[/settings/nrpe/server] verify mode = noneinsecure = trueextended response  = 0allow arguments = trueallow nasty characters = true[/modules]  CheckHelpers = 1CheckNSCP = 1CheckDisk = 1CheckSystem =  1nsclientserver = 1checkeventlog = 1nscaclient = 1nrpeserver =  enabledcheckexternalscripts = enabled[/settings/nrpe/server] verify mode =  Noneinsecure = trueport = 9999extended response = 0allow arguments  = trueallow nasty characters = true[/settings/external scripts] allow  arguments = true[/settings/external scripts/scripts]financejob = cmd /c  echo c:\\veeam_backup.ps1  $ARG 1$; exit ($lastexitcode)  | powershell.exe - command -

After the modification is complete, after restarting the NSCP service, log in to the Nagios server in SSH to test whether the command recognizes

[Email protected] libexec]#/check_nrpe-h drvbr01-c financejob-a "Finance servers-backup" ok-job: ' Finance Servers -Backup ' was completed succesfully, Lastrun finished at 11/12/2017 23:30:00



3) Configure Nagios's command.cfg, Host.cfg and Service.cfg


Define command {   command_name  check_veeamjob   command_ line   $USER 1$/check_nrpe -h  $HOSTADDRESS $ -p 5666 -c  $ARG 1$ -a   $ARG 2$}define host{        use              windows-server  ;          host_name       DRVBR01 ;         alias            drvbr01    ;         address          10.9.1.74       ;         parents         syd3750colo          }         define service{         use                      generic-service         host_name                DRVBR01        servicegroups            windows-services        service_ description     veeam replication job - finance         check_command            check_veeamjob!financejob! ' Finance servers - replication '         }


4) Testing

Restart the Nagios service and then see the results on the page.

650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/13/881f6f4d6ea5332ab370c3aee93e0ab2.png "style=" float: none; "title=" 2.PNG "alt=" 881f6f4d6ea5332ab370c3aee93e0ab2.png "/>


Results consistent with Veeam management interface


650) this.width=650; "src=" Https://s2.51cto.com/oss/201711/13/69a3a1050c95df7e7bb33fc861a6b9b0.png "style=" float: none; "title=" 3.PNG "alt=" 69a3a1050c95df7e7bb33fc861a6b9b0.png "/>


This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1981136

Powershell + Nagios monitors VEEAM backup status

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.