nagios监控ipsec运行情况、防火墙、sqlserver镜像

公司机房安全问题运用了安全策略,但是老被人停来停去的,特写脚本添加到nagios监控里了

-------------------------------------------------

@netsh ipsec static show policy service |find "已分配" |find "否" >nul 2>nul
@if %ERRORLEVEL% == 0 (
@echo Ipsec Critical - Ipsec is close !!!
@exit 2) else (
@echo ipsec OK - ipsec is open !
@exit 0)
@pause

 

 

被监控端编辑

C:\Program Files\NSClient++\NSC.ini

[External Scripts]
check_ipsec=scripts\check_ipsec.bat

 

------------------------------------------------------------------------------------------------

C:\>netsh firewall show state | find "操作模式"
操作模式                          = 禁用

C:\>netsh firewall show state | find "操作模式" |find "禁用" >nul 2>nul

C:\>echo %ERRORLEVEL%
0

C:\>netsh firewall show state | find "操作模式" |find "启用" >nul 2>nul

C:\>echo %ERRORLEVEL%
1

C:\>

 

 

-------------------------------------------------------------------------

监控sqlserver数据库镜像运行情况

@sqlcmd  -d master -t 3 -W  -Q "select count(*) from sys.database_mirroring where mirroring_role=2 and mirroring_state<>4" | findstr "^[1-9]" >nul 2>nul
@if %ERRORLEVEL% == 1 (
@echo mirror OK - mirror is ok !
@exit 0) else (
@echo mirror Critical - mirror have a error!!!
@exit 2)
@pause

 --------------------------

nagios服务端

[root@localhost libexec]# ./check_nrpe -H xx.xx.xx.xx -p 5666 -t 5 -c check_mirror
mirror OK - mirror is ok !
[root@localhost libexec]# ./check_nrpe -H xx.xx.xx.xx -p 5666 -t 5 -c check_mirror

C:\Program Files\NSClient++>else (
'else' 2??ě2??22?????е???′|-??mirror Critica   ------------脚本那个else不能换行
[root@localhost libexec]# ./check_nrpe -H xx.xx.xx.xx -p 5666 -t 5 -c check_mirror
mirror Critical - mirror have a error!!!

 -------------------------------------------------------------

监控job

@sqlcmd  -S .\sql2005 -d master -t 3 -W  -Q "select count(*) from msdb.dbo.sysjobservers,msdb.dbo.sysjobs_view where msdb.dbo.sysjobs_view.job_id=msdb.dbo.sysjobservers.job_id and msdb.dbo.sysjobs_view.enabled =1 and msdb.dbo.sysjobservers.last_run_outcome=0" | findstr "^[1-9]" >nul 2>nul
@if %ERRORLEVEL% == 1 (
@echo JOB IS OK - job is ok !
@exit 0) else (
@echo JOB Critical - JOB have a error!!!
@exit 2)
@pause

 

------------------------------------------------------------------------------------

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值