Converted from local repo

2021
Eric Loyd 6 years ago
parent 41ae300c01
commit b5cc0cac3f

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,163 @@
define contactgroup {
contactgroup_name delladmins
alias Nagios Administrators
members ESS Page, ESS UNIX List
}
define contactgroup {
contactgroup_name DBA Page
alias DBA Page and email
members Audrey Wright, Sergey Guberman, Chris Stewart, Ron Gittleman, Todd Whitaker, Debby Becker, Krish Anugula, Paul Beaulieu
}
define contactgroup {
contactgroup_name DBA Page CRITICAL
alias DBA Page on CRITICAL
members Audrey Wright CRITICAL, Sergey Guberman CRITICAL, Chris Stewart CRITICAL, Ron Gittleman CRITICAL, Todd Whitaker CRITICAL, Debby Becker CRITICAL, DBA Important List, Krish Anugula CRITICAL, Paul Beaulieu CRITICAL
}
define contactgroup {
contactgroup_name dummy
alias Dummy contact group -- does nothing
members dummy
}
define contactgroup {
contactgroup_name nobody
alias Noone - does nothing
members nobody
}
define contactgroup {
contactgroup_name CISDR
alias CISDR (former CSG) members
members clk, dbashore, jsophy, jwagner, ratliff, stevea, monikam
}
define contactgroup {
contactgroup_name CISDR on call
alias CISDR members on call
members clk, dbashore, jsophy, jwagner, ratliff, stevea
}
define contactgroup {
contactgroup_name ESS_8x5
alias ESS page 8x5, and email rest of the time
members ESS_outside_8x5, ESS_8x5
}
define contactgroup {
contactgroup_name GUI Admins
alias Nagios GUI Administrators Authorization
members anykey, bhaines, bts, bigmac, chief53, coto, drevil, drinker, dw10, eburd, hajar, hajarn, irwin, ists, jfitz, jkaram, jmkcsg, jsotoj
}
define contactgroup {
contactgroup_name GUI Operators
alias Naemon GUI Operators Authorization
members bstango, chris, ck, clk, clu, cs2, dbashore, dchin, duvergem, igubenko, jasonrap, jf19, jlf, jsophy, jwagner, kgift, kh6, llong, martin, monikam, moraski2, ndelo, ranugula, riverhi21, ryangm, sergeyg, shorey, simonlee, skampel, steven, willman
}
define contactgroup {
contactgroup_name GUI Help Desk
alias Auth users for Help Desk VI/SOC
members ohd-vi002, ohd-vi003, ohd-vi004, ohd-vi005, ohd-vi006, ohd-vi007, ohd-vi008, ohd-vi009, ohd-vi010, ohd-vi011, ohd-vi012, ohd-vi013, ohd-vi015, ohd-vi016, ohd-vi017, ohd-vi019
}
define contactgroup {
contactgroup_name IAM
alias Identity Management
members jasonrap, kbmartin, simonlee, willman
}
define contactgroup {
contactgroup_name Maximo
alias Maximo Support
members Michael Zhong, Quoc B. Nguyen
}
define contactgroup {
contactgroup_name Maximo Pagers
alias Maximo Support via SMS
members Michael Zhong Cell, Quoc B. Nguyen Cell
}
define contactgroup {
contactgroup_name Monitoring Admins
alias Nagios Administrators
members Erick W. Burd, Igor Yahoo, Igor V. Gubenko, Joseph M. Karam
}
define contactgroup {
contactgroup_name Monitoring Admins Pager
alias Nagios Administrators
members Igor Pager, Igor Pager External, Joseph Karam Pager, Joseph Karam Pager External
}
define contactgroup {
contactgroup_name Networking Pager
alias Text all members of the Network n Monitoring group
members David Rinker Pager, Hajar Pager, Igor Pager, Irwin Pager, Joseph Karam Pager
}
define contactgroup {
contactgroup_name nagiosadmin
alias Linux Administrators
members nagiosadmin
}
define contactgroup {
contactgroup_name OAS
alias OAS folks
members Brian Long, Natasha Metelitsa, RN Admin, Salvatore Urso
}
define contactgroup {
contactgroup_name OnBase
alias OnBase people
members Devaki Ginde, Elizabeth Parham, Robert Tengowski, Terrence M. Lam, Vito Badalamenti, OnBase Admin, OnBase UA Support
}
define contactgroup {
contactgroup_name pu_default
alias pu_default
members pu_default
}
define contactgroup {
contactgroup_name OIT-Support-Services
alias OIT Support Services (SS Machines)
members Phillip M. Immordino, Thomas J. Francais, Jesse Barron
}
define contactgroup {
contactgroup_name SOC
alias SOC
members Andre D. Corbitt, Brian A. Ariza, Brian T. Burgher, Bradley A. Wells, Donald Ade, Dominique N. Davis, Eric J. Swingle, Jeffrey Kontio, Jacob Swimmer, John J. Zerillo, Raymund Roco, Thomas J. Byrne, Terence Tung, William V. Brown Jr., Zachary M. Barton
# members acorbitt, bariza, bburgher, bwells, dade, dd7, dplante, eswingle, jkontio, jswimmer, jzerillo, mariannm, rroco, tbyrne, ttung, wb, zbarton
}
define contactgroup {
contactgroup_name TSM
alias TSM (Martin, Maureen)
members Martin_Harriss, Maureen E. OConnor
}
define contactgroup {
contactgroup_name TSM Page
alias TSM Page (Martin, Maureen)
members Dan Chin Pager, Martin Pager, Maureen E. OConnor Pager
}
define contactgroup {
contactgroup_name UHS
alias UHS server team
members UHS Server Team, Kevin E. Leighton Pager
}
define contactgroup {
contactgroup_name WWS
alias Woodrow Wilson School (Catherine Cuff, Keith Moulton)
members Catherine Cuff, Catherine Cuff Pager, Keith Moulton, Keith Moulton Pager, WWS Help List
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,48 @@
define hostdependency {
dependent_hostgroup_name NS PrivateDMZ
host_name Gearman NS PrivateDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name NS PublicDMZ
host_name Gearman NS PublicDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name NS Trust
host_name Gearman NS Trust
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name NS Untrust, NS Restricted
host_name Gearman NS Untrust
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 PrivateDMZ
host_name Gearman 151 PrivateDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 PublicDMZ
host_name Gearman 151 PublicDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 Trust
host_name Gearman 151 Trust
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 Untrust, 151 Restricted, Clusters, CISDR, Email, ESX, F5 Load Balancers, Firewalls, Kaltura Live, KMA, Net, Netmgmt, IAM, SharePoint, Solaris, TSM, Webcheck, Webcheck_csg, Webcheck_Roxen
host_name Gearman 151 Untrust
notification_failure_criteria d
}

@ -0,0 +1,122 @@
define hostescalation {
use Prod 8x5 escalation
hostgroup_name Prod 8x5 Linux, Prod 8x5 Windows
contact_groups ESS_8x5
}
define hostescalation {
use Prod outside 8x5 escalation
hostgroup_name Prod 8x5 Linux, Prod 8x5 Windows
contact_groups ESS_8x5
}
define hostescalation {
use Delay Dev
hostgroup_name Linux Dev/QA, !Oracle Exadata Dev/QA
contacts ESS UNIX List
}
define hostescalation {
use Delay Dev
hostgroup_name Oracle Exadata Dev/QA
contact_groups DBA Page
}
define hostescalation {
use Delay Dev
escalation_period 8x5
hostgroup_name Windows Dev/QA
contacts ESS Windows List
}
define hostescalation {
use Delay Production
hostgroup_name DBA Windows Prod, DBA UNIX Prod, Solaris, Linux Prod, Windows Prod, ESX, !Oracle Exadata, !TSM Production, !Prod 8x5 Linux, !Prod 8x5 Windows
contacts ESS Page
}
define hostescalation {
use Delay Exadata Production
hostgroup_name Oracle Exadata
contact_groups DBA Page
}
define hostescalation {
use Delay Production
hostgroup_name TSM Production
contact_groups TSM, TSM Page
}
define hostescalation {
use host_notify_once
hostgroup_name Netmgmt
contacts ESS Ops
}
define hostescalation {
use host_notify_once
hostgroup_name Netmgmt
escalation_options r
contacts ESS UNIX List
}
define hostescalation {
name Prod 8x5 escalation
first_notification 2
last_notification 24
notification_interval 360
escalation_period 8x5
escalation_options r,d,u
register 0
}
define hostescalation {
name Prod outside 8x5 escalation
first_notification 2
last_notification 24
notification_interval 360
escalation_period Outside 8x5
escalation_options r,d,u
register 0
}
define hostescalation {
name Delay Dev
first_notification 1
last_notification 30
notification_interval 1440
escalation_period 24x7
escalation_options r,d
register 0
}
define hostescalation {
name Delay Production
first_notification 2
last_notification 6
notification_interval 360
escalation_period 24x7
escalation_options r,d,u
register 0
}
define hostescalation {
name Delay Exadata Production
first_notification 1
last_notification 6
notification_interval 360
escalation_period 24x7
escalation_options r,d,u
register 0
}
define hostescalation {
name host_notify_once
first_notification 1
last_notification 1
notification_interval 0
escalation_period 24x7
escalation_options d,u
register 0
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,163 @@
define contactgroup {
contactgroup_name delladmins
alias Nagios Administrators
members ESS Page, ESS UNIX List
}
define contactgroup {
contactgroup_name DBA Page
alias DBA Page and email
members Audrey Wright, Sergey Guberman, Chris Stewart, Ron Gittleman, Todd Whitaker, Debby Becker, Krish Anugula, Paul Beaulieu
}
define contactgroup {
contactgroup_name DBA Page CRITICAL
alias DBA Page on CRITICAL
members Audrey Wright CRITICAL, Sergey Guberman CRITICAL, Chris Stewart CRITICAL, Ron Gittleman CRITICAL, Todd Whitaker CRITICAL, Debby Becker CRITICAL, DBA Important List, Krish Anugula CRITICAL, Paul Beaulieu CRITICAL
}
define contactgroup {
contactgroup_name dummy
alias Dummy contact group -- does nothing
members dummy
}
define contactgroup {
contactgroup_name nobody
alias Noone - does nothing
members nobody
}
define contactgroup {
contactgroup_name CISDR
alias CISDR (former CSG) members
members clk, dbashore, jsophy, jwagner, ratliff, stevea, monikam
}
define contactgroup {
contactgroup_name CISDR on call
alias CISDR members on call
members clk, dbashore, jsophy, jwagner, ratliff, stevea
}
define contactgroup {
contactgroup_name ESS_8x5
alias ESS page 8x5, and email rest of the time
members ESS_outside_8x5, ESS_8x5
}
define contactgroup {
contactgroup_name GUI Admins
alias Nagios GUI Administrators Authorization
members anykey, bhaines, bts, bigmac, chief53, coto, drevil, drinker, dw10, eburd, hajar, hajarn, irwin, ists, jfitz, jkaram, jmkcsg, jsotoj
}
define contactgroup {
contactgroup_name GUI Operators
alias Naemon GUI Operators Authorization
members bstango, chris, ck, clk, clu, cs2, dbashore, dchin, duvergem, igubenko, jasonrap, jf19, jlf, jsophy, jwagner, kgift, kh6, llong, martin, monikam, moraski2, ndelo, ranugula, riverhi21, ryangm, sergeyg, shorey, simonlee, skampel, steven, willman
}
define contactgroup {
contactgroup_name GUI Help Desk
alias Auth users for Help Desk VI/SOC
members ohd-vi002, ohd-vi003, ohd-vi004, ohd-vi005, ohd-vi006, ohd-vi007, ohd-vi008, ohd-vi009, ohd-vi010, ohd-vi011, ohd-vi012, ohd-vi013, ohd-vi015, ohd-vi016, ohd-vi017, ohd-vi019
}
define contactgroup {
contactgroup_name IAM
alias Identity Management
members jasonrap, kbmartin, simonlee, willman
}
define contactgroup {
contactgroup_name Maximo
alias Maximo Support
members Michael Zhong, Quoc B. Nguyen
}
define contactgroup {
contactgroup_name Maximo Pagers
alias Maximo Support via SMS
members Michael Zhong Cell, Quoc B. Nguyen Cell
}
define contactgroup {
contactgroup_name Monitoring Admins
alias Nagios Administrators
members Erick W. Burd, Igor Yahoo, Igor V. Gubenko, Joseph M. Karam
}
define contactgroup {
contactgroup_name Monitoring Admins Pager
alias Nagios Administrators
members Igor Pager, Igor Pager External, Joseph Karam Pager, Joseph Karam Pager External
}
define contactgroup {
contactgroup_name Networking Pager
alias Text all members of the Network n Monitoring group
members David Rinker Pager, Hajar Pager, Igor Pager, Irwin Pager, Joseph Karam Pager
}
define contactgroup {
contactgroup_name nagiosadmin
alias Linux Administrators
members nagiosadmin
}
define contactgroup {
contactgroup_name OAS
alias OAS folks
members Brian Long, Natasha Metelitsa, RN Admin, Salvatore Urso
}
define contactgroup {
contactgroup_name OnBase
alias OnBase people
members Devaki Ginde, Elizabeth Parham, Robert Tengowski, Terrence M. Lam, Vito Badalamenti, OnBase Admin, OnBase UA Support
}
define contactgroup {
contactgroup_name pu_default
alias pu_default
members pu_default
}
define contactgroup {
contactgroup_name OIT-Support-Services
alias OIT Support Services (SS Machines)
members Phillip M. Immordino, Thomas J. Francais, Jesse Barron
}
define contactgroup {
contactgroup_name SOC
alias SOC
members Andre D. Corbitt, Brian A. Ariza, Brian T. Burgher, Bradley A. Wells, Donald Ade, Dominique N. Davis, Eric J. Swingle, Jeffrey Kontio, Jacob Swimmer, John J. Zerillo, Raymund Roco, Thomas J. Byrne, Terence Tung, William V. Brown Jr., Zachary M. Barton
# members acorbitt, bariza, bburgher, bwells, dade, dd7, dplante, eswingle, jkontio, jswimmer, jzerillo, mariannm, rroco, tbyrne, ttung, wb, zbarton
}
define contactgroup {
contactgroup_name TSM
alias TSM (Martin, Maureen)
members Martin_Harriss, Maureen E. OConnor
}
define contactgroup {
contactgroup_name TSM Page
alias TSM Page (Martin, Maureen)
members Dan Chin Pager, Martin Pager, Maureen E. OConnor Pager
}
define contactgroup {
contactgroup_name UHS
alias UHS server team
members UHS Server Team, Kevin E. Leighton Pager
}
define contactgroup {
contactgroup_name WWS
alias Woodrow Wilson School (Catherine Cuff, Keith Moulton)
members Catherine Cuff, Catherine Cuff Pager, Keith Moulton, Keith Moulton Pager, WWS Help List
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,48 @@
define hostdependency {
dependent_hostgroup_name NS PrivateDMZ
host_name Gearman NS PrivateDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name NS PublicDMZ
host_name Gearman NS PublicDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name NS Trust
host_name Gearman NS Trust
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name NS Untrust, NS Restricted
host_name Gearman NS Untrust
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 PrivateDMZ
host_name Gearman 151 PrivateDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 PublicDMZ
host_name Gearman 151 PublicDMZ
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 Trust
host_name Gearman 151 Trust
notification_failure_criteria d
}
define hostdependency {
dependent_hostgroup_name 151 Untrust, 151 Restricted, Clusters, CISDR, Email, ESX, F5 Load Balancers, Firewalls, Kaltura Live, KMA, Net, Netmgmt, IAM, SharePoint, Solaris, TSM, Webcheck, Webcheck_csg, Webcheck_Roxen
host_name Gearman 151 Untrust
notification_failure_criteria d
}

@ -0,0 +1,122 @@
define hostescalation {
use Prod 8x5 escalation
hostgroup_name Prod 8x5 Linux, Prod 8x5 Windows
contact_groups ESS_8x5
}
define hostescalation {
use Prod outside 8x5 escalation
hostgroup_name Prod 8x5 Linux, Prod 8x5 Windows
contact_groups ESS_8x5
}
define hostescalation {
use Delay Dev
hostgroup_name Linux Dev/QA, !Oracle Exadata Dev/QA
contacts ESS UNIX List
}
define hostescalation {
use Delay Dev
hostgroup_name Oracle Exadata Dev/QA
contact_groups DBA Page
}
define hostescalation {
use Delay Dev
escalation_period 8x5
hostgroup_name Windows Dev/QA
contacts ESS Windows List
}
define hostescalation {
use Delay Production
hostgroup_name DBA Windows Prod, DBA UNIX Prod, Solaris, Linux Prod, Windows Prod, ESX, !Oracle Exadata, !TSM Production, !Prod 8x5 Linux, !Prod 8x5 Windows
contacts ESS Page
}
define hostescalation {
use Delay Exadata Production
hostgroup_name Oracle Exadata
contact_groups DBA Page
}
define hostescalation {
use Delay Production
hostgroup_name TSM Production
contact_groups TSM, TSM Page
}
define hostescalation {
use host_notify_once
hostgroup_name Netmgmt
contacts ESS Ops
}
define hostescalation {
use host_notify_once
hostgroup_name Netmgmt
escalation_options r
contacts ESS UNIX List
}
define hostescalation {
name Prod 8x5 escalation
first_notification 2
last_notification 24
notification_interval 360
escalation_period 8x5
escalation_options r,d,u
register 0
}
define hostescalation {
name Prod outside 8x5 escalation
first_notification 2
last_notification 24
notification_interval 360
escalation_period Outside 8x5
escalation_options r,d,u
register 0
}
define hostescalation {
name Delay Dev
first_notification 1
last_notification 30
notification_interval 1440
escalation_period 24x7
escalation_options r,d
register 0
}
define hostescalation {
name Delay Production
first_notification 2
last_notification 6
notification_interval 360
escalation_period 24x7
escalation_options r,d,u
register 0
}
define hostescalation {
name Delay Exadata Production
first_notification 1
last_notification 6
notification_interval 360
escalation_period 24x7
escalation_options r,d,u
register 0
}
define hostescalation {
name host_notify_once
first_notification 1
last_notification 1
notification_interval 0
escalation_period 24x7
escalation_options d,u
register 0
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,200 @@
define servicedependency {
dependent_hostgroup_name NS PrivateDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker NS PrivateDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name NS PublicDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker NS PublicDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name NS Trust
dependent_service_description .*
host_name monitor
service_description Gearman worker NS Trust
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name NS Untrust, NS Restricted
dependent_service_description .*
host_name monitor
service_description Gearman worker NS Untrust
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 PrivateDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 PrivateDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 PublicDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 PublicDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 Trust
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 Trust
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 Untrust, 151 Restricted
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 Untrust
notification_failure_criteria c
}
define servicedependency {
hostgroup_name Windows Prod
dependent_service_description nrpe_win_.*, !nrpe_win_agent_status
use NRPE_Win_Dependency
}
define servicedependency {
hostgroup_name Physical Prod Windows
dependent_service_description snmp_win_.*, !snmp_win_alive
use SNMP_Win_Dependency
}
define servicedependency {
hostgroup_name Windows Dev/QA
dependent_service_description nrpe_wintest_.*, !nrpe_wintest_agent_status
use NRPE_Win_NonProd_Dependency
}
define servicedependency {
hostgroup_name Windows Dev/QA
dependent_service_description snmp_wintest_.*, !snmp_wintest_alive
use SNMP_Win_NonProd_Dependency
}
define servicedependency {
hostgroup_name Linux Prod, Solaris
dependent_service_description nrpe_unix_.*, !nrpe_unix_agent_status
use NRPE_Unix_Dependency
}
define servicedependency {
hostgroup_name Physical Prod Linux
dependent_service_description snmp_unix_.*, !snmp_unix_alive
use SNMP_Unix_Dependency
}
define servicedependency {
hostgroup_name Linux Dev/QA
dependent_service_description nrpe_unixtest_.*, !nrpe_unixtest_agent_status
use NRPE_Unix_NonProd_Dependency
}
define servicedependency {
hostgroup_name Linux Dev/QA, !CPanel Dev/QA, !Linux DevQA - no SNMP
dependent_service_description snmp_unixtest_.*, !snmp_unixtest_alive
use SNMP_Unix_NonProd_Dependency
}
define servicedependency {
dependent_host_name backupvpn
dependent_service_description Comcast
host_name backupvpn
service_description Google through Comcast
notification_failure_criteria c
}
define servicedependency {
dependent_host_name backupvpn
dependent_service_description Verizon
host_name backupvpn
service_description Yahoo through Verizon
notification_failure_criteria c
}
define servicedependency {
name NRPE_Unix_Dependency
service_description nrpe_unix_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name NRPE_Unix_NonProd_Dependency
service_description nrpe_unixtest_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name NRPE_Win_Dependency
service_description nrpe_win_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name NRPE_Win_NonProd_Dependency
service_description nrpe_wintest_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Win_Dependency
service_description snmp_win_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Win_NonProd_Dependency
service_description snmp_wintest_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Unix_Dependency
service_description snmp_unix_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Unix_NonProd_Dependency
service_description snmp_unixtest_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name maestro_carryfwd_dependency
service_description jnextcheck
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}

@ -0,0 +1,84 @@
define serviceescalation {
use service_notify_once
hostgroup_name Netmgmt, !Netmgmt - No SSH
service_description .*
contacts ESS Ops
}
define serviceescalation {
hostgroup_name Netmgmt, !Netmgmt - No SSH
service_description .*
first_notification 1
last_notification 0
notification_interval 0
escalation_period 24x7
escalation_options r
contacts ESS UNIX List
}
define serviceescalation {
host_name monitor
service_description Gearman worker ims.*
first_notification 12
last_notification 14
notification_interval 120
escalation_period 24x7
escalation_options c
contact_groups Monitoring Admins Pager
}
define serviceescalation {
host_name monitor
service_description Gearman worker (151|NS).*
first_notification 3
last_notification 5
notification_interval 60
escalation_period 24x7
escalation_options c
contact_groups Monitoring Admins Pager
}
define serviceescalation {
use service_notify_once
host_name monitor
service_description .*_akam_net
escalation_options w,c,r
contacts Networking
}
define serviceescalation {
hostgroup_name Exchange Mailbox
service_description nrpe_win_agent_status, nrpe_win_Exchange*
escalation_period Exchange MBX busy
first_notification 1
last_notification 3
notification_interval 10
contact_groups dummy
}
define serviceescalation {
hostgroup_name Exchange Mailbox
service_description nrpe_win_agent_status
escalation_period Exchange MBX OK
first_notification 4
contacts ESS Page, ESS Windows List
}
define serviceescalation {
hostgroup_name Exchange Mailbox
service_description nrpe_win_Exchange*
escalation_period Exchange MBX OK
first_notification 4
contacts John P. Sophy
}
define serviceescalation {
name service_notify_once
first_notification 1
last_notification 1
notification_interval 0
escalation_period 24x7
escalation_options w,u,c
register 0
}

@ -0,0 +1,122 @@
define servicegroup {
servicegroup_name SharePoint Dev/QA
alias SharePoint Dev/QA services
members csgspfe100w,nrpe_wintest_service_SharePoint2K10, csgspfe101w,nrpe_wintest_service_SharePoint2K10, csgspapp102w,nrpe_wintest_service_SharePoint2K10, csgspapp103w,nrpe_wintest_service_SharePoint2K10
}
define servicegroup {
servicegroup_name Maestro_DEV
alias Dev Maestro Services and Disk
members ais302l, nrpe_maestro_stdlistsz, ais302l, nrpe_unixtest_disk_app_maestro, ais302l, nrpe_maestro_procs, landrdev, nrpe_maestro_stdlistsz, ais101l, nrpe_maestro_stdlistsz, ais101l, nrpe_maestro_procs, ais101l, nrpe_unixtest_disk_app_maestro
}
define servicegroup {
servicegroup_name Maestro_Prod
alias Maestro Production Services
members ais204l, nrpe_maestro_stdlistsz, ais204l, nrpe_unix_disk_app_maestro, ais204l, nrpe_maestro_procs
}
define servicegroup {
servicegroup_name Maestro_app_services
alias Maestro/TWS application checks
members landr,nrpe_maestro_stdlistsz, landrdev,nrpe_maestro_stdlistsz
}
define servicegroup {
servicegroup_name Monitor
alias All important checks for the monitoring infrastructure
servicegroup_members Monitor Production, Monitor Dev/QA
}
define servicegroup {
servicegroup_name Monitor Production
alias Important checks for the production monitoring infrastructure
members mon204l,Gearman, mon204l,Selenium, mon205l,Gearman, mon205l,Selenium, monitor,Gearman Hub, monitor,Selenium Cluster, monitor,Selenium Hub
}
define servicegroup {
servicegroup_name Monitor Dev/QA
alias Important checks for the devqa monitoring infrastructure
members mon302l,Gearman DevQA, mon302l,Selenium DevQA, mon303l,Gearman DevQA, mon303l,Selenium DevQA, monitor-dev,Gearman DevQA Hub, monitor-dev,Selenium DevQA Cluster, monitor-dev,Selenium DevQA Hub
}
define servicegroup {
servicegroup_name OnBase Development
alias Checks for OnBase Development
members aisob301w,nrpe_wintest_service_W3SVC, aisob302w,nrpe_wintest_service_W3SVC, aisob310w,nrpe_wintest_service_W3SVC, aisob311w,nrpe_wintest_service_W3SVC, aisob315w,nrpe_wintest_service_W3SVC, aisob316w,nrpe_wintest_service_W3SVC, aisob316w,http_OnBase_Hyland, aisob318w,nrpe_wintest_service_W3SVC, aisob302w,nrpe_wintest_service_OnBase_DDS, aisob319w,nrpe_wintest_service_OnBase_DDS, aisob313w,nrpe_wintest_service_SMTP, aisob313w,nrpe_wintest_service_Hyland, aisob318w,nrpe_wintest_service_Hyland_FTS, aisob314w,nrpe_wintest_service_Hyland_Unity, aisob316w,nrpe_wintest_service_BizTalk
}
define servicegroup {
servicegroup_name OnBase QA
alias Checks for OnBase QA
members aisob301tstw,nrpe_wintest_service_W3SVC, aisob302tstw,nrpe_wintest_service_W3SVC, aisob310tstw,nrpe_wintest_service_W3SVC, aisob311tstw,nrpe_wintest_service_W3SVC, aisob315tstw,nrpe_wintest_service_W3SVC, aisob318tstw,nrpe_wintest_service_W3SVC, aisob302tstw,nrpe_wintest_service_OnBase_DDS, aisob319tstw,nrpe_wintest_service_OnBase_DDS, aisob313tstw,nrpe_wintest_service_SMTP, aisob313tstw,nrpe_wintest_service_Hyland, aisob314tstw,nrpe_wintest_service_Hyland_Unity, aisob101w,nrpe_wintest_service_W3SVC, aisob102w,nrpe_wintest_service_W3SVC, aisob110w,nrpe_wintest_service_W3SVC, aisob111w,nrpe_wintest_service_W3SVC, aisob115w,nrpe_wintest_service_W3SVC, aisob118w,nrpe_wintest_service_W3SVC, aisob102w,nrpe_wintest_service_OnBase_DDS, aisob119w,nrpe_wintest_service_OnBase_DDS, aisob113w,nrpe_wintest_service_SMTP, aisob113w,nrpe_wintest_service_Hyland, aisob118w,nrpe_wintest_service_Hyland_FTS, aisob114w,nrpe_wintest_service_Hyland_Unity
}
define servicegroup {
servicegroup_name OnBase Dev/QA
alias Checks for OnBase Dev/QA
servicegroup_members OnBase Development, OnBase QA
}
define servicegroup {
servicegroup_name OnBase Production
alias Checks for OnBase Production
members aisob201w,nrpe_win_service_W3SVC, aisob202w,nrpe_win_service_W3SVC, aisob210w,nrpe_win_service_W3SVC, aisob211w,nrpe_win_service_W3SVC, aisob215w,nrpe_win_service_W3SVC, aisob216w,nrpe_win_service_W3SVC, aisob216w,http_OnBase_Hyland, aisob218w,nrpe_win_service_W3SVC, aisob202w,nrpe_win_service_OnBase_DDS, aisob219w,nrpe_win_service_OnBase_DDS, aisob213w,nrpe_win_service_SMTP, aisob213w,nrpe_win_service_Hyland, aisob218w,nrpe_win_service_Hyland_FTS, aisob214w,nrpe_win_service_Hyland_Unity, aisob216w,nrpe_win_service_BizTalk
}
define servicegroup {
servicegroup_name csg_services
alias imap, smtp, pop3
members lists,SMTP, smtp,SMTP, smtp,SMTPS
}
define servicegroup {
servicegroup_name disk_app_lsscvms_services
alias Drives D - K - Life Safety and Security
members lsscvms207w,nrpe_win_disk_app
}
define servicegroup {
servicegroup_name Webchecks
alias Webchecks to be run locally
members iamcas200w,https_CAS, iamcas201w,https_CAS, iamxythos200l,https_Webspace, iamxythos201l,https_Webspace, sdprsa200l,https_rsa_sc, sdprsa200l,https_rsa_ss, sdprsa201l,https_rsa_sc
}
define servicegroup {
servicegroup_name Local
alias Checks to be run locally
members backupvpn,Comcast, backupvpn,Google through Comcast, backupvpn,Verizon, backupvpn,Yahoo through Verizon, ims204,Naemon Latency, ims205,Naemon Latency, mon204l,Gearman, mon205l,Gearman, mon204l,Selenium, mon205l,Selenium, mon302l,Gearman DevQA, mon303l,Gearman DevQA, mon302l,Selenium DevQA, mon303l,Selenium DevQA, monitor-dev,Gearman DevQA Hub, monitor-dev,Selenium DevQA Hub, x110client01,snmp_unixtest_proc_memory_usage, x110client02,snmp_unixtest_proc_memory_usage, x210client01,snmp_unix_proc_memory_usage, x210client02,snmp_unix_proc_memory_usage
}
define servicegroup {
servicegroup_name Loghost
alias Log checks on eis222l
members .*,nrpe_unix_log_nfs_failure, .*,nrpe_unixtest_log_nfs_failure
}
define servicegroup {
servicegroup_name Network NTP
alias Network and Monitoring NTP services
members alfrente,NTP, alfrente,NTPq, capserver,NTP, capserver,NTPq, cuckoo,NTP, cuckoo,NTPq, four11,NTP, four11,NTPq, iblox1-vrrp,NTP, iblox1-vrrp,NTPq, iblox2-vrrp,NTP, iblox2-vrrp,NTPq, ibddipv6-vrrp,NTP, ibddipv6-vrrp,NTPq, netvclock200l,NTP, netvclock200l,NTPq, oznot,NTP, oznot,NTPq
}
define servicegroup {
servicegroup_name Network Web
alias Network and Monitoring Web checks
members Webcheck_host,https_mrtg_net, Webcheck_host,https_www_net
}
define servicegroup {
servicegroup_name External DNS
alias Backup external DNS servers
members monitor,DNS_a1-158_akam_net, monitor,DNS_a20-65_akam_net, monitor,DNS_a24-66_akam_net, monitor,DNS_a3-67_akam_net, monitor,DNS_a6-64_akam_net, monitor,DNS_a7-65_akam_net, monitor,DNS_auth1_dns_cogentco, monitor,DNS_auth2_dns_cogentco
}
define servicegroup {
servicegroup_name Network and Monitoring
alias Checks for Network and Monitoring group
# servicegroup_members External DNS, Network NTP, Network Web, Solaris DNS
servicegroup_members External DNS, Network NTP, Network Web
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,200 @@
define servicedependency {
dependent_hostgroup_name NS PrivateDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker NS PrivateDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name NS PublicDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker NS PublicDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name NS Trust
dependent_service_description .*
host_name monitor
service_description Gearman worker NS Trust
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name NS Untrust, NS Restricted
dependent_service_description .*
host_name monitor
service_description Gearman worker NS Untrust
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 PrivateDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 PrivateDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 PublicDMZ
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 PublicDMZ
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 Trust
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 Trust
notification_failure_criteria c
}
define servicedependency {
dependent_hostgroup_name 151 Untrust, 151 Restricted
dependent_service_description .*
host_name monitor
service_description Gearman worker 151 Untrust
notification_failure_criteria c
}
define servicedependency {
hostgroup_name Windows Prod
dependent_service_description nrpe_win_.*, !nrpe_win_agent_status
use NRPE_Win_Dependency
}
define servicedependency {
hostgroup_name Physical Prod Windows
dependent_service_description snmp_win_.*, !snmp_win_alive
use SNMP_Win_Dependency
}
define servicedependency {
hostgroup_name Windows Dev/QA
dependent_service_description nrpe_wintest_.*, !nrpe_wintest_agent_status
use NRPE_Win_NonProd_Dependency
}
define servicedependency {
hostgroup_name Windows Dev/QA
dependent_service_description snmp_wintest_.*, !snmp_wintest_alive
use SNMP_Win_NonProd_Dependency
}
define servicedependency {
hostgroup_name Linux Prod, Solaris
dependent_service_description nrpe_unix_.*, !nrpe_unix_agent_status
use NRPE_Unix_Dependency
}
define servicedependency {
hostgroup_name Physical Prod Linux
dependent_service_description snmp_unix_.*, !snmp_unix_alive
use SNMP_Unix_Dependency
}
define servicedependency {
hostgroup_name Linux Dev/QA
dependent_service_description nrpe_unixtest_.*, !nrpe_unixtest_agent_status
use NRPE_Unix_NonProd_Dependency
}
define servicedependency {
hostgroup_name Linux Dev/QA, !CPanel Dev/QA, !Linux DevQA - no SNMP
dependent_service_description snmp_unixtest_.*, !snmp_unixtest_alive
use SNMP_Unix_NonProd_Dependency
}
define servicedependency {
dependent_host_name backupvpn
dependent_service_description Comcast
host_name backupvpn
service_description Google through Comcast
notification_failure_criteria c
}
define servicedependency {
dependent_host_name backupvpn
dependent_service_description Verizon
host_name backupvpn
service_description Yahoo through Verizon
notification_failure_criteria c
}
define servicedependency {
name NRPE_Unix_Dependency
service_description nrpe_unix_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name NRPE_Unix_NonProd_Dependency
service_description nrpe_unixtest_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name NRPE_Win_Dependency
service_description nrpe_win_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name NRPE_Win_NonProd_Dependency
service_description nrpe_wintest_agent_status
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Win_Dependency
service_description snmp_win_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Win_NonProd_Dependency
service_description snmp_wintest_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Unix_Dependency
service_description snmp_unix_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name SNMP_Unix_NonProd_Dependency
service_description snmp_unixtest_alive
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}
define servicedependency {
name maestro_carryfwd_dependency
service_description jnextcheck
execution_failure_criteria w,u,c
notification_failure_criteria w,u,c
register 0
}

@ -0,0 +1,84 @@
define serviceescalation {
use service_notify_once
hostgroup_name Netmgmt, !Netmgmt - No SSH
service_description .*
contacts ESS Ops
}
define serviceescalation {
hostgroup_name Netmgmt, !Netmgmt - No SSH
service_description .*
first_notification 1
last_notification 0
notification_interval 0
escalation_period 24x7
escalation_options r
contacts ESS UNIX List
}
define serviceescalation {
host_name monitor
service_description Gearman worker ims.*
first_notification 12
last_notification 14
notification_interval 120
escalation_period 24x7
escalation_options c
contact_groups Monitoring Admins Pager
}
define serviceescalation {
host_name monitor
service_description Gearman worker (151|NS).*
first_notification 3
last_notification 5
notification_interval 60
escalation_period 24x7
escalation_options c
contact_groups Monitoring Admins Pager
}
define serviceescalation {
use service_notify_once
host_name monitor
service_description .*_akam_net
escalation_options w,c,r
contacts Networking
}
define serviceescalation {
hostgroup_name Exchange Mailbox
service_description nrpe_win_agent_status, nrpe_win_Exchange*
escalation_period Exchange MBX busy
first_notification 1
last_notification 3
notification_interval 10
contact_groups dummy
}
define serviceescalation {
hostgroup_name Exchange Mailbox
service_description nrpe_win_agent_status
escalation_period Exchange MBX OK
first_notification 4
contacts ESS Page, ESS Windows List
}
define serviceescalation {
hostgroup_name Exchange Mailbox
service_description nrpe_win_Exchange*
escalation_period Exchange MBX OK
first_notification 4
contacts John P. Sophy
}
define serviceescalation {
name service_notify_once
first_notification 1
last_notification 1
notification_interval 0
escalation_period 24x7
escalation_options w,u,c
register 0
}

@ -0,0 +1,122 @@
define servicegroup {
servicegroup_name SharePoint Dev/QA
alias SharePoint Dev/QA services
members csgspfe100w,nrpe_wintest_service_SharePoint2K10, csgspfe101w,nrpe_wintest_service_SharePoint2K10, csgspapp102w,nrpe_wintest_service_SharePoint2K10, csgspapp103w,nrpe_wintest_service_SharePoint2K10
}
define servicegroup {
servicegroup_name Maestro_DEV
alias Dev Maestro Services and Disk
members ais302l, nrpe_maestro_stdlistsz, ais302l, nrpe_unixtest_disk_app_maestro, ais302l, nrpe_maestro_procs, landrdev, nrpe_maestro_stdlistsz, ais101l, nrpe_maestro_stdlistsz, ais101l, nrpe_maestro_procs, ais101l, nrpe_unixtest_disk_app_maestro
}
define servicegroup {
servicegroup_name Maestro_Prod
alias Maestro Production Services
members ais204l, nrpe_maestro_stdlistsz, ais204l, nrpe_unix_disk_app_maestro, ais204l, nrpe_maestro_procs
}
define servicegroup {
servicegroup_name Maestro_app_services
alias Maestro/TWS application checks
members landr,nrpe_maestro_stdlistsz, landrdev,nrpe_maestro_stdlistsz
}
define servicegroup {
servicegroup_name Monitor
alias All important checks for the monitoring infrastructure
servicegroup_members Monitor Production, Monitor Dev/QA
}
define servicegroup {
servicegroup_name Monitor Production
alias Important checks for the production monitoring infrastructure
members mon204l,Gearman, mon204l,Selenium, mon205l,Gearman, mon205l,Selenium, monitor,Gearman Hub, monitor,Selenium Cluster, monitor,Selenium Hub
}
define servicegroup {
servicegroup_name Monitor Dev/QA
alias Important checks for the devqa monitoring infrastructure
members mon302l,Gearman DevQA, mon302l,Selenium DevQA, mon303l,Gearman DevQA, mon303l,Selenium DevQA, monitor-dev,Gearman DevQA Hub, monitor-dev,Selenium DevQA Cluster, monitor-dev,Selenium DevQA Hub
}
define servicegroup {
servicegroup_name OnBase Development
alias Checks for OnBase Development
members aisob301w,nrpe_wintest_service_W3SVC, aisob302w,nrpe_wintest_service_W3SVC, aisob310w,nrpe_wintest_service_W3SVC, aisob311w,nrpe_wintest_service_W3SVC, aisob315w,nrpe_wintest_service_W3SVC, aisob316w,nrpe_wintest_service_W3SVC, aisob316w,http_OnBase_Hyland, aisob318w,nrpe_wintest_service_W3SVC, aisob302w,nrpe_wintest_service_OnBase_DDS, aisob319w,nrpe_wintest_service_OnBase_DDS, aisob313w,nrpe_wintest_service_SMTP, aisob313w,nrpe_wintest_service_Hyland, aisob318w,nrpe_wintest_service_Hyland_FTS, aisob314w,nrpe_wintest_service_Hyland_Unity, aisob316w,nrpe_wintest_service_BizTalk
}
define servicegroup {
servicegroup_name OnBase QA
alias Checks for OnBase QA
members aisob301tstw,nrpe_wintest_service_W3SVC, aisob302tstw,nrpe_wintest_service_W3SVC, aisob310tstw,nrpe_wintest_service_W3SVC, aisob311tstw,nrpe_wintest_service_W3SVC, aisob315tstw,nrpe_wintest_service_W3SVC, aisob318tstw,nrpe_wintest_service_W3SVC, aisob302tstw,nrpe_wintest_service_OnBase_DDS, aisob319tstw,nrpe_wintest_service_OnBase_DDS, aisob313tstw,nrpe_wintest_service_SMTP, aisob313tstw,nrpe_wintest_service_Hyland, aisob314tstw,nrpe_wintest_service_Hyland_Unity, aisob101w,nrpe_wintest_service_W3SVC, aisob102w,nrpe_wintest_service_W3SVC, aisob110w,nrpe_wintest_service_W3SVC, aisob111w,nrpe_wintest_service_W3SVC, aisob115w,nrpe_wintest_service_W3SVC, aisob118w,nrpe_wintest_service_W3SVC, aisob102w,nrpe_wintest_service_OnBase_DDS, aisob119w,nrpe_wintest_service_OnBase_DDS, aisob113w,nrpe_wintest_service_SMTP, aisob113w,nrpe_wintest_service_Hyland, aisob118w,nrpe_wintest_service_Hyland_FTS, aisob114w,nrpe_wintest_service_Hyland_Unity
}
define servicegroup {
servicegroup_name OnBase Dev/QA
alias Checks for OnBase Dev/QA
servicegroup_members OnBase Development, OnBase QA
}
define servicegroup {
servicegroup_name OnBase Production
alias Checks for OnBase Production
members aisob201w,nrpe_win_service_W3SVC, aisob202w,nrpe_win_service_W3SVC, aisob210w,nrpe_win_service_W3SVC, aisob211w,nrpe_win_service_W3SVC, aisob215w,nrpe_win_service_W3SVC, aisob216w,nrpe_win_service_W3SVC, aisob216w,http_OnBase_Hyland, aisob218w,nrpe_win_service_W3SVC, aisob202w,nrpe_win_service_OnBase_DDS, aisob219w,nrpe_win_service_OnBase_DDS, aisob213w,nrpe_win_service_SMTP, aisob213w,nrpe_win_service_Hyland, aisob218w,nrpe_win_service_Hyland_FTS, aisob214w,nrpe_win_service_Hyland_Unity, aisob216w,nrpe_win_service_BizTalk
}
define servicegroup {
servicegroup_name csg_services
alias imap, smtp, pop3
members lists,SMTP, smtp,SMTP, smtp,SMTPS
}
define servicegroup {
servicegroup_name disk_app_lsscvms_services
alias Drives D - K - Life Safety and Security
members lsscvms207w,nrpe_win_disk_app
}
define servicegroup {
servicegroup_name Webchecks
alias Webchecks to be run locally
members iamcas200w,https_CAS, iamcas201w,https_CAS, iamxythos200l,https_Webspace, iamxythos201l,https_Webspace, sdprsa200l,https_rsa_sc, sdprsa200l,https_rsa_ss, sdprsa201l,https_rsa_sc
}
define servicegroup {
servicegroup_name Local
alias Checks to be run locally
members backupvpn,Comcast, backupvpn,Google through Comcast, backupvpn,Verizon, backupvpn,Yahoo through Verizon, ims204,Naemon Latency, ims205,Naemon Latency, mon204l,Gearman, mon205l,Gearman, mon204l,Selenium, mon205l,Selenium, mon302l,Gearman DevQA, mon303l,Gearman DevQA, mon302l,Selenium DevQA, mon303l,Selenium DevQA, monitor-dev,Gearman DevQA Hub, monitor-dev,Selenium DevQA Hub, x110client01,snmp_unixtest_proc_memory_usage, x110client02,snmp_unixtest_proc_memory_usage, x210client01,snmp_unix_proc_memory_usage, x210client02,snmp_unix_proc_memory_usage
}
define servicegroup {
servicegroup_name Loghost
alias Log checks on eis222l
members .*,nrpe_unix_log_nfs_failure, .*,nrpe_unixtest_log_nfs_failure
}
define servicegroup {
servicegroup_name Network NTP
alias Network and Monitoring NTP services
members alfrente,NTP, alfrente,NTPq, capserver,NTP, capserver,NTPq, cuckoo,NTP, cuckoo,NTPq, four11,NTP, four11,NTPq, iblox1-vrrp,NTP, iblox1-vrrp,NTPq, iblox2-vrrp,NTP, iblox2-vrrp,NTPq, ibddipv6-vrrp,NTP, ibddipv6-vrrp,NTPq, netvclock200l,NTP, netvclock200l,NTPq, oznot,NTP, oznot,NTPq
}
define servicegroup {
servicegroup_name Network Web
alias Network and Monitoring Web checks
members Webcheck_host,https_mrtg_net, Webcheck_host,https_www_net
}
define servicegroup {
servicegroup_name External DNS
alias Backup external DNS servers
members monitor,DNS_a1-158_akam_net, monitor,DNS_a20-65_akam_net, monitor,DNS_a24-66_akam_net, monitor,DNS_a3-67_akam_net, monitor,DNS_a6-64_akam_net, monitor,DNS_a7-65_akam_net, monitor,DNS_auth1_dns_cogentco, monitor,DNS_auth2_dns_cogentco
}
define servicegroup {
servicegroup_name Network and Monitoring
alias Checks for Network and Monitoring group
# servicegroup_members External DNS, Network NTP, Network Web, Solaris DNS
servicegroup_members External DNS, Network NTP, Network Web
}

@ -0,0 +1,297 @@
define timeperiod {
timeperiod_name Dell-24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
define timeperiod {
timeperiod_name dellworkhours
alias Normal Work Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}
define timeperiod {
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
}
define timeperiod {
timeperiod_name 7x4
alias 7am to 4pm weekdays (Normal ESS work time)
friday 07:00-16:00
wednesday 07:00-16:00
thursday 07:00-16:00
monday 07:00-16:00
tuesday 07:00-16:00
}
define timeperiod {
timeperiod_name 8x5
alias "Normal" Working Hours
friday 08:00-17:00
wednesday 08:00-17:00
thursday 08:00-17:00
monday 08:00-17:00
tuesday 08:00-17:00
}
define timeperiod {
timeperiod_name 9x5
alias Other Working Hours
friday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
monday 09:00-17:00
tuesday 09:00-17:00
}
define timeperiod {
timeperiod_name Dev Dispatcher
alias Dev Dispatcher on dev-webprod off during the summer
september 1 - june 30 / 1 00:00-24:00
}
define timeperiod {
timeperiod_name EGN Dome WWWInterface
alias egn-dome-wwwinterface off during the summer/fall
december 1 - april 20 / 1 00:00-24:00
}
define timeperiod {
timeperiod_name Listserv_hours
alias Hours when Listserv is operational
sunday 00:35-23:45
friday 00:35-23:45
saturday 00:35-23:45
wednesday 00:35-23:45
thursday 00:35-23:45
monday 00:35-23:45
tuesday 00:35-23:45
}
define timeperiod {
timeperiod_name Outside 8x5
alias Offhours 8x5
sunday 00:00-24:00
friday 17:00-24:00,00:00-08:00
saturday 00:00-24:00
wednesday 17:00-24:00,00:00-08:00
thursday 17:00-24:00,00:00-08:00
monday 17:00-24:00,00:00-08:00
tuesday 17:00-24:00,00:00-08:00
}
define timeperiod {
timeperiod_name Except 23:55-6:05
alias Hours except 23:55 to 6:05
sunday 06:05-23:55
friday 06:05-23:55
saturday 06:05-23:55
wednesday 06:05-23:55
thursday 06:05-23:55
monday 06:05-23:55
tuesday 06:05-23:55
}
define timeperiod {
timeperiod_name Except 23:55-3:05
alias Hours except 23:55 to 3:05
sunday 03:05-23:55
friday 03:05-23:55
saturday 03:05-23:55
wednesday 03:05-23:55
thursday 03:05-23:55
monday 03:05-23:55
tuesday 03:05-23:55
}
define timeperiod {
timeperiod_name none
alias No Time Is A Good Time
}
define timeperiod {
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
}
define timeperiod {
timeperiod_name roxen-devedit
alias Daytime hours for Roxen devedit response check
sunday 06:00-21:00
friday 06:00-21:00
saturday 06:00-21:00
wednesday 06:00-21:00
thursday 06:00-21:00
monday 06:00-21:00
tuesday 06:00-21:00
}
define timeperiod {
timeperiod_name score_hours
alias Score: available from 7:30am until 2:00am the following morning
sunday 00:00-02:00,07:30-24:00
friday 00:00-02:00,07:30-24:00
saturday 00:00-02:00,07:30-24:00
wednesday 00:00-02:00,07:30-24:00
thursday 00:00-02:00,07:30-24:00
monday 00:00-02:00,07:30-24:00
tuesday 00:00-02:00,07:30-24:00
}
define timeperiod {
timeperiod_name win_tdpexecc
alias Check for TSM Exchange backup process
friday 10:15-12:00,13:00-17:00
saturday 10:15-12:00,13:00-17:00
wednesday 10:15-12:00,13:00-17:00
thursday 10:15-12:00,13:00-17:00
monday 10:15-12:00,13:00-17:00
tuesday 10:15-12:00,13:00-17:00
}
define timeperiod {
timeperiod_name Except 11:55-12:10
alias Except 11:55pm to 12:10am
friday 00:10-23:55
saturday 00:10-23:55
sunday 00:10-23:55
monday 00:10-23:55
tuesday 00:10-23:55
wednesday 00:10-23:55
thursday 00:10-23:55
}
define timeperiod {
timeperiod_name Except 11:45-12:05
alias Except 11:45pm to 12:05am
friday 00:05-23:45
saturday 00:05-23:45
sunday 00:05-23:45
monday 00:05-23:45
tuesday 00:05-23:45
wednesday 00:05-23:45
thursday 00:05-23:45
}
define timeperiod {
timeperiod_name Except 1-3am
alias Except 1:00am to 3:00am
friday 00:00-01:00,03:00-24:00
saturday 00:00-01:00,03:00-24:00
sunday 00:00-01:00,03:00-24:00
monday 00:00-01:00,03:00-24:00
tuesday 00:00-01:00,03:00-24:00
wednesday 00:00-01:00,03:00-24:00
thursday 00:00-01:00,03:00-24:00
}
define timeperiod {
timeperiod_name Gearman server
alias Gearman server restart
sunday 00:00-00:15
}
define timeperiod {
timeperiod_name Gearman server online
alias Except Gearman server restart
day 1 - -1 00:00-24:00
exclude Gearman server
}
define timeperiod {
timeperiod_name 23:15-23:45 Tue and Fri
alias 11:15pm to 11:45pm Tuesday and Friday
tuesday 23:15-23:45
friday 23:15-23:45
}
define timeperiod {
timeperiod_name Except 23:15-23:45 Tue and Fri
alias All times except 11:15pm to 11:45pm on Tuesday and Friday
day 1 - -1 00:00-24:00
exclude 23:15-23:45 Tue and Fri
}
define timeperiod {
timeperiod_name 4am-9am daily
alias 4am to 9am every day
day 1 - -1 04:00-09:00
}
define timeperiod {
timeperiod_name 9am-4am daily
alias 9am to 4am every day (all times except 4am-9am)
day 1 - -1 00:00-24:00
exclude 4am-9am daily
}
define timeperiod {
timeperiod_name 3am-4am daily
alias 3am to 4am every day
day 1 - -1 03:00-04:00
}
define timeperiod {
timeperiod_name 4am-3am daily
alias 4am to 3am every day (all times except 3am-4am)
day 1 - -1 00:00-24:00
exclude 3am-4am daily
}
define timeperiod {
timeperiod_name 9am-3am daily
alias 9am to 3am every day (all times except 3am-9am)
day 1 - -1 00:00-24:00
exclude 3am-4am daily, 4am-9am daily
}
define timeperiod {
timeperiod_name Exchange MBX busy
alias Exchange Mailbox servers are busy
friday 17:00-24:00
saturday 00:00-24:00
sunday 00:00-24:00
monday 00:00-15:00
}
define timeperiod {
timeperiod_name Exchange MBX OK
alias Exchange Mailbox servers are not busy
friday 00:00-17:00
monday 15:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
}
define timeperiod {
timeperiod_name Exclude Cognos App Server Restart
alias Exclude daily restart time of Cognos App Server
day 1 - -1 05:05-24:00,00:00-04:40
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -0,0 +1,31 @@
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# ails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
all: check_mkevents
check_mkevents: check_mkevents.cc
g++ -O2 -s -o check_mkevents check_mkevents.cc
clean:
rm -f check_mkevents

@ -0,0 +1,284 @@
#!/usr/local/bin/perl
#
# (c)2001 Sebastian Hetze, Linux Information Systems AG
# send bug reports to <S.Hetze@Linux-AG.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# you should have received a copy of the GNU General Public License
# along with this program (or with Nagios); if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA
#
#
# Check apache status information provided by mod_status to find
# out about the load (number of servers working) and the
# performance (average response time for recent requests).
#
# Usage:
# check_apache -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]
#
# check_apache <host> <warn> <crit> <url> (if you cannot avoid it)
#
use LWP::UserAgent;
use URI::URL;
use Getopt::Long;
Getopt::Long::Configure('bundling');
$version=0.01;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
#
# some default values
#
$perf_w=500;
$perf_c=1000;
$load_w=20;
$load_c=30;
$TIMEOUT=15;
#
# get command line options the regular way
#
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"l" => \$opt_l, "load" => \$opt_l,
"v" => \$verbose, "verbose" => \$verbose,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"u=s" => \$opt_u, "url=s" => \$opt_u);
#
# handle the verbose stuff first
#
if ($opt_V) {
print "\n";
print "check_apache nagios plugin version $version\n";
print "\n";
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
print "copies of the plugins under the terms of the GNU General Public License.\n";
print "For more information about these matters, see the file named COPYING.\n";
print "\n";
print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n";
print "\n";
print "\n";
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'UNKNOWN'};
}
#
# now get options the weired way and set the defaults
# if nothing else is provided
#
$opt_H = shift unless ($opt_H);
print_usage() unless ($opt_H);
if($opt_l) {
$autostring="?auto";
($opt_w) || ($opt_w = shift) || ($opt_w = $load_w);
$warn = $1 if ($opt_w =~ /([0-9]+)/);
($opt_c) || ($opt_c = shift) || ($opt_c = $load_c);
$alert = $1 if ($opt_c =~ /([0-9]+)/);
} else {
$autostring="";
($opt_w) || ($opt_w = shift) || ($opt_w = $perf_w);
$warn = $1 if ($opt_w =~ /([0-9]+)/);
($opt_c) || ($opt_c = shift) || ($opt_c = $perf_c);
$alert = $1 if ($opt_c =~ /([0-9]+)/);
}
($opt_u) || ($opt_u = shift) || ($opt_u = "/server-status");
#
# dont let us wait forever...
#
$SIG{'ALRM'} = sub {
print ("ERROR: No response from HTTP server (alarm)\n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
#
# now we set things up for the real work
# and fire up the request
#
$ua = new LWP::UserAgent;
$ua->agent("Nagios/0.1 " . $ua->agent);
$urlstring = "http://" . $opt_H . $opt_u . $autostring;
$url = url($urlstring);
my $req = new HTTP::Request 'GET', $url;
my $res = $ua->request($req);
#
# hopefully we´ve got something usefull
#
if ($res->is_success) {
if($opt_l) {
foreach $_ (split /^/m, $res->content) {
next if /^\s*$/;
#
# this is the load checking section
# we parse the whole content, just in case someone
# wants to use this some day in the future
#
if (/^Total Accesses:\s+([0-9.]+)/) { $accesses = $1; next; }
if (/^Total kBytes:\s+([0-9.]+)/) { $kbytes = $1; next; }
if (/^CPULoad:\s+([0-9.]+)\s+/) { $load = $1; next; }
if (/^Uptime:\s+([0-9.]+)\s+/) { $uptime = $1; next; }
if (/^ReqPerSec:\s+([0-9.]+)\s+/) { $rps = $1; next; }
if (/^BytesPerSec:\s+([0-9.]+)\s+/) { $bps = $1; next; }
if (/^BytesPerReq:\s+([0-9.]+)\s+/) { $bpr = $1; next; }
if (/^BusyServers:\s+([0-9.]+)\s+/) { $busy = $1; next; }
if (/^IdleServers:\s+([0-9.]+)\s+/) { $idle = $1; next; }
if (/^Scoreboard:\s+([SRWKDLG_.]+)\s+/) { $score = $1; next; }
print "Unknown Status\n";
exit $ERRORS{"UNKNOWN"};
}
#
# now we even parse the whole scoreboard, just for fun
#
foreach $scorepoint (split //m, $score) {
if($scorepoint eq '.') { $scores{'.'}+=1; next; } # Unused
if($scorepoint eq '_') { $scores{'_'}+=1; next; } # Waiting
if($scorepoint eq 'S') { $scores{'S'}+=1; next; } # Starting
if($scorepoint eq 'R') { $scores{'R'}+=1; next; } # Reading
if($scorepoint eq 'W') { $scores{'W'}+=1; next; } # Writing
if($scorepoint eq 'K') { $scores{'K'}+=1; next; } # Keepalive
if($scorepoint eq 'D') { $scores{'D'}+=1; next; } # DNS Lookup
if($scorepoint eq 'L') { $scores{'L'}+=1; next; } # Logging
if($scorepoint eq 'G') { $scores{'G'}+=1; next; } # Going
}
if($busy>$alert) {
printf "HTTPD CRITICAL: %.0f servers running\n", $busy;
exit $ERRORS{"CRITICAL"};
}
if($busy>$warn) {
printf "HTTPD WARNING: %.0f servers running\n", $busy;
exit $ERRORS{"WARNING"};
}
printf "HTTPD ok: %.0f servers running, %d idle\n", $busy, $idle;
exit $ERRORS{"OK"};
} else {
#
# this is the performance check section
# We are a bit lazy here, no parsing of the initial data
# block and the scoreboard.
# However, you have the whole set of per server
# information to play with ;-)
# The actual performance is measured by adding up the
# milliseconds required to process the most recent
# requests of all instances and then taking the average.
#
foreach $tablerow (split /<tr>/m, $res->content) {
$tablerow =~ s/<\/td>//g;
($empty,$Srv,$PID,$Acc,$M,$CPU,$SS,$Req,$Conn,$Child,$Slot,$Client,$VHost,$Request)
= split /<td>/, $tablerow;
if(defined $Req) {
$lines+=1;
$req_sum+=$Req;
}
undef $Req;
}
$average=$req_sum/$lines;
if($average>$alert) {
printf "HTTPD CRITICAL: average response time %.0f
milliseconds\n", $average;
exit $ERRORS{"CRITICAL"};
}
if($average>$warn) {
printf "HTTPD WARNING: average response time %.0f
milliseconds\n", $average;
exit $ERRORS{"WARNING"};
}
if($average>0 or ($average == 0 and $lines > 0)) {
printf "HTTPD ok: average response time %.0f milliseconds\n",
$average;
exit $ERRORS{"OK"};
}
print "Unknown Status\n";
exit $ERRORS{"UNKNOWN"};
}
} else {
print "HTTP request failed\n";
exit $ERRORS{"CRITICAL"};
}
#
# ok, now we are almost through
# These last subroutines do the things for those that do not
# read source code.
#
sub print_usage () {
print "Usage: $0 -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]\n"; }
sub print_help () {
print "\n";
print "\n";
print "check_apache nagios plugin version $version\n";
print "\n";
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
print "copies of the plugins under the terms of the GNU General Public License.\n";
print "For more information about these matters, see the file named COPYING.\n";
print "\n";
print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n";
print "\n";
print "\n";
print "This plugin checks the apache HTTP service on the specified host.\n";
print "It uses the mod_status facilities provided by the apache server.\n";
print "The monitoring server must be authorized in httpd.conf.\n";
print "\n";
print "\n";
print_usage();
print "\n";
print "Options:\n";
print " -H, --hostname=ADDRESS\n";
print " host name argument for server.\n";
print " -l, --load\n";
print " check load instead of performance.\n";
print " -h, --help\n";
print " print detailed help screen.\n";
print " -V, --version\n";
print " print version information.\n";
print " -w, --warning=INTEGER\n";
print " load / performance level at which a warning message will be gererated.\n";
print " -c, --critical=INTEGER\n";
print " load / performance level at which a critical message will be gererated.\n";
print " -u, --url=PATH\n";
print " location to call mod_status.\n";
print "\n";
print " Defaults for performance checking are $perf_w/$perf_c msec.\n";
print " Defaults for load checking are $load_w/$load_c servers running.\n";
print "\n";
print "\n";
}
#
# the end
#

Binary file not shown.

@ -0,0 +1,192 @@
#!/usr/bin/perl
#
# License: GPL v.3+
# Copyright (c) 2009 op5 AB
# Author: Henrik Nilsson <henrik30000@gmail.com>
#
# For direct contact with any of the op5 developers send a mail to
# op5-users@lists.op5.com
# Discussions are directed to the mailing list op5-users@op5.com,
# see http://lists.op5.com/mailman/listinfo/op5-users
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 or,
# at your option, any later version, as published by the Free Software
# Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
use lib qw(/usr/local/monitoring/perl/lib/perl5);
use DBI;
use Nagios::Plugin;
my $return_code=0;
my $return_msg;
my $p=Nagios::Plugin->new(usage=>"Usage %s: -U user -P password (-H server|-S servername)\n");
$p->add_arg(spec=>'username|U=s', help=>'User name', required=>1);
$p->add_arg(spec=>'password|P=s', help=>'Password', required=>1);
$p->add_arg(spec=>'host|H=s', help=>'BizTalk server to check (hostname/IP)', required=>0);
$p->add_arg(spec=>'server|S=s', help=>'BizTalk server to check (by sybase configuration)', required=>0);
$p->add_arg(spec=>'port|p=i', help=>'Port for the MSSQL server that BizTalk uses', required=>0);
$p->add_arg(spec=>'warning|w=s', help=>'Warning-range for receive/send ports', required=>0);
$p->add_arg(spec=>'critical|c=s', help=>'Critical-range for receive/send ports', required=>0);
$p->add_arg(spec=>'queuewarning|W=s', help=>'Warning-range for queues', required=>0);
$p->add_arg(spec=>'queuecritical|C=s', help=>'Critical-range for queues', required=>0);
$p->add_arg(spec=>'orchestrationwarning|o=s', help=>'Warning-range for orchestrations', required=>0);
$p->add_arg(spec=>'orchestrationcritical|O=s', help=>'Critical-range for orchestrations', required=>0);
$p->add_arg(spec=>'sendportwarning|d=s', help=>'Warning-range for sendports', required=>0);
$p->add_arg(spec=>'sendportcritical|D=s', help=>'Critical-range for sendports', required=>0);
$p->add_arg(spec=>'receivelocations|l=s', help=>'Specific receivelocation(s) to check, comma-separated', required=>0);
$p->getopts;
if(!defined($p->opts->host)&&!defined($p->opts->server)){$p->nagios_die("You must provide either host or server name");}
# Set up timeout
if(defined($p->opts->timeout))
{
$SIG{'ALRM'} = sub{$p->nagios_die("UNKNOWN", "Plugin timed out.");};
alarm($p->opts->timeout);
}
if (defined($p->opts->port)) {
$ENV{TDSPORT} = $p->opts->port;
}
# Connect to the database
my $db;
if(defined($p->opts->host))
{
$db=DBI->connect("dbi:Sybase:server=".$p->opts->host.";port=".(defined($p->opts->port)?$p->opts->port:1433), $p->opts->username, $p->opts->password) or $p->nagios_die("Could not connect to the BizTalk database", CRITICAL);
}else{
$db=DBI->connect("dbi:Sybase:".$p->opts->server, $p->opts->username, $p->opts->password) or $p->nagios_die("Could not connect to the BizTalk database", CRITICAL);
}
$db->prepare("use BizTalkMgmtDb")->execute();
# Check receive locations
my $q=$db->prepare("select Name, Disabled from adm_ReceiveLocation;");
$q->execute();
my $name, $disabled;
my $count=0;
my $msg="";
$q->bind_columns(\$name, \$disabled);
if(defined($p->opts->receivelocations))
{
$msg='';
my @list=split(",", $p->opts->receivelocations);
while($q->fetch)
{
if($disabled and grep {$_ eq $name} @list)
{
$msg.=$name.", ";
$count++;
}
}
$return_code=$p->check_threshold(check=>$count, warning=>$p->opts->warning, critical=>$p->opts->critical);
$p->nagios_exit($return_code, $count." of ".@list." receive location".(@list!=1?'s':'')." disabled: ".$msg);
}else{
while($q->fetch)
{
if($disabled)
{
$msg.=$name.", ";
$count++;
}
}
}
$code=$p->check_threshold(check=>$count, warning=>$p->opts->warning, critical=>$p->opts->critical);
if($code>$return_code)
{
$return_code=$code;
$return_msg=$count." receive location".($count!=1?"s":"")." disabled: ".$msg;
}elsif($return_code==0){
$return_msg.=$count." receive location".($count!=1?"s":"")." disabled. ";
}
# Check message queue
# Getting the messagequeue, in which we check if nState is 4 or 32 (both mean suspended, 4 for resumable, 32 for non-resumable)
$db->prepare("use BizTalkMsgBoxDb")->execute();
$q=$db->prepare("select nState, nvcErrorDescription from InstancesSuspended where nState=4 or nState=32;");
$q->execute();
my $state, $error;
$count=0;
$msg="";
$q->bind_columns(\$state, \$error);
while($q->fetch)
{
if($state==32)
{
$msg.="Non-resumable: ".$error;
}else{
$msg.="Resumable: ".$error;
}
$count++;
}
$code=$p->check_threshold(check=>$count, warning=>$p->opts->warning, critical=>$p->opts->critical);
if($code>$return_code)
{
$return_code=$code;
$return_msg=$count." suspended messages: ".$msg;
}elsif($return_code==0){
$return_msg.=$count." suspended messages. ";
}
# Check the total length of the queue
$q=$db->prepare("select count(nState) from InstancesSuspended;");
$q->execute();
my @line=$q->fetchrow_array;
$code=$p->check_threshold(check=>$line[0], warning=>$p->opts->queuewarning, critical=>$p->opts->queuecritical);
if($code>$return_code)
{
$return_code=$code;
$return_msg=$line[0]." messages in queue.";
}elsif($return_code==0){
$return_msg.=$line[0]." messages in queue. ";
}
# Check SendPorts
$q=$db->prepare("SELECT nvcName AS SendPortName, nPortStatus as PortStatus FROM [BizTalkMgmtDb].[dbo].[bts_sendport] WHERE nPortStatus != 3");
$q->execute();
$q->bind_columns(\$SendPortName, \$PortStatus);
$count=0;
my $portline;
while($q->fetch) {
$portline .= $SendPortName . ": " . $PortStatus . " ";
$count++;
}
$return_msg .= $count . " lines matching SendPortStatus <> 3. ";
$code=$p->check_threshold(check=>$count,warning=>$p->opts->sendportwarning,critical=>$p->opts->sendportcritical);
if ( $code > 0 ) {
$return_code = $code;
$return_msg =" SendPort: " . $portline
}
# Check Orchesrations
$q=$db->prepare("SELECT nvcFullName AS OrchestrationName,nOrchestrationStatus as PortStatus FROM [BizTalkMgmtDb].[dbo].[bts_orchestration] WHERE (nOrchestrationStatus != 3)");
$q->execute();
$q->bind_columns(\$OrchestrationName, \$PortStatus);
$count=0;
my $orchline;
while($q->fetch) {
$orchline .= $OrchestrationName . ": " . $PortStatus . " ";
$count++;
}
$return_msg .= $count . " lines matching OrchestrationStatus <> 3. ";
$code=$p->check_threshold(check=>$count,warning=>$p->opts->orchestrationwarning,critical=>$p->opts->orchestrationcritical);
if ( $code > 0 ) {
$return_code = $code;
$return_msg =" Orchestration: " . $orchline
}
$p->nagios_exit($return_code, $return_msg);

@ -0,0 +1,38 @@
#!/bin/bash
### ### som kollar att MSDTC process som visar vilken server som är aktiv, körs på exakt en av de servrar som anges i argumentet.
SERVICE='BTSSvc$GcCxHost'
if [ $# -ne 1 -o "$1" == "-h" ]; then
echo "Usage: $1 -h | ip.address,ip.address,ip.address, ..."
exit
fi
IFS=,
RUNNING=0
for i in $1; do
status=`/opt/plugins/check_nt -H $i -p 1248 -v SERVICESTATE -l $SERVICE`
ret=$?
if [ $ret == 0 ]; then
RUNNING=$(($RUNNING + 1))
TEXT="$TEXT$i is running $SERVICE "
fi
done
if [ $RUNNING == 0 ]; then
echo "INSTANCES CRITICAL: None running $SERVICE"
exit 2
elif [ $RUNNING -gt 1 ]; then
echo "INSTANCES CRITICAL: More than one ($RUNNING) hosts running
$SERVICE! ($TEXT)"
exit 2
else
echo "INSTANCES OK: $TEXT"
exit 0
fi

@ -0,0 +1,39 @@
#!/bin/bash
### som kollar att MSDTC process som visar vilken server som är aktiv, körs på exakt en av de servrar som anges i argumentet.
SERVICE='MSDTC$a6c864e0-37c8-4aa9-b63e-8fb1b8c89f79'
if [ $# -ne 1 -o "$1" == "-h" ]; then
echo "Usage: $1 -h | ip.address,ip.address,ip.address, ..."
exit
fi
IFS=,
RUNNING=0
for i in $1; do
status=`/opt/plugins/check_nt -H $i -p 1248 -v SERVICESTATE -l $SERVICE`
ret=$?
if [ $ret == 0 ]; then
RUNNING=$(($RUNNING + 1))
TEXT="$TEXT$i is running $SERVICE "
fi
done
if [ $RUNNING == 0 ]; then
echo "INSTANCES CRITICAL: None running $SERVICE"
exit 2
elif [ $RUNNING -gt 1 ]; then
echo "INSTANCES CRITICAL: More than one ($RUNNING) hosts running
$SERVICE! ($TEXT)"
exit 2
else
echo "INSTANCES OK: $TEXT"
exit 0
fi

@ -0,0 +1,89 @@
#!/usr/local/bin/perl -w
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '/usr/local/monitoring/libexec';
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME = "check_breeze";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"C=s" => \$opt_C, "community=s" => \$opt_C);
if ($opt_V) {
print_revision($PROGNAME,'2.1.1');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
($opt_H) || usage("Host name/address not specified\n");
my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($host) || usage("Invalid host: $opt_H\n");
($opt_w) || usage("Warning threshold not specified\n");
my $warning = $1 if ($opt_w =~ /([0-9]{1,2}|100)+/);
($warning) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || usage("Critical threshold not specified\n");
my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/);
($critical) || usage("Invalid critical threshold: $opt_c\n");
($opt_C) || ($opt_C = "public") ;
my $sig=0;
$sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`;
my @test=split(/ /,$sig);
$sig=$test[2];
$sig=int($sig);
if ($sig>100){$sig=100}
print "Signal Strength at: $sig%\n";
exit $ERRORS{'CRITICAL'} if ($sig<$critical);
exit $ERRORS{'WARNING'} if ($sig<$warning);
exit $ERRORS{'OK'};
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-C community] -w <warn> -c <crit>\n";
}
sub print_help () {
print_revision($PROGNAME,'2.1.1');
print "Copyright (c) 2000 Jeffrey Blank/Karl DeBisschop
This plugin reports the signal strength of a Breezecom wireless equipment
";
print_usage();
print "
-H, --hostname=HOST
Name or IP address of host to check
-C, --community=community
SNMPv1 community (default public)
-w, --warning=INTEGER
Percentage strength below which a WARNING status will result
-c, --critical=INTEGER
Percentage strength below which a CRITICAL status will result
";
support();
}

Binary file not shown.

@ -0,0 +1,16 @@
#!/bin/bash
eval "$(<~/.ssh/.ssh-agent)" >/dev/null
#for arg in $@; do echo "#${arg}#"; done
# This crazy shit is done because of issues with passing quotes in
precmd=`echo $* | sed 's/\-C.*//'`
cmd=`echo "$*" | sed 's/.*\-C[[:space:]]\+//'`
#echo "#${precmd}#${cmd}#"
exec /usr/local/monitoring/nagios/libexec/check_by_ssh $precmd -C "$cmd" 2>&1
exit $?

@ -0,0 +1,28 @@
#!/bin/bash
if [[ "$#" -lt "4" ]]; then
echo "Usage: $0 <path_to_keyfile> <remoteuser> <remotehost> <remotecommand> [regex_to_match_expected]"
exit 3
fi
key=$1
usr=$2
host=$3
command=$4
expect=$5
command=`echo "$command" | sed 's/%%%%pipe%%%%/|/'`
##echo "###$command###"
ret=`/usr/bin/ssh -i $key ${usr}@${host} "$command" 2>&1`
stat=$?
if [[ "$stat" -eq "0" && ("$ret" =~ $expect || -z "$expect") ]]
then
echo "OK: $ret"
else
echo "CRITICAL: $ret"
stat=2
fi
exit $stat

Binary file not shown.

Binary file not shown.

@ -0,0 +1,45 @@
#!/bin/sh
name=`basename $0`
usage () {
echo "Usage: $name {-h|-s} [-l label] [-w warn_thres] [-c crit_thres] -d <host_or_service_ret_codes_comma_sep>"
exit 3
}
#echo "$*" >> /tmp/trace.clus
while getopts "d:hsl:w:c:" option
do
case $option in
d) spec="$OPTARG" ;;
s) type="-s" ;;
h) type="-h" ;;
l) label="$OPTARG" ;;
w) warn="-w $OPTARG" ;;
c) crit="-c $OPTARG" ;;
*) usage ;;
\?) usage ;;
esac
done
if [ -z "$type" -o -z "$spec" ]; then usage; fi
OLD_IFS="$IFS"
IFS=,
for stat in $spec
do
if [ "$stat" -eq "$stat" ] 2>/dev/null; then continue; else
echo "The host or service specified \"$stat\" does not exist"
exit 3
fi
done
IFS="$OLD_IFS"
lbl=`echo $label | sed 's/ /_/g'`
label="$lbl"
#echo "/usr/local/monitoring/nagios/libexec/check_cluster $type $label -d $spec $warn $crit" >> /tmp/trace.clus
/usr/local/monitoring/nagios/libexec/check_cluster $type -l $label -d $spec $warn $crit
exit $?

@ -0,0 +1,263 @@
#!/usr/bin/perl -w
#
# $Id: check_cpu,v 1.7 2004/06/22 16:51:05 hmann Exp $
#
# check_cpu checks CPU and returns sar stats
#
# Copyright (c) 2000-2004 Harper Mann. All rights reserved
# (harper.mann@comcast.net)
#
# No warrenty of any kind is granted io implied.
#
# Change Log
#----------------
# 15-Feb-2004 - Harper Mann
# Initial revision
# 19-Mar-2004 Harper Mann
# Fixed to use /proc instead of sar
# 23-Mar-2004 Harper Mann
# Back to sar so numbers match. Beta release
# 4-Jun-2004 - Harper Mann
# Changed idle value to be a < test
# 21-Jun-2004 - Harper Mann
# Added switch for CPU
#
use strict;
my @sar_vals = undef;
my @lines = undef;
my @res = undef;
my $PROCSTAT = "/proc/stat";
my $cpu;
my $userwarn = 101;
my $usercrit = 101;
my $nicewarn = 101;
my $nicecrit = 101;
my $syswarn = 101;
my $syscrit = 101;
my $iowaitwarn = 101;
my $iowaitcrit = 101;
my $idlewarn = 0;
my $idlecrit = 0;
my $debug = 0;
my $perf = 0;
# my $SAR = "/usr/local/groundwork/bin/sar";
my $SAR = "/usr/bin/sar";
use Getopt::Long;
use vars qw($opt_V $opt_c $opt_s $opt_n $opt_u $opt_i $opt_W $opt_D $opt_p $opt_h);
use vars qw($PROGNAME);
use lib "/usr/local/nagios/libexec" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
sub print_help ();
sub print_usage ();
$PROGNAME = "check_cpu";
Getopt::Long::Configure('bundling');
my $status = GetOptions
( "V" => \$opt_V, "Version" => \$opt_V,
"c=s" => \$opt_c, "cpu=s" => \$opt_c,
"u=s" => \$opt_u, "user=s" => \$opt_u,
"n=s" => \$opt_n, "nice=s" => \$opt_n,
"s=s" => \$opt_s, "system=s" => \$opt_s,
"W=s" => \$opt_W, "iowait=s" => \$opt_W,
"i=s" => \$opt_i, "idle=s" => \$opt_i,
"D" => \$opt_D, "debug" => \$opt_D,
"p" => \$opt_p, "performance" => \$opt_p,
"h" => \$opt_h, "help" => \$opt_h );
if ($status == 0) { print_usage() ; exit $ERRORS{'UNKNOWN'}; }
# Debug switch
if ($opt_D) { $debug = 1 }
# Cpu switch
if ($opt_c) { $cpu = $opt_c } else { $cpu = 0 }
print "CPU: $cpu\n" if $debug;
# Performance switch
if ($opt_p) { $perf = 1; }
# Version
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.7 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'}}
# Options checking
# Percent CPU system utilization
if ($opt_s) {
($syswarn, $syscrit) = split /:/, $opt_s;
($syswarn && $syscrit) || usage ("missing value -s <warn:crit>\n");
($syswarn =~ /^\d{1,3}$/ && $syswarn > 0 && $syswarn <= 100) &&
($syscrit =~ /^\d{1,3}$/ && $syscrit > 0 && $syscrit <= 100) ||
usage("Invalid value: -s <warn:crit> (system percent): $opt_s\n");
($syscrit > $syswarn) ||
usage("system critical (-s $opt_s <warn:crit>) must be > warning\n");
}
# Percent CPU nice utilization
if ($opt_n) {
($nicewarn, $nicecrit) = split /:/, $opt_n;
($nicewarn && $nicecrit) || usage ("missing value -n <warn:crit>\n");
($nicewarn =~ /^\d{1,3}$/ && $nicewarn > 0 && $nicewarn <= 100) &&
($nicecrit =~ /^\d{1,3}$/ && $nicecrit > 0 && $nicecrit <= 100) ||
usage("Invalid value: -n <warn:crit> (nice percent): $opt_n\n");
($nicecrit > $nicewarn) ||
usage("nice critical (-n $opt_n <warn:crit>) must be > warning\n");
}
# Percent CPU user utilzation
if ($opt_u) {
($userwarn, $usercrit) = split /:/, $opt_u;
($userwarn && $usercrit) || usage ("missing value -u <warn:crit>\n");
($userwarn =~ /^\d{1,3}$/ && $userwarn > 0 && $userwarn <= 100) &&
($usercrit =~ /^\d{1,3}$/ && $usercrit > 0 && $usercrit <= 100) ||
usage("Invalid value: -u <warn:crit> (user percent): $opt_u\n");
($usercrit > $userwarn) ||
usage("user critical (-u $opt_u <warn:crit>) must be < warning\n");
}
# Percent CPU idle utilzation
if ($opt_i) {
($idlewarn, $idlecrit) = split /:/, $opt_i;
($idlewarn && $idlecrit) || usage ("missing value -i <warn:crit>\n");
($idlewarn =~ /^\d{1,3}$/ && $idlewarn > 0 && $idlewarn <= 100) &&
($idlecrit =~ /^\d{1,3}$/ && $idlecrit > 0 && $idlecrit <= 100) ||
usage("Invalid value: -i <warn:crit> (idle percent): $opt_i\n");
($idlecrit < $idlewarn) ||
usage("idle critical (-i $opt_i <warn:crit>) must be > warning\n");
}
# Percent CPU iowait utilzation
if ($opt_W) {
($iowaitwarn, $iowaitcrit) = split /:/, $opt_W;
($iowaitwarn && $iowaitcrit) || usage ("missing value -W <warn:crit>\n");
($iowaitwarn =~ /^\d{1,3}$/ && $iowaitwarn > 0 && $iowaitwarn <= 100) &&
($iowaitcrit =~ /^\d{1,3}$/ && $iowaitcrit > 0 && $iowaitcrit <= 100) ||
usage("Invalid value: -W <warn:crit> (iowait percent): $opt_W\n");
($iowaitcrit > $iowaitwarn) ||
usage("iowait critical (-i $opt_W <warn:crit>) must be > warning\n");
}
# Read /proc/stat values. The first "cpu " line has aggregate values if
# the system is SMP
#
my ($lbl, $user, $nice, $sys, $iowait, $idle, $idle2, $use_idle2) = undef;
if ($cpu eq "ALL" ) {
(@res = qx/$SAR 1 1/) || die "No output from sar: $!";
} else {
(@res = qx/$SAR 1 1 -U $cpu/) || die "No output from sar: $!";
}
foreach (@res) {
chomp;
if (/steal/) { $use_idle2 = 1; }
($lbl,$cpu,$user,$nice,$sys,$iowait,$idle,$idle2) = split(/\s+/);
if (/average/) { last }
}
$idle = $idle2 if $use_idle2;
# Do the value checks
my $out = undef;
$out=$out."(cpu: $cpu) ";
$out=$out."user: $user";
($user > $usercrit) ? ($out=$out."(Critical) ") :
($user > $userwarn) ? ($out=$out."(Warning) ") : ($out=$out."(OK) ");
$out=$out."nice: $nice";
($nice > $nicecrit) ? ($out=$out."(Critical) ") :
($nice > $nicewarn) ? ($out=$out."(Warning) ") : ($out=$out."(OK) ");
$out=$out."iowait: $iowait";
($iowait > $iowaitcrit) ? ($out=$out."(Critical) ") :
($iowait > $iowaitwarn) ? ($out=$out."(Warning) ") : ($out=$out."(OK) ");
$out=$out."sys: $sys";
($sys > $syscrit) ? ($out=$out."(Critical) ") :
($sys > $syswarn) ? ($out=$out."(Warning) ") : ($out=$out."(OK) ");
$out=$out."idle: $idle";
($idle < $idlecrit) ? ($out=$out."(Critical) ") :
($idle < $idlewarn) ? ($out=$out."(Warning) ") : ($out=$out."(OK) ");
print "$out";
print " |cpu: $cpu user: $user nice: $nice sys: $sys idle: $idle" if $perf;
print "\n";
# Plugin output
# $worst == $ERRORS{'OK'} ? print "CPU OK @goodlist" : print "@badlist";
# Performance?
if ($out =~ /Critical/) { exit (2) }
if ($out =~ /Warning/) { exit (1) }
exit (0); #OK
# Usage sub
sub print_usage () {
print "Usage: $PROGNAME
[-c, --cpu <cpu number>
[-u, --user <warn:crit> percent
[-n, --nice <warn:crit> percent
[-s, --system <warn:crit> percent
[-i, --idle <warn:crit> percent (NOTE: idle less than x)
[-p] (output Nagios performance data)
[-D] (debug) [-h] (help) [-V] (Version)\n";
}
# Help sub
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.7 $');
# Perl device CPU check plugin for Nagios
print_usage();
print "
-c, --cpu
CPU Number (default is 0, ALL for all)
-u, --user
Percent CPU user
-n, --nice
Percent CPU nice
-s, --system=STRING
Percent CPU system
-i, --idle
If less than Percent CPU idle
-p, --performance
Report Nagios performance data after the ouput string
-h, --help
Print help
-V, --Version
Print version of plugin
";
}

@ -0,0 +1,580 @@
#!/usr/bin/perl -w
#
# ============================== SUMMARY =====================================
#
# Program : check_dell_openmanage.pl
# Version : 1.3
# Date : March 31 2010
# Author : Jason Ellison - infotek@gmail.com
# Summary : This is a nagios plugin that checks the status of objects
# monitored by Dell OpenManage on Dell PowerEdge servers via SNMP
#
# Licence : GPL - summary below, full text at http://www.fsf.org/licenses/gpl.txt
#
# =========================== PROGRAM LICENSE =================================
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ===================== INFORMATION ABOUT THIS PLUGIN =========================
#
# This plugin checks the status of objects monitored by OpenManage via SNMP
# and returns OK, WARNING, CRITICAL or UNKNOWN. If a failure occurs it will
# describe the subsystem that failed and the failure code.
#
# This program is written and maintained by:
# Jason Ellison - infotek(at)gmail.com
#
# It is based on check_snmp_temperature.pl plugin by:
# William Leibzon - william(at)leibzon.org
#
# Using information from
# Dell OpenManage Server Administrator Version 5.4 SNMP Reference Guide
# http://support.dell.com/support/edocs/software/svradmin/
#
# System Types
#
# "dellom" monitors the following OID's:
# systemStateChassisStatus .1.3.6.1.4.1.674.10892.1.200.10.1.4.1
# systemStatePowerSupplyStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.9.1
# systemStateVoltageStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.12.1
# systemStateCoolingDeviceStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.21.1
# systemStateTemperatureStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.24.1
# systemStateMemoryDeviceStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.27.1
# systemStateChassisIntrusionStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.30.1
# systemStateEventLogStatus .1.3.6.1.4.1.674.10892.1.200.10.1.41.1
#
# "dellom_storage" test all of the OID's "dellom" tests plus the storage OID
# systemStateChassisStatus .1.3.6.1.4.1.674.10892.1.200.10.1.4.1
# systemStatePowerSupplyStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.9.1
# systemStateVoltageStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.12.1
# systemStateCoolingDeviceStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.21.1
# systemStateTemperatureStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.24.1
# systemStateMemoryDeviceStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.27.1
# systemStateChassisIntrusionStatusCombined .1.3.6.1.4.1.674.10892.1.200.10.1.30.1
# systemStateEventLogStatus .1.3.6.1.4.1.674.10892.1.200.10.1.41.1
# StorageManagement-MIB::agentGlobalSystemStatus .1.3.6.1.4.1.674.10893.1.20.110.13.0
#
# "global" monitors
# GlobalSystemStatus .1.3.6.1.4.1.674.10892.1.200.10.1.2.1
#
# "chassis" monitors
# ChassisStatus .1.3.6.1.4.1.674.10892.1.200.10.1.4.1
#
# "custom" is meant to be customised by advanced users
#
# ============================= SETUP NOTES ====================================
#
# Copy this file to your Nagios installation folder in "libexec/". Rename
# to "check_dell_openmanage.pl".
#
# You must have Dell OpenManage installed on the server that you want to
# monitor. You must have enabled SNMP on the server and allow SNMP queries.
# On the server that will be running the plugin you must have the perl
# "Net::SNMP" module installed.
#
# perl -MCPAN -e shell
# cpan> install Net::SNMP
#
# For SNMPv3 support make sure you have the following modules installed:
# Crypt::DES, Digest::MD5, Digest::SHA1, and Digest::HMAC
#
# Check Dell OpenManage on the local host for alert thresholds like min/max
# fan speeds and temperatures...
#
# To test using SNMPv1 use the following syntax:
#
# ./check_dell_openmanage.pl -v -H <host> -C <snmp_community> -T <type>
#
# Where <type> is "test", "dellom", "dellom_storage", "blade", "global", "chassis" or "custom"
#
# ========================= SETUP EXAMPLES ==================================
#
# define command{
# command_name check_dell_open_manage
# command_line $USER1$/check_dell_openmanage.pl -H $HOSTADDRESS$ -C $ARG1$ -T $ARG2$
# }
#
# define service{
# use generic-service
# host_name DELL-SERVER-00
# service_description Dell OpenManage Status
# check_command check_dell_open_manage!public!dellom
# normal_check_interval 3
# retry_check_interval 1
# }
#
# define service{
# use generic-service
# host_name DELL-SERVER-01
# service_description Dell OpenManage Status plus Storage
# check_command check_dell_open_manage!public!dellom_storage
# normal_check_interval 3
# retry_check_interval 1
# }
#
# =================================== TODO ===================================
#
# Fix bugs and make more user friendly.
#
# ================================ REVISION ==================================
#
#
# ver 1.3
#
# If non-numeric codes are returned just add the text to the statusinfo
# This was done to allow adding machine information Dell Model Number and Service Tag to output.
#
# ver 1.2
#
# Major rewrite. Simplified the way new systems are defined. Added system
# type "test" which can be used to easly generate new system definitions.
#
# ver 1.1
# formating of text output
# add blade system type... blades apparently do not support
# systemStatePowerSupplyStatusCombined, systemStateCoolingDeviceStatusCombined
# or systemStateChassisIntrusionStatusCombined
#
# ver 1.0
#
# while in verbose mode report which OID failed in a more readable manner.
# add "global", "chassis", and "custom" type.
#
# ver 0.9
# change added type dellom_storage as this is more accurate. This plugin works
# with all PowerEdge servers it has been tested with. left pe2950 in for compat
# remove min max int options from help text as they are no longer relevant
#
# ver 0.8
#
# removed ucdavis definition. Added note about SNMPv3 dependencies
# check that perl environment has "Net::SNMP" if not found complain.
# missing "Net::SNMP" is the most common issue users report.
#
# ver 0.7
#
# removed ucdavis definition. Added note about SNMPv3 dependencies
#
# ver 0.6
#
# + Added StorageManagement GlobalSystemStatus
# StorageManagement-MIB::agentGlobalSystemStatus
# .1.3.6.1.4.1.674.10893.1.20.110.13.0
#
# ver 0.5
#
# + Cleaned up verbose output for debugging
#
# ver 0.4
#
# + Fixed major flaw in logic that cause errors to not be reported.
#
# + Added to the system_types error warning and unkown variables like seen on
# http://www.mail-archive.com/intermapper-talk@list.dartware.com/msg02687.html
# below section: "This section performs value to text conversions"
#
# ========================== START OF PROGRAM CODE ============================
use strict;
use Getopt::Long;
my %system_types = (
"dellom" => [
'systemStateChassisStatus',
'systemStatePowerSupplyStatusCombined',
'systemStateVoltageStatusCombined',
'systemStateCoolingDeviceStatusCombined',
'systemStateTemperatureStatusCombined',
'systemStateMemoryDeviceStatusCombined',
'systemStateChassisIntrusionStatusCombined',
'systemStateEventLogStatus',
],
"dellom_storage" => [
'systemStateChassisStatus',
'systemStatePowerSupplyStatusCombined',
'systemStateVoltageStatusCombined',
'systemStateCoolingDeviceStatusCombined',
'systemStateTemperatureStatusCombined',
'systemStateMemoryDeviceStatusCombined',
'systemStateChassisIntrusionStatusCombined',
'systemStateEventLogStatus',
'StorageManagementGlobalSystemStatus'
],
"blade" => [
'systemStateChassisStatus',
'systemStateVoltageStatusCombined',
'systemStateTemperatureStatusCombined',
'systemStateMemoryDeviceStatusCombined',
'systemStateEventLogStatus',
'StorageManagementGlobalSystemStatus'
],
"global" => [
'systemStateGlobalSystemStatus'
],
"chassis" => [
'systemStateChassisStatus'
],
"storage" => [
'StorageManagementGlobalSystemStatus'
],
"custom" => [
'systemStateChassisStatus',
'systemStatePowerSupplyStatusCombined',
'systemStateCoolingDeviceStatusCombined',
'systemStateTemperatureStatusCombined',
'systemStateChassisIntrusionStatusCombined',
'systemStateEventLogStatus',
'chassisModelName',
'chassisServiceTagName'
]
);
my %dell_oids = (
'systemStateGlobalSystemStatus'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.2.1',
'systemStateChassisStatus'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.4.1',
'systemStatePowerSupplyStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.9.1',
'systemStateVoltageStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.12.1',
'systemStateAmperageStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.15.1',
'systemStateCoolingDeviceStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.21.1',
'systemStateTemperatureStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.24.1',
'systemStateMemoryDeviceStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.27.1',
'systemStateChassisIntrusionStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.30.1',
'systemStateACPowerCordStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.36.1',
'systemStateEventLogStatus'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.41.1',
'systemStatePowerUnitStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.42.1',
'systemStateCoolingUnitStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.44.1',
'systemStateACPowerSwitchStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.46.1',
'systemStateProcessorDeviceStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.50.1',
'systemStateBatteryStatusCombined'=>'.1.3.6.1.4.1.674.10892.1.200.10.1.52.1',
'StorageManagementGlobalSystemStatus'=>'.1.3.6.1.4.1.674.10893.1.20.110.13.0',
'chassisManufacturerName'=>'1.3.6.1.4.1.674.10892.1.300.10.1.8.1',
'chassisModelName'=>'1.3.6.1.4.1.674.10892.1.300.10.1.9.1',
'chassisServiceTagName'=>'1.3.6.1.4.1.674.10892.1.300.10.1.11.1',
'chassisSystemName'=>'1.3.6.1.4.1.674.10892.1.300.10.1.15.1',
'operatingSystemOperatingSystemName'=>'1.3.6.1.4.1.674.10892.1.400.10.1.6.1',
'operatingSystemOperatingSystemVersionName'=>'1.3.6.1.4.1.674.10892.1.400.10.1.7.1'
);
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
my @DELLSTATUS=('DellStatus', 'other', 'unknown', 'ok', 'nonCritical', 'critical', 'nonRecoverable');
my $Version='1.3';
my $o_host= undef; # hostname
my $o_community= undef; # community
my $o_port= 161; # SNMP port
my $o_help= undef; # help option
my $o_verb= undef; # verbose mode
my $o_version= undef; # version info option
my $o_warn= undef; # warning level option
my @o_warnL= (); # array for above list
my $o_crit= undef; # Critical level option
my @o_critL= (); # array for above list
my $o_timeout= 5; # Default 5s Timeout
my $o_version2= undef; # use snmp v2c
# SNMPv3 specific
my $o_login= undef; # Login for snmpv3
my $o_passwd= undef; # Pass for snmpv3
my $o_attr= undef; # What attribute(s) to check (specify more then one separated by '.')
my @o_attrL= (); # array for above list
my $o_unkdef= 2; # Default value to report for unknown attributes
my $o_type= undef; # Type of system to check
sub print_version { print "$0: $Version\n" };
sub print_usage {
print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-P <port>] -T test|dellom|dellom_storage|blade|global|chassis|custom [-t <timeout>] [-V] [-u <unknown_default>]\n";
}
# Return true if arg is a number
sub isnum {
my $num = shift;
if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 1 ;}
return 0;
}
sub help {
print "\nSNMP Dell OpenManage Monitor for Nagios version ",$Version,"\n";
print " by Jason Ellison - infotek(at)gmail.com\n\n";
print_usage();
print <<EOD;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v 1 protocol)
-2, --v2c
use SNMP v2 (instead of SNMP v1)
-P, --port=PORT
SNMPd port (Default 161)
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
-u, --unknown_default=INT
If attribute is not found then report the output as this number (i.e. -u 0)
-T, --type=test|dellom|dellom_storage|blade|global|chassis|custom
This allows to use pre-defined system type
Currently support systems types are:
test (tries all OID's in verbose mode can be used to generate new system type)
dellom (Dell OpenManage general detailed)
dellom_storage (Dell OpenManage plus Storage Management detailed)
blade (some features are on the chassis not the blade)
global (only check the global health status)
chassis (only check the system chassis health status)
custom (intended for customization)
EOD
}
# For verbose output - don't use it right now
sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; }
# Get the alarm signal (just in case snmp timout screws up)
$SIG{'ALRM'} = sub {
print ("ERROR: Alarm signal (Nagios time-out)\n");
exit $ERRORS{"UNKNOWN"};
};
sub check_options {
Getopt::Long::Configure ("bundling");
GetOptions(
'v' => \$o_verb, 'verbose' => \$o_verb,
'h' => \$o_help, 'help' => \$o_help,
'H:s' => \$o_host, 'hostname:s' => \$o_host,
'P:i' => \$o_port, 'port:i' => \$o_port,
'C:s' => \$o_community, 'community:s' => \$o_community,
'l:s' => \$o_login, 'login:s' => \$o_login,
'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd,
't:i' => \$o_timeout, 'timeout:i' => \$o_timeout,
'V' => \$o_version, 'version' => \$o_version,
'2' => \$o_version2, 'v2c' => \$o_version2,
'u:i' => \$o_unkdef, 'unknown_default:i' => \$o_unkdef,
'T:s' => \$o_type, 'type:s' => \$o_type
);
if (defined($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}; }
if (defined($o_version)) { print_version(); exit $ERRORS{"UNKNOWN"}; }
if (! defined($o_host) ) # check host and filter
{ print "No host defined!\n";print_usage(); exit $ERRORS{"UNKNOWN"}; }
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd)) )
{ print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; }
if (!defined($o_type)) { print "Must define system type!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; }
if (defined ($o_type)) {
if ($o_type eq "test"){
print "TEST MODE:\n";
} elsif (!defined($system_types{$o_type})) {
print "Unknown system type $o_type !\n"; print_usage(); exit $ERRORS{"UNKNOWN"};
}
}
}
########## MAIN #######
check_options();
# Check global timeout if something goes wrong
if (defined($o_timeout)) {
verb("Alarm at $o_timeout");
alarm($o_timeout);
} else {
verb("no timeout defined : using 5s");
alarm (5);
}
eval "use Net::SNMP";
if ($@) {
verb("ERROR: You do NOT have the Net:".":SNMP library \n"
. " Install it by running: \n"
. " perl -MCPAN -e shell \n"
. " cpan[1]> install Net::SNMP \n");
exit 1;
} else {
verb("The Net:".":SNMP library is available on your server \n");
}
# SNMP Connection to the host
my ($session,$error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => 'md5',
-privpassword => $o_passwd,
-timeout => $o_timeout
);
} else {
if (defined ($o_version2)) {
# SNMPv2 Login
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
# next part of the code builds list of attributes to be retrieved
my $i;
my $oid;
my $line;
my $resp;
my $attr;
my $key;
my %varlist = ();
my $result;
if ( $o_type eq "test" ) {
print "Trying all preconfigured Dell OID's against target...\n";
for $attr (sort keys %dell_oids) {
print "$attr\t\($dell_oids{$attr}\)\n";
$result = $session->get_request(
-varbindlist => [$dell_oids{$attr}]
);
print "RESULT: ";
if (!defined($result)) {
print "NO RESPONSE\n";
} else {
if ( $result->{$dell_oids{$attr}} =~ /^[123456]$/ ) {
push @{ $varlist{$attr} }, "$attr", "$dell_oids{$attr}", "$result->{$dell_oids{$attr}}";
print "$result->{$dell_oids{$attr}}\($DELLSTATUS[$result->{$dell_oids{$attr}}]\)\n";
} else {
print "$result->{$dell_oids{$attr}}\n";
}
}
}
$session->close();
print "\nPlease email the results to Jason Ellison - infotek\@gmail.com\n";
print "\nTo add this system to check_dell_openmanage, use something like the following:\n\n";
print " \"pexxxx\" => [\n";
$i = 1;
my $count = keys %varlist;
for $attr (sort keys %varlist){
print " \'$varlist{$attr}[0]\'";
if ( $i lt $count ) {
print ",\n";
} else {
print "\n";
}
$i++;
}
print " ],\n";
exit 0 ;
}
my $statusinfo = "";
verb("SNMP responses...");
for $attr ( @{ $system_types{$o_type} } ) {
$result = $session->get_request(
-varbindlist => [$dell_oids{$attr}]
);
if (!defined($result)) {
verb("RESULT: $attr \n$dell_oids{$attr} = undef");
push @{ $varlist{$attr} }, "$attr", "$dell_oids{$attr}", "$o_unkdef";
}
else {
if ( $result->{$dell_oids{$attr}} =~ /^[123456]$/ ) {
verb("RESULT: $attr \n$dell_oids{$attr} = $result->{$dell_oids{$attr}}\($DELLSTATUS[$result->{$dell_oids{$attr}}]\)");
push @{ $varlist{$attr} }, "$attr", "$dell_oids{$attr}", "$result->{$dell_oids{$attr}}";
} else {
verb("RESULT: $attr \n$dell_oids{$attr} = $result->{$dell_oids{$attr}}");
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$result->{$dell_oids{$attr}}";
}
}
}
$session->close();
# loop to check if warning & critical attributes are ok
verb("\nDell Status to Nagios Status mapping...");
my $statuscode = "OK";
my $statuscritical = "0";
my $statuswarning = "0";
my $statusunknown = "0";
foreach $attr (keys %varlist) {
if ($varlist{$attr}[2] eq "6") {
$statuscritical = "1";
$statuscode="CRITICAL";
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$attr=Non-Recoverable";
}
elsif ($varlist{$attr}[2] eq "5") {
$statuscritical="1";
$statuscode="CRITICAL";
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$attr=Critical";
}
elsif ($varlist{$attr}[2] eq "4") {
$statuswarning = "1";
$statuscode="WARNING";
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$attr=Non-Critical";
}
elsif ($varlist{$attr}[2] eq "2") {
$statusunknown = "1";
$statuscode="UNKNOWN";
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$attr=UKNOWN";
}
elsif ($varlist{$attr}[2] eq "1") {
$statusunknown = "1";
$statuscode="UNKNOWN";
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$attr=Other";
}
elsif ($varlist{$attr}[2] eq "3") {
$statuscode="OK";
}
else {
$statusunknown = "1";
$statuscode="UNKNOWN";
$statusinfo .= ", " if ($statusinfo);
$statusinfo .= "$attr=UKNOWN";
}
verb("$attr: statuscode = $statuscode");
}
$statuscode="OK";
if ($statuscritical eq '1'){
$statuscode="CRITICAL";
}
elsif ($statuswarning eq '1'){
$statuscode="WARNING";
}
elsif ($statusunknown eq '1'){
$statuscode="UNKNOWN";
}
printf("$statuscode: $statusinfo\n");
verb("\nEXIT CODE: $ERRORS{$statuscode} STATUS CODE: $statuscode\n");
exit $ERRORS{$statuscode};

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,279 @@
#!/usr/bin/perl
use Getopt::Std;
$CFG_FILE = "/usr/local/nagios/etc/check_disk.cfg";
$CFG_FILE_LOCAL = "/usr/local/nagios/etc/check_disk_local.cfg";
$DFLT_WARN = 90;
$DFLT_CRIT = 95;
$DFLT_CLASS = "system";
$CURR_WARN = $DFLT_WARN;
$CURR_CRIT = $DFLT_CRIT;
$CURR_CLASS = $DFLT_CLASS;
$sys_type = `uname`;
chomp($sys_type);
%FSTypes = (
ext2 => 1,
ext3 => 1,
ext4 => 1,
ufs => 1,
vxfs => 1,
zfs => 1,
xfs => 1
);
# -p enable perf stats
# -d enable debugging output
# -c <crit> set default critical threshold
# -w <warn> set default warning threshold
# -f <config-file>
# -C <class>
# -t <type[,type...]> add additional file system types
getopts("pdc:w:f:C:t:");
$CURR_WARN = $opt_w if $opt_w ne '';
$CURR_CRIT = $opt_c if $opt_c ne '';
$opt_C = $CURR_CLASS if $opt_C eq '';
# get the types
if ($opt_t ne '') {
@types = split(/,/, $opt_t);
for $t (@types) {
print "add type $t\n" if $opt_d;
$FSTypes{$t} = 1;
}
}
# get the list of file systems
&read_mounts;
# read the config file; if it's not there we take the defaults, except
# that if we specify a config file on the command line, we return UNKNOWN
# if the file isn't there
if ($opt_f ne '') {
open (CFG_FILE, $opt_f) or unknown("Can't open config file: $opt_f");
&read_config;
}
else {
(open(CFG_FILE, $CFG_FILE_LOCAL) or open(CFG_FILE, $CFG_FILE)) and &read_config;
}
if ($opt_d) {
for $fs (sort keys %Class) {
print "fs $fs class $Class{$fs} warn $Warn{$fs} crit $Crit{$fs}\n";
}
}
# if there are any file systems that are mounted but not mentioned in the config file,
# give them default class and thresholds
for $fs (keys %Type) {
print "testing $fs: ", defined($Interesting{$fs}) ? "" : "not ", "interested\n" if $opt_d;
if (! defined($Interesting{$fs})) {
$Class{$fs} = $DFLT_CLASS;
$Warn{$fs} = $DFLT_WARN;
$Crit{$fs} = $DFLT_CRIT;
}
}
if ($sys_type eq "Linux") {
$cmd = "/bin/df -kP";
}
elsif ($sys_type eq "SunOS") {
$cmd = "/usr/bin/df -k";
}
else {
unknown("I don't grok system type $sys_type");
}
$fscount = 0;
for $fs (sort keys %Class) {
## unknown("Non-existant FS ($fs) in config file, line $Line{$fs}") if $Type{$fs} eq '';
push(@FSList, $fs);
}
for $fs (@FSList) {
next if $Ignore{$fs};
next if $Class{$fs} ne $opt_C;
$cmd = $cmd . " " . $fs;
$fscount++;
}
if ($fscount == 0) {
unknown("no file systems in class \'$opt_C\'");
}
print "$cmd\n" if $opt_d;
$code = 0;
open(DF, "$cmd|") or unknown("Unable to exec df command");
$junk = <DF>; # column headers
while (<DF>) {
chop;
($dev, $tot, $used, $free, $cap, $fs) = split;
$p = int(($tot - $free) * 100 / $tot);
print "$fs: $used/$tot $p\n" if $opt_d;
$perf .= " $fs=$p\%";
if ($p > $Crit{$fs}) {
$crit_result .= " $fs: $p\% (C)";
$code = 2;
}
elsif ($p > $Warn{$fs}) {
$warn_result .= " $fs: $p\% (W)";
$code = 1 if $code != 2;
}
else {
$result .= " $fs: $p\% (OK)";
}
}
print "perf $perf\n" if $opt_d;
@CODE = ("OK", "WARNING", "CRITICAL", "UNKNOWN");
print "DISK $CODE[$code]: class '$opt_C':$crit_result$warn_result$result";
print "|$perf" if $opt_p;
print "\n";
exit $code;
sub read_mounts
{
open(MNTTAB, "/etc/mtab") or open(MNTTAB, "/etc/mnttab") or unknown("Can't open file system mount table");
while (<MNTTAB>) {
chop;
@mnt = split;
next if $FSTypes{$mnt[2]} != 1;
$fs = $mnt[1];
print "read from mtab: $_\n" if $opt_d;
# push(@FSList, $fs);
$Type{$fs} = $mnt[2];
# $Class{$fs} = $DFLT_CLASS;
# $Warn{$fs} = $DFLT_WARN;
# $Crit{$fs} = $DFLT_CRIT;
}
}
sub read_config
{
my ($tmp_class, $tmp_warn, $tmp_crit);
$line_num = 0;
while (<CFG_FILE>) {
$line_num++;
chop;
s/^[ ]*//;
next if /^#/;
next if $_ eq '';
if (/^ignore\s/) {
($junk, $fs) = split;
$Ignore{$fs} = 1;
}
elsif (/^crit\s/) {
($junk, $crit) = split;
$CURR_CRIT = $crit;
}
elsif (/^warn\s/) {
($junk, $warn) = split;
$CURR_WARN = $warn;
}
elsif (/^class\s/) {
($junk, $class) = split;
$CURR_CLASS = $class;
}
elsif (/^fs\s/) {
($junk, @a) = split;
$fs = $a[0];
@fslist = &match($fs);
foreach $fs (@fslist) {
$tmp_class = $CURR_CLASS;
$tmp_warn = $CURR_WARN;
$tmp_crit = $CURR_CRIT;
@aa = @a;
shift @aa;
foreach $arg (@aa) {
if ($arg =~ /^class=/) { $tmp_class = substr($arg, 6); }
elsif ($arg =~ /^warn=/) { $tmp_warn = substr($arg, 5); }
elsif ($arg =~ /^crit=/) { $tmp_crit = substr($arg, 5); }
else { unknown("Syntax error in config file, line $line_num"); }
}
# mark the file system as being of overall interest
$Interesting{$fs} = 1;
# Only set these values if the class of the file system is the one that
# we are looking to check. This allows us to put a file system in
# multiple classes (in cases where more than on group wants to know
# about a F.S.) and not have one definition overwritten by another one.
print "about to test $fs now $Class{$fs} tmp $tmp_class dflt $CURR_CLASS opt $opt_C\n" if $opt_d;
next if $tmp_class ne $opt_C;
print "setting $fs to class $tmp_class\n" if $opt_d;
$Class{$fs} = $tmp_class;
$Warn{$fs} = $tmp_warn;
$Crit{$fs} = $tmp_crit;
$Line{$fs} = $line_num;
}
}
else { # syntax error
unknown("Syntax error in config file, line $line_num");
}
}
close(CFG_FILE);
}
sub match
{
my ($fs) = @_;
my @glist = glob($fs);
my @rlist = ();
print "Match glob list is " . join(' ', @glist) . "\n" if $opt_d;
foreach $fs (@glist) {
push @rlist, $fs if $Type{$fs} ne '';
}
print "Match return list is " . join(' ', @rlist) . "\n" if $opt_d;
return @rlist;
}
sub unknown
{
my ($reason) = @_;
print "UNKNOWN: $reason\n";
exit 3;
}

@ -0,0 +1,331 @@
#!/usr/local/bin/perl -w
#
#
# check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port]
#
# Monitoring host script to get the disk usage from a SMB share
#
# Changes and Modifications
# =========================
# 7-Aug-1999 - Michael Anthon
# Created from check_disk.pl script provided with netsaint_statd (basically
# cause I was too lazy (or is that smart?) to write it from scratch)
# 8-Aug-1999 - Michael Anthon
# Modified [warn] and [critical] parameters to accept format of nnn[M|G] to
# allow setting of limits in MBytes or GBytes. Percentage settings for large
# drives is a pain in the butt
# 2-May-2002 - SGhosh fix for embedded perl
#
#
require 5.004;
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose);
use vars qw($PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '/usr/local/monitoring/libexec';
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
sub print_help ();
sub print_usage ();
$PROGNAME = "check_disk_smb";
$ENV{'PATH'}='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("v" => \$verbose, "verbose" => \$verbose,
"P=s" => \$opt_P, "port=s" => \$opt_P,
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c,
"p=s" => \$opt_p, "password=s" => \$opt_p,
"u=s" => \$opt_u, "username=s" => \$opt_u,
"s=s" => \$opt_s, "share=s" => \$opt_s,
"W=s" => \$opt_W, "workgroup=s" => \$opt_W,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"a=s" => \$opt_a, "address=s" => \$opt_a);
if ($opt_V) {
print_revision($PROGNAME,'2.1.1'); #'
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
my $smbclient = $utils::PATH_TO_SMBCLIENT;
$smbclient || usage("check requires smbclient, smbclient not set\n");
-x $smbclient || usage("check requires smbclient, $smbclient: $!\n");
# Options checking
($opt_H) || ($opt_H = shift @ARGV) || usage("Host name not specified\n");
my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9 ]+\$?)$/);
($host) || usage("Invalid host: $opt_H\n");
($opt_s) || ($opt_s = shift @ARGV) || usage("Share volume not specified\n");
my $share = $1 if ($opt_s =~ /^([-_.A-Za-z0-9 ]+\$?)$/);
($share) || usage("Invalid share: $opt_s\n");
defined($opt_u) || ($opt_u = shift @ARGV) || ($opt_u = "guest");
my $user = $1 if ($opt_u =~ /^([-_.A-Za-z0-9\\]*)$/);
defined($user) || usage("Invalid user: $opt_u\n");
defined($opt_p) || ($opt_p = shift @ARGV) || ($opt_p = "");
my $pass = $1 if ($opt_p =~ /(.*)/);
($opt_w) || ($opt_w = shift @ARGV) || ($opt_w = 85);
my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
($warn) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || ($opt_c = shift @ARGV) || ($opt_c = 95);
my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
($crit) || usage("Invalid critical threshold: $opt_c\n");
# Execute the given command line and return anything it writes to STDOUT and/or
# STDERR. (This might be useful for other plugins, too, so it should possibly
# be moved to utils.pm.)
sub output_and_error_of {
local *CMD;
local $/ = undef;
my $pid = open CMD, "-|";
if (defined($pid)) {
if ($pid) {
return <CMD>;
} else {
open STDERR, ">&STDOUT" and exec @_;
exit(1);
}
}
return undef;
}
# split the type from the unit value
#Check $warn and $crit for type (%/M/G) and set up for tests
#P = Percent, K = KBytes
my $warn_type;
my $crit_type;
if ($opt_w =~ /^([0-9]+)\%?$/) {
$warn = "$1";
$warn_type = "P";
} elsif ($opt_w =~ /^([0-9]+)k$/) {
$warn_type = "K";
$warn = $1;
} elsif ($opt_w =~ /^([0-9]+)M$/) {
$warn_type = "K";
$warn = $1 * 1024;
} elsif ($opt_w =~ /^([0-9]+)G$/) {
$warn_type = "K";
$warn = $1 * 1048576;
}
if ($opt_c =~ /^([0-9]+)\%?$/) {
$crit = "$1";
$crit_type = "P";
} elsif ($opt_c =~ /^([0-9]+)k$/) {
$crit_type = "K";
$crit = $1;
} elsif ($opt_c =~ /^([0-9]+)M$/) {
$crit_type = "K";
$crit = $1 * 1024;
} elsif ($opt_c =~ /^([0-9]+)G$/) {
$crit_type = "K";
$crit = $1 * 1048576;
}
# check if both warning and critical are percentage or size
unless( ( $warn_type eq "P" && $crit_type eq "P" ) || ( $warn_type ne "P" && $crit_type ne "P" ) ){
$opt_w =~ s/\%/\%\%/g;
$opt_c =~ s/\%/\%\%/g;
usage("Both warning and critical should be same type- warning: $opt_w critical: $opt_c \n");
}
# verify warning is less than critical
if ( $warn_type eq "K") {
unless ( $warn > $crit) {
usage("Disk size: warning ($opt_w) should be greater than critical ($opt_c) \n");
}
}else{
unless ( $warn < $crit) {
$opt_w =~ s/\%/\%\%/g;
$opt_c =~ s/\%/\%\%/g;
usage("Percentage: warning ($opt_w) should be less than critical ($opt_c) \n");
}
}
my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
my $address = $1 if (defined($opt_a) && $opt_a =~ /(.*)/);
# end of options checking
my $state = "OK";
my $answer = undef;
my $res = undef;
my $perfdata = "";
my @lines = undef;
# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "No Answer from Client\n";
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
# Execute a "du" on the share using smbclient program
# get the results into $res
my @cmd = (
$smbclient,
"//$host/$share",
"-U", "$user%$pass",
defined($workgroup) ? ("-W", $workgroup) : (),
defined($address) ? ("-I", $address) : (),
defined($opt_P) ? ("-p", $opt_P) : (),
"-c", "du"
);
print join(" ", @cmd) . "\n" if ($verbose);
$res = output_and_error_of(@cmd) or exit $ERRORS{"UNKNOWN"};
#Turn off alarm
alarm(0);
#Split $res into an array of lines
@lines = split /\n/, $res;
#Get the last line into $_
$_ = $lines[$#lines-1];
#print "$_\n";
#Process the last line to get free space.
#If line does not match required regexp, return an UNKNOWN error
if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
my ($avail_bytes) = $3 * $2;
my ($total_bytes) = $1 * $2;
my ($occupied_bytes) = $1 * $2 - $avail_bytes;
my ($avail) = $avail_bytes/1024;
my ($capper) = int(($3/$1)*100);
my ($mountpt) = "\\\\$host\\$share";
# TODO : why is the kB the standard unit for args ?
my ($warn_bytes) = $total_bytes - $warn * 1024;
if ($warn_type eq "P") {
$warn_bytes = $warn * $1 * $2 / 100;
}
my ($crit_bytes) = $total_bytes - $crit * 1024;
if ($crit_type eq "P") {
$crit_bytes = $crit * $1 * $2 / 100;
}
if (int($avail / 1024) > 0) {
$avail = int($avail / 1024);
if (int($avail /1024) > 0) {
$avail = (int(($avail / 1024)*100))/100;
$avail = $avail ."G";
} else {
$avail = $avail ."M";
}
} else {
$avail = $avail ."K";
}
#print ":$warn:$warn_type:\n";
#print ":$crit:$crit_type:\n";
#print ":$avail:$avail_bytes:$capper:$mountpt:\n";
$perfdata = "'" . $share . "'=" . $occupied_bytes . 'B;'
. $warn_bytes . ';'
. $crit_bytes . ';'
. '0;'
. $total_bytes;
if ($occupied_bytes > $crit_bytes) {
$state = "CRITICAL";
$answer = "CRITICAL: Only $avail ($capper%) free on $mountpt";
} elsif ( $occupied_bytes > $warn_bytes ) {
$state = "WARNING";
$answer = "WARNING: Only $avail ($capper%) free on $mountpt";
} else {
$answer = "Disk ok - $avail ($capper%) free on $mountpt";
}
} else {
$answer = "Result from smbclient not suitable";
$state = "UNKNOWN";
foreach (@lines) {
if (/(Access denied|NT_STATUS_LOGON_FAILURE|NT_STATUS_ACCESS_DENIED)/) {
$answer = "Access Denied";
$state = "CRITICAL";
last;
}
if (/(Unknown host \w*|Connection.*failed)/) {
$answer = "$1";
$state = "CRITICAL";
last;
}
if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) {
$answer = "Invalid share name \\\\$host\\$share";
$state = "CRITICAL";
last;
}
}
}
print $answer;
print " | " . $perfdata if ($perfdata);
print "\n";
print "$state\n" if ($verbose);
exit $ERRORS{$state};
sub print_usage () {
print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
-w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n";
}
sub print_help () {
print_revision($PROGNAME,'2.1.1');
print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop
Perl Check SMB Disk plugin for monitoring
";
print_usage();
print "
-H, --hostname=HOST
NetBIOS name of the server
-s, --share=STRING
Share name to be tested
-W, --workgroup=STRING
Workgroup or Domain used (Defaults to \"WORKGROUP\")
-a, --address=IP
IP-address of HOST (only necessary if HOST is in another network)
-u, --user=STRING
Username to log in to server. (Defaults to \"guest\")
-p, --password=STRING
Password to log in to server. (Defaults to an empty password)
-w, --warning=INTEGER or INTEGER[kMG]
Percent of used space at which a warning will be generated (Default: 85%)
-c, --critical=INTEGER or INTEGER[kMG]
Percent of used space at which a critical will be generated (Defaults: 95%)
-P, --port=INTEGER
Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
If thresholds are followed by either a k, M, or G then check to see if that
much disk space is available (kilobytes, Megabytes, Gigabytes)
Warning percentage should be less than critical
Warning (remaining) disk space should be greater than critical.
";
support();
}

Binary file not shown.

@ -0,0 +1,155 @@
#!/usr/bin/perl -w
use strict;
use IO::Handle;
use Socket;
use Sys::Hostname;
use Getopt::Std;
STDERR->autoflush(1);
STDOUT->autoflush(1);
# getopts "H:p:b:a:v:s:t:
# b: base dn; a: atrib; v: value of attrib; s: search string; t: timeout
use vars qw($opt_d $opt_h $opt_H $opt_p $opt_b $opt_a $opt_v $opt_s $opt_t);
getopts("dhH:p:b:a:v:s:t:");
our $Usage = <<EOUSAGE;
Usage: $0 -H <hostname> [-p <port>] [-t <timeout>] -b <base DN> -a <attribute> -v <value> -s <result string>
EOUSAGE
(print $Usage and exit 3) if $opt_h;
if (!defined($opt_H) or !defined($opt_b) or !defined($opt_a) or !defined($opt_v) or !defined($opt_s)) {
print $Usage;
exit 3;
}
our $debug = $opt_d;
our $ThatHost = $opt_H;
our $ThatPort = defined($opt_p) ? $opt_p : 80;
our $TIMEOUT = defined($opt_t) ? $opt_t : 10;
# our $BaseDN = "o=Princeton University,c=US";
# our $Attrib = "uid";
# our $Value = "esm";
our $BaseDN = $opt_b;
our $Attrib = $opt_a;
our $Value = $opt_v;
our $SearchFor = $opt_s;
our @Result;
our $DSML = <<End_Of_Query;
<?xml version='1.0' encoding='UTF-8' ?>
<soap-env:Envelope
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'>
<soap-env:Body xmlns:dsml="urn:oasis:names:tc:DSML:2:0:core">
<batchRequest>
<searchRequest dn="$BaseDN"
scope="wholeSubtree"
derefAliases="neverDerefAliases"
sizeLimit="1">
<filter>
<equalityMatch name="$Attrib">
<value>$Value</value>
</equalityMatch>
</filter>
<attributes>
<attribute name="cn" />
</attributes>
</searchRequest>
</batchRequest>
</soap-env:Body>
</soap-env:Envelope>
End_Of_Query
our $LengthOfDSML = length($DSML);
our $ThisHost = hostname();
our ($AfInet, $SockStream, $SockAddr) = (AF_INET, SOCK_STREAM, 'S n a4 x8');
our ($Name, $Aliases, $Proto) = getprotobyname('tcp');
our ($Type, $Length) = (undef, undef);
our @ThisAddr = ();
our @ThatAddr = ();
($Name, $Aliases, $Type, $Length, @ThisAddr) = gethostbyname($ThisHost);
($Name, $Aliases, $Type, $Length, @ThatAddr) = gethostbyname($ThatHost);
our $This = pack ($SockAddr, $AfInet, 0, $ThisAddr[0]);
our $That = pack ($SockAddr, $AfInet, $ThatPort, $ThatAddr[0]);
if (socket(SOCKET, $AfInet, $SockStream, $Proto)) {
print STDOUT "TCP socket created\n" if $debug;
} else {
print "CRITICAL: Cannot connect to $ThatHost:$ThatPort\n";
exit 2;
}
## if (bind(SOCKET, $This)) {
## print STDOUT "Bound to $ThisHost\n";
## } else {
## die "Cannot bind to $ThisHost; $!\n";
## }
## our $Error = sprintf 'Timeout connecting to port %u of %s', $ThatPort, $ThatHost;
our $Error = '';
$SIG{ALRM} = sub { print "CRITICAL: Timeout connecting to $ThatHost:$ThatPort\n"; exit 2; };
alarm($TIMEOUT) if $TIMEOUT > 0;
if (connect(SOCKET, $That)) {
printf STDOUT "Connected to port %u of %s\n", $ThatPort, $ThatHost if $debug;
} else {
print "CRITICAL: Cannot connect to $ThatHost:$ThatPort\n";
exit 2;
}
alarm(0);
$SIG{ALRM} = 'DEFAULT';
SOCKET->autoflush(1);
our $HTTPandDSML = <<EODSML;
POST / HTTP/1.1
Host: $ThisHost
Content-Type: text/xml; charset="utf-8"
Content-Length: $LengthOfDSML
SOAPAction: dsml://$ThatHost/
$DSML
EODSML
select SOCKET; $|=1; select STDOUT;
$SIG{ALRM} = sub { print "CRITICAL: Timeout receiving response from $ThatHost:$ThatPort\n"; exit 2; };
alarm($TIMEOUT) if $TIMEOUT > 0;
print STDOUT $HTTPandDSML if $debug;
print SOCKET $HTTPandDSML;
while (<SOCKET>) {
print STDOUT if $debug;
chop;
push @Result, $_;
next unless m|</soap-env:Envelope>|is;
$Error = '';
last;
}
alarm(0);
$SIG{ALRM} = 'DEFAULT';
close SOCKET;
if ($Result[0] !~ /HTTP\/.*200 OK/) {
print "CRITICAL: DSML query returned $Result[0]\n";
exit 2;
}
my $s;
foreach $s (@Result) {
if ($s =~ /$SearchFor/) {
print "OK: lookup of $Attrib=$Value succeeded\n";
exit 0;
}
}
print "CRITICAL: lookup of $Attrib=$Value failed\n";
exit 2;

Binary file not shown.

@ -0,0 +1,974 @@
#!/usr/bin/perl
use strict;
use lib qw(/usr/local/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8);
my $VERSION = '0.7.1';
my $COPYRIGHT = 'Copyright (C) 2005-2011 Jonathan Buhacoff <jonathan@buhacoff.net>';
my $LICENSE = 'http://www.gnu.org/licenses/gpl.txt';
my %status = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3 );
# look for required modules
exit $status{UNKNOWN} unless load_modules(qw/Getopt::Long/);
BEGIN {
if( grep { /^--hires$/ } @ARGV ) {
eval "use Time::HiRes qw(time);";
warn "Time::HiRes not installed\n" if $@;
}
}
# get options from command line
Getopt::Long::Configure("bundling");
my $verbose = 0;
my $help = "";
my $help_usage = "";
my $show_version = "";
my $host = "";
my $smtp_server = "";
my $smtp_port = "";
my $imap_server = "";
my $smtp_username = "";
my $smtp_password = "";
my $smtp_tls = "";
my $imap_port = "";
my $imap_username = "";
my $imap_password = "";
my $imap_mailbox = "";
my $username = "";
my $password = "";
my $ssl = "";
my $imap_ssl = "";
my $mailto = "";
my $mailfrom = "";
my @header = ();
my $body = "";
my $warnstr = "";
my $critstr = "";
my $waitstr = "";
my $delay_warn = 95;
my $delay_crit = 300;
my $smtp_warn = 15;
my $smtp_crit = 30;
my $imap_warn = 15;
my $imap_crit = 30;
my $timeout = "";
my @alert_plugins = ();
my $imap_interval = 5;
my $imap_retries = 5;
my @plugins = ();
my @token_formats = ();
my $tokenfile = "";
my $default_crit = 30;
my $default_warn = 15;
my $default_wait = 5;
my $default_timeout = 60;
my $time_hires = "";
my $libexec = "/usr/local/monitoring/nagios/libexec";
my $ok;
$ok = Getopt::Long::GetOptions(
"V|version"=>\$show_version,
"v|verbose+"=>\$verbose,"h|help"=>\$help,"usage"=>\$help_usage,
"w|warning=s"=>\$warnstr,"c|critical=s"=>\$critstr, "t|timeout=s"=>\$timeout,
"libexec=s"=>\$libexec,
# plugin settings
"p|plugin=s"=>\@plugins, "T|token=s"=>\@token_formats,
"A|alert=i"=>\@alert_plugins,
"F|file=s"=>\$tokenfile,
# common settings
"H|hostname=s"=>\$host,
"U|username=s"=>\$username,"P|password=s"=>\$password,
"ssl!"=>\$ssl,
# smtp settings
"smtp-server=s"=>\$smtp_server,"smtp-port=i"=>\$smtp_port,
"mailto=s"=>\$mailto, "mailfrom=s",\$mailfrom,
"header=s"=>\@header, "body=s"=>\$body,
# smtp-tls settings
"smtptls!"=>\$smtp_tls,
"smtp-username=s"=>\$smtp_username,"smtp-password=s"=>\$smtp_password,
# delay settings
"wait=s"=>\$waitstr,
# imap settings
"imap-server=s"=>\$imap_server,"imap-port=i"=>\$imap_port,
"imap-username=s"=>\$imap_username,"imap-password=s"=>\$imap_password,
"imap-mailbox=s"=>\$imap_mailbox,
"imap-check-interval=i"=>\$imap_interval,"imap-retries=i"=>\$imap_retries,
"imapssl!"=>\$imap_ssl,
# Time
"hires"=>\$time_hires,
);
if( $show_version ) {
print "$VERSION\n";
if( $verbose ) {
print "Warning threshold: $delay_warn seconds\n";
print "Critical threshold: $delay_crit seconds\n";
print "Default wait: $default_wait seconds\n";
print "Default timeout: $default_timeout seconds\n";
}
exit $status{UNKNOWN};
}
if( $help ) {
exec "perldoc", $0 or print "Try `perldoc $0`\n";
exit $status{UNKNOWN};
}
if( $host ) {
$smtp_server = $host if $smtp_server eq "";
$imap_server = $host if $imap_server eq "";
}
if( $username ) {
$smtp_username = $username if $smtp_username eq "";
$imap_username = $username if $imap_username eq "";
}
if( $password ) {
$smtp_password = $password if $smtp_password eq "";
$imap_password = $password if $imap_password eq "";
}
if( $ssl ) {
$imap_ssl = $ssl if $imap_ssl eq "";
$smtp_tls = $ssl if $smtp_tls eq "";
}
if( $help_usage
||
(
scalar(@plugins) == 0
&&
(
$smtp_server eq "" || $mailto eq "" || $mailfrom eq ""
|| $imap_server eq "" || $username eq "" || $password eq ""
)
)
) {
print "Usage 1: $0 -H host \n\t".
"--mailto recipient\@your.net --mailfrom sender\@your.net --body 'message' \n\t".
"--username username --password password \n\t".
"[-w <seconds>] [-c <seconds>]\n\t" .
"[--imap-check-interval <seconds> ] [--imap-retries <times> ]\n";
print "Usage 2: $0 \n\t".
"-p 'first plugin command with %TOKEN1% embedded' \n\t".
"-p 'second plugin command with %TOKEN1% embedded' \n\t".
"[-w <seconds1>,<seconds2>] [-c <seconds1>,<seconds2>] \n";
exit $status{UNKNOWN};
}
# determine thresholds
my @warning_times = split(",", $warnstr);
my @critical_times = split(",", $critstr);
my @alarm_times = split(",", $timeout);
my @wait_times = split(",", $waitstr);
my ($dw,$sw,$rw) = split(",", $warnstr);
my ($dc,$sc,$rc) = split(",", $critstr);
my ($wait) = split(",", $waitstr);
$delay_warn = $dw if defined $dw and $dw ne "";
$smtp_warn = $sw if defined $sw and $sw ne "";
$imap_warn = $rw if defined $rw and $rw ne "";
$delay_crit = $dc if defined $dc and $dc ne "";
$smtp_crit = $sc if defined $sc and $sc ne "";
$imap_crit = $rc if defined $rc and $rc ne "";
my $smtp_thresholds = "";
$smtp_thresholds .= "-w $smtp_warn " if defined $smtp_warn and $smtp_warn ne "";
$smtp_thresholds .= "-c $smtp_crit " if defined $smtp_crit and $smtp_crit ne "";
my $imap_thresholds = "";
$imap_thresholds .= "-w $imap_warn " if defined $imap_warn and $imap_warn ne "";
$imap_thresholds .= "-c $imap_crit " if defined $imap_crit and $imap_crit ne "";
$imap_thresholds .= "--imap-check-interval $imap_interval " if defined $imap_interval and $imap_interval ne "";
$imap_thresholds .= "--imap-retries $imap_retries " if defined $imap_retries and $imap_retries ne "";
if( scalar(@alarm_times) == 1 ) {
$default_timeout = shift(@alarm_times);
}
# determine which other options to include
my $smtp_options = "";
$smtp_options .= "-H $smtp_server " if defined $smtp_server and $smtp_server ne "";
$smtp_options .= "-p $smtp_port " if defined $smtp_port and $smtp_port ne "";
$smtp_options .= "--tls " if defined $smtp_tls and $smtp_tls;
$smtp_options .= "-U ".shellquote($smtp_username)." " if defined $smtp_username and $smtp_username ne "";
$smtp_options .= "-P ".shellquote($smtp_password)." " if defined $smtp_password and $smtp_password ne "";
$smtp_options .= "--mailto ".shellquote($mailto)." " if defined $mailto and $mailto ne "";
$smtp_options .= "--mailfrom ".shellquote($mailfrom)." " if defined $mailfrom and $mailfrom ne "";
foreach my $h( @header ) {
$smtp_options .= "--header ".shellquote($h)." ";
}
my $imap_options = "";
$imap_options .= "-H $imap_server " if defined $imap_server and $imap_server ne "";
$imap_options .= "-p $imap_port " if defined $imap_port and $imap_port ne "";
$imap_options .= "-U ".shellquote($imap_username)." " if defined $imap_username and $imap_username ne "";
$imap_options .= "-P ".shellquote($imap_password)." " if defined $imap_password and $imap_password ne "";
$imap_options .= "--mailbox ".shellquote($imap_mailbox)." " if defined $imap_mailbox and $imap_mailbox ne "";
$imap_options .= "--ssl " if defined $imap_ssl and $imap_ssl;
# create the report object
my $report = new PluginReport;
my @report_plugins = (); # populated later with either (smtp,imap) or (plugin1,plugin2,...)
my $time_start; # initialized later with time the work actually starts
# create token formats for use with the plugins
my @alpha = qw/a b c d e f g h i j k l m n o p q r s t u v w x y z/;
my @numeric = qw/0 1 2 3 4 5 6 7 8 9/;
my @hex = qw/0 1 2 3 4 5 6 7 8 9 a b c d e f/;
my @pgp_even = qw/aardvark absurd accrue acme adrift adult afflict ahead aimless Algol allow alone ammo ancient apple artist assume Athens atlas Aztec baboon backfield backward banjo beaming bedlamp beehive beeswax befriend Belfast berserk billiard bison blackjack blockade blowtorch bluebird bombast bookshelf brackish breadline breakup brickyard briefcase Burbank button buzzard cement chairlift chatter checkup chisel choking chopper Christmas clamshell classic classroom cleanup clockwork cobra commence concert cowbell crackdown cranky crowfoot crucial crumpled crusade cubic dashboard deadbolt deckhand dogsled dragnet drainage dreadful drifter dropper drumbeat drunken Dupont dwelling eating edict egghead eightball endorse endow enlist erase escape exceed eyeglass eyetooth facial fallout flagpole flatfoot flytrap fracture framework freedom frighten gazelle Geiger glitter glucose goggles goldfish gremlin guidance hamlet highchair hockey indoors indulge inverse involve island jawbone keyboard kickoff kiwi klaxon locale lockup merit minnow miser Mohawk mural music necklace Neptune newborn nightbird Oakland obtuse offload optic orca payday peachy pheasant physique playhouse Pluto preclude prefer preshrunk printer prowler pupil puppy python quadrant quiver quota ragtime ratchet rebirth reform regain reindeer rematch repay retouch revenge reward rhythm ribcage ringbolt robust rocker ruffled sailboat sawdust scallion scenic scorecard Scotland seabird select sentence shadow shamrock showgirl skullcap skydive slingshot slowdown snapline snapshot snowcap snowslide solo southward soybean spaniel spearhead spellbind spheroid spigot spindle spyglass stagehand stagnate stairway standard stapler steamship sterling stockman stopwatch stormy sugar surmount suspense sweatband swelter tactics talon tapeworm tempest tiger tissue tonic topmost tracker transit trauma treadmill Trojan trouble tumor tunnel tycoon uncut unearth unwind uproot upset upshot vapor village virus Vulcan waffle wallet watchword wayside willow woodlark Zulu/;
my @pgp_odd = qw/adroitness adviser aftermath aggregate alkali almighty amulet amusement antenna applicant Apollo armistice article asteroid Atlantic atmosphere autopsy Babylon backwater barbecue belowground bifocals bodyguard bookseller borderline bottomless Bradbury bravado Brazilian breakaway Burlington businessman butterfat Camelot candidate cannonball Capricorn caravan caretaker celebrate cellulose certify chambermaid Cherokee Chicago clergyman coherence combustion commando company component concurrent confidence conformist congregate consensus consulting corporate corrosion councilman crossover crucifix cumbersome customer Dakota decadence December decimal designing detector detergent determine dictator dinosaur direction disable disbelief disruptive distortion document embezzle enchanting enrollment enterprise equation equipment escapade Eskimo everyday examine existence exodus fascinate filament finicky forever fortitude frequency gadgetry Galveston getaway glossary gossamer graduate gravity guitarist hamburger Hamilton handiwork hazardous headwaters hemisphere hesitate hideaway holiness hurricane hydraulic impartial impetus inception indigo inertia infancy inferno informant insincere insurgent integrate intention inventive Istanbul Jamaica Jupiter leprosy letterhead liberty maritime matchmaker maverick Medusa megaton microscope microwave midsummer millionaire miracle misnomer molasses molecule Montana monument mosquito narrative nebula newsletter Norwegian October Ohio onlooker opulent Orlando outfielder Pacific pandemic Pandora paperweight paragon paragraph paramount passenger pedigree Pegasus penetrate perceptive performance pharmacy phonetic photograph pioneer pocketful politeness positive potato processor provincial proximate puberty publisher pyramid quantity racketeer rebellion recipe recover repellent replica reproduce resistor responsive retraction retrieval retrospect revenue revival revolver sandalwood sardonic Saturday savagery scavenger sensation sociable souvenir specialist speculate stethoscope stupendous supportive surrender suspicious sympathy tambourine telephone therapist tobacco tolerance tomorrow torpedo tradition travesty trombonist truncated typewriter ultimate undaunted underfoot unicorn unify universe unravel upcoming vacancy vagabond vertigo Virginia visitor vocalist voyager warranty Waterloo whimsical Wichita Wilmington Wyoming yesteryear Yucatan/;
my %formats = (
'a' => sub { pick_random(@alpha) },
'n' => sub { pick_random(@numeric) },
'c' => sub { pick_random(@alpha,@numeric) },
'h' => sub { pick_random(@hex) },
'U' => sub { time },
'X' => sub { pick_random(@pgp_even) },
'Y' => sub { pick_random(@pgp_odd) },
);
if( scalar(@plugins) ) {
# scan the plugin commands for use of tokens to count how many we need
my $token_count = 0;
foreach my $p (@plugins) {
my @matches = sort ($p =~ m/%TOKEN(\d+)%/g);
my $max = pop @matches;
$token_count = $max if defined($max) && $max > $token_count;
}
# create the tokens
my @tokens = ();
foreach my $t (1..$token_count) {
my $format = shift @token_formats;
$format = "U-X-Y" unless $format;
my @format_characters = split(//, $format);
my $token = "";
foreach my $c (@format_characters) {
if( defined $formats{$c} ) {
$token .= &{$formats{$c}};
}
else {
$token .= $c;
}
}
push @tokens, $token;
}
# substitute the tokens into each plugin command
foreach my $p (@plugins) {
foreach my $t (1..$token_count) {
my $token = $tokens[$t-1];
$p =~ s/%TOKEN$t%/$token/g;
}
}
# mark plugins that are allowed to generate alerts. default behavior is to alert for all plugins.
my %alert_plugins = ();
if( scalar(@alert_plugins) > 0 ) {
%alert_plugins = map { $_ => 1 } @alert_plugins;
}
else {
%alert_plugins = map { $_ => 1 } (1..scalar(@plugins));
}
# run each plugin and store its output in a report
$time_start = time;
my $i = 0;
foreach my $p( @plugins ) {
$i++;
my $plugin_timeout = shift(@alarm_times) || $default_timeout;
# run the plugin
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $plugin_timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $plugin_timeout;
my $output = `$p`;
chomp $output;
if( $output !~ m/OK|WARNING|CRITICAL/ ) {
print "EMAIL DELIVERY UNKNOWN - plugin $i error: $output\n";
print "Plugin $i: $p\n" if $verbose;
# record tokens in a file if option is enabled
record_tokens($tokenfile,\@tokens,$time_start,undef,'UNKNOWN',$i,$output) if $tokenfile;
exit $status{UNKNOWN};
}
if( $output =~ m/CRITICAL/ && $alert_plugins{$i} ) {
print "EMAIL DELIVERY CRITICAL - plugin $i failed: $output\n";
print "Plugin $i: $p" if $verbose;
# record tokens in a file if option is enabled
record_tokens($tokenfile,\@tokens,$time_start,undef,'CRITICAL',$i,$output) if $tokenfile;
exit $status{CRITICAL};
}
if( $output =~ m/WARNING/ && $alert_plugins{$i} ) {
print "EMAIL DELIVERY WARNING - plugin $i warning: $output\n";
print "Plugin $i: $p\n" if $verbose;
# record tokens in a file if option is enabled
record_tokens($tokenfile,\@tokens,$time_start,undef,'WARNING',$i,$output) if $tokenfile;
exit $status{WARNING};
}
$report->{"plugin".$i} = $output;
alarm 0;
};
if( $@ && $alert_plugins{$i} ) {
print "EMAIL DELIVERY CRITICAL - Could not run plugin $i: $@\n";
print "Plugin $i: $p\n" if $verbose;
exit $status{CRITICAL};
}
# if this wasn't the last plugin, wait before continuing
if( $i < scalar(@plugins) ) {
my $wait = shift(@wait_times) || $default_wait;
sleep $wait;
}
# compatibility with the "not using plugins" method... pretend to calculate the total round trip time (the delay) using data from the plugins ...
$report->{max} = 0;
$report->{delay} = 0;
}
# register the list of reports
foreach my $r ( 1..scalar(@plugins)) {
push @report_plugins, "plugin".$r;
}
# record tokens in a file if option is enabled
my $tmp_long_report = join(", ", map { "$_: $report->{$_}" } @report_plugins ) if $tokenfile;
record_tokens($tokenfile,\@tokens,$time_start,time,'OK',scalar(@plugins),$tmp_long_report) if $tokenfile;
}
else {
# not using plugins.
$time_start = time;
# send email via SMTP
my $id = $time_start; # XXX should include localhost name maybe or some random number in case the same mailbox is used for multiple delivery tests
my $smtp_plugin = "$libexec/check_smtp_send";
$smtp_plugin = "$libexec/check_smtp_send.pl" unless -e $smtp_plugin;
my $smtp_timeout = shift(@alarm_times) || $default_timeout;
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $smtp_timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $smtp_timeout;
my $smtp = `$smtp_plugin $smtp_options --header 'Subject: Nagios Message SMTP $smtp_server ID $id.' --body 'Nagios Email Delivery Plugin\n$body' $smtp_thresholds`;
if( $smtp !~ m/OK|WARNING|CRITICAL/ ) {
print "EMAIL DELIVERY UNKNOWN - smtp unknown: $smtp\n";
exit $status{UNKNOWN};
}
if( $smtp =~ m/CRITICAL/ ) {
print "EMAIL DELIVERY CRITICAL - smtp failed: $smtp\n";
exit $status{CRITICAL};
}
chomp $smtp;
$report->{smtp} = $smtp;
alarm 0;
};
if( $@ ) {
print "EMAIL DELIVERY CRITICAL - Could not connect to SMTP server $smtp_server: $@\n";
exit $status{CRITICAL};
}
# wait before checking the delivery
$wait = shift(@wait_times) || $default_wait;
sleep $wait;
# check email via IMAP
my $imap_plugin = "$libexec/check_imap_receive";
$imap_plugin = "$libexec/check_imap_receive.pl" unless -e $imap_plugin;
my $imap_timeout = shift(@alarm_times) || $default_timeout;
eval {
local $SIG{ALRM} = sub { die "exceeded timeout $imap_timeout seconds\n" }; # NB: \n required, see `perldoc -f alarm`
alarm $imap_timeout;
my $imap = `$imap_plugin $imap_options -s SUBJECT -s 'Nagios Message SMTP $smtp_server ID' --capture-max 'Nagios Message SMTP $smtp_server ID (\\d+)' --nodelete-captured $imap_thresholds`;
if( $imap !~ m/OK|WARNING|CRITICAL/ ) {
print "EMAIL DELIVERY UNKNOWN - imap unknown: $imap\n";
exit $status{UNKNOWN};
}
if( $imap =~ m/CRITICAL/ ) {
print "EMAIL DELIVERY CRITICAL - imap failed: $imap\n";
exit $status{CRITICAL};
}
if( $imap =~ m/ (\d+) max/ ) {
my $last_received = $1;
$report->{max} = $1;
my $delay = time - $last_received;
$report->{delay} = $delay;
}
chomp $imap;
$report->{imap} = $imap;
alarm 0;
};
if( $@ ) {
print "EMAIL DELIVERY CRITICAL - Could not connect to IMAP server $imap_server: $@\n";
exit $status{CRITICAL};
}
# register the list of reports
push @report_plugins, ("smtp","imap");
}
# calculate elapsed time and issue warnings
my $time_end = time;
my $elapsedtime = $time_end - $time_start;
$report->{seconds} = $elapsedtime;
my @warning = ();
my @critical = ();
push @warning, "most recent received $report->{delay} seconds ago" if( defined($report->{delay}) && $report->{delay} > $delay_warn );
push @critical, "most recent received $report->{delay} seconds ago" if( defined($report->{delay}) && $report->{delay} > $delay_crit );
push @warning, "no emails found" if( !defined($report->{delay}) );
# print report and exit with known status
my $perf_data = "delay=".$report->{delay}."s;$delay_warn;$delay_crit;0 elapsed=".$report->{seconds}."s"; # TODO: need a component for safely generating valid perf data format. for notes on the format, see http://www.perfparse.de/tiki-view_faq.php?faqId=6
my $short_report = $report->text(qw/seconds delay/) . " | $perf_data";
my $long_report = join("", map { "$_: $report->{$_}\n" } @report_plugins );
if( scalar @critical ) {
my $alerts = join(", ", @critical);
print "EMAIL DELIVERY CRITICAL - $alerts; $short_report\n";
print $long_report if $verbose;
exit $status{CRITICAL};
}
if( scalar @warning ) {
my $alerts = join(", ", @warning);
print "EMAIL DELIVERY WARNING - $alerts; $short_report\n";
print $long_report if $verbose;
exit $status{WARNING};
}
print "EMAIL DELIVERY OK - $short_report\n";
print $long_report if $verbose;
exit $status{OK};
# utility to load required modules. exits if unable to load one or more of the modules.
sub load_modules {
my @missing_modules = ();
foreach( @_ ) {
eval "require $_";
push @missing_modules, $_ if $@;
}
if( @missing_modules ) {
print "Missing perl modules: @missing_modules\n";
return 0;
}
return 1;
}
# returns one random character from a set of characters
sub pick_random {
my @set = @_;
my $size = scalar @set;
my $string = $set[int(rand($size))];
return $string;
}
# appens tokens and times to a tab-separated value file
sub record_tokens {
my ($tokenfile,$tokens,$time_start,$time_end,$status,$plugin_num,$output) = @_;
if( $tokenfile ) {
my @tokens = @$tokens;
$time_end = "" unless defined $time_end;
$status = "" unless defined $status;
$plugin_num = "" unless defined $plugin_num;
$output = "" unless defined $output;
print "saving ".scalar(@tokens)." tokens into $tokenfile\n" if $verbose;
open(TOKENFILE,">>$tokenfile");
foreach(@tokens) {
print TOKENFILE "$_\t$time_start\t$time_end\t$status\t$plugin_num\t$output\n";
}
close(TOKENFILE);
}
}
# wraps argument in single-quotes and escapes any single-quotes in the argument
sub shellquote {
my $str = shift || "";
$str =~ s/\'/\'\\\'\'/g;
return "'$str'";
}
# NAME
# PluginReport
# SYNOPSIS
# $report = new PluginReport;
# $report->{label1} = "value1";
# $report->{label2} = "value2";
# print $report->text(qw/label1 label2/);
package PluginReport;
sub new {
my ($proto,%p) = @_;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
$self->{$_} = $p{$_} foreach keys %p;
return $self;
}
sub text {
my ($self,@labels) = @_;
my @report = map { "$self->{$_} $_" } grep { defined $self->{$_} } @labels;
my $text = join(", ", @report);
return $text;
}
package main;
1;
__END__
=pod
=head1 NAME
check_email_delivery - sends email and verifies delivery
=head1 SYNOPSIS
check_email_delivery -vV
check_email_delivery --usage
check_email_delivery --help
=head1 OPTIONS
=over
=item --warning <seconds>[,<smtp_seconds>,<imap_seconds>]
Exit with WARNING if the most recent email found is older than <seconds>. The
optional <smtp_seconds> and <imap_seconds> parameters will be passed on to the
included plugins that are used for those tasks. If they are not
given then they will not be passed on and the default for that plugin will apply.
Also known as: -w <seconds>[,<send>[,<recv>]]
When using the --plugin option, only one parameter is supported (-w <seconds>) and it will apply
to the entire process. You can specify a warning threshold specific to each plugin in the
plugin command line.
When using the --plugin option, no measuring of "most recent email" is done because we would
not know how to read this information from receive plugins. This may be addressed in future versions.
=item --critical <seconds>[,<smtp_seconds>,<imap_seconds>]
Exit with CRITICAL if the most recent email found is older than <seconds>. The
optional <smtp_seconds> and <imap_seconds> parameters will be passed on to the
included plugins that are used for those tasks. If they are not
given then they will not be passed on and the default for that plugin will apply.
Also known as: -c <seconds>[,<send>[,<recv>]]
When using the --plugin option, only one parameter is supported (-c <seconds>) and it will apply
to the entire process. You can specify a critical threshold specific to each plugin in the
plugin command line.
When using the --plugin option, no measuring of "most recent email" is done because we would
not know how to read this information from receive plugins. This may be addressed in future versions.
=item --timeout <seconds>
=item --timeout <smtp_seconds>,<imap_seconds>
=item --timeout <plugin1_seconds>,<plugin2_seconds>,...
Exit with CRITICAL if the plugins do not return a status within the specified number of seconds.
When only one parameter is used, it applies to each plugin. When multiple parameters are used
(separated by commas) they apply to plugins in the same order the plugins were specified on the
command line. When using --timeout but not the --plugin option, the first parameter is for
check_smtp_send and the second is for check_imap_receive.
=item --alert <pluginN>
Exit with WARNING or CRITICAL only if a warning or error (--warning, --critical, or --timeout)
occurs for specified plugins. If a warning or error occurs for non-specified plugins that run
BEFORE the specified plugins, the exit status will be UNKNOWN. If a warning of error occurs
for non-specified plugins that run AFTER the specified plugins, the exit status will not be
affected.
You would use this option if you are using check_email_delivery with the --plugin option and
the plugins you configure each use different servers, for example different SMTP and IMAP servers.
By default, if you do not use the --alert option, if anything goes wrong during the email delivery
check, a WARNING or CRITICAL alert will be issued. This means that if you define check_email_delivery
for the SMTP server only and the IMAP server fails, Nagios will alert you for the SMTP server which
would be misleading. If you define it for both the SMTP server and IMAP server and just one of them
fails, Nagios will alert you for both servers, which would still be misleading. If you have this
situation, you may want to use the --alert option. You define the check_email_delivery check for
both servers: for the SMTP server (first plugin) you use --alert 1, and for for the IMAP server
(second plugin) you use --alert 2. When check_email_delivery runs with --alert 1 and the SMTP
server fails, you will get the appropriate alert. If the IMAP server fails it will not affect the
status. When check_email_delivery runs with --alert 2 and the SMTP server fails, you will get the
UNKNOWN return code. If the IMAP server generates an alert you will get a WARNING or CRITICAL as
appropriate.
You can repeat this option to specify multiple plugins that should cause an alert.
Do this if you have multiple plugins on the command line but some of them involve the same server.
See also: --plugin.
Also known as: -A <pluginN>
=item --wait <seconds>[,<seconds>,...]
How long to wait between sending the message and checking that it was received. View default with
the -vV option.
When using the --plugin option, you can specify as many wait-between times as you have plugins
(minus the last plugin, because it makes no sense to wait after running the last one). For
example, if you use the --plugin option twice to specify an SMTP plugin and an IMAP plugin, and
you want to wait 5 seconds between sending and receiving, then you would specify --wait 5. A second
example, if you are using the --plugin option three times, then specifying -w 5 will wait 5 seconds
between the second and third plugins also. You can specify a different wait time
of 10 seconds between the second and third plugins, like this: -w 5,10.
=item --hostname <server>
Address or name of the SMTP and IMAP server. Examples: mail.server.com, localhost, 192.168.1.100.
Also known as: -H <server>
=item --smtp-server <server>
Address or name of the SMTP server. Examples: smtp.server.com, localhost, 192.168.1.100.
Using this option overrides the hostname option.
=item --smtp-port <number>
Service port on the SMTP server. Default is 25.
=item --smtp-username <username>
=item --smtp-password <password>
Username and password to use when connecting to the SMTP server with the TLS option.
Use these options if the SMTP account has a different username/password than the
IMAP account you are testing. These options take precendence over the --username and
the --password options.
These are shell-escaped; special characters are ok.
=item --imap-server <server>
Address or name of the IMAP server. Examples: imap.server.com, localhost, 192.168.1.100.
Using this option overrides the hostname option.
=item --imap-port <number>
Service port on the IMAP server. Default is 143. If you use SSL the default is 993.
=item --imap-username <username>
=item --imap-password <password>
Username and password to use when connecting to the IMAP server.
Use these options if the IMAP account has a different username/password than the
SMTP account you are testing. These options take precendence over the --username and
the --password options.
These are shell-escaped; special characters are ok.
=item --username <username>
=item --password <password>
Username and password to use when connecting to IMAP server.
Also known as: -U <username> -P <password>
Also used as the username and password for SMTP when the TLS option is enabled.
To specify a separate set of credentials for SMTP authentication, see the
options --smtp-username and --smtp-password.
=item --imap-check-interval <seconds>
How long to wait between polls of the imap-server for the specified mail. Default is 5 seconds.
=item --imap-retries <times>
How many times to poll the imap-server for the mail, before we give up. Default is 10.
=item --body <message>
Use this option to specify the body of the email message.
=item --header <header>
Use this option to set an arbitrary header in the message. You can use it multiple times.
=item --mailto recipient@your.net
You can send a message to multiple recipients by repeating this option or by separating
the email addresses with commas (no whitespace allowed):
$ check_email_delivery ... --mailto recipient@your.net,recipient2@your.net --mailfrom sender@your.net
This argument is shell-escaped; special characters or angle brackets around the address are ok.
=item --mailfrom sender@your.net
Use this option to set the "from" address in the email.
=item --imapssl
=item --noimapssl
Use this to enable or disable SSL for the IMAP plugin.
This argument is shell-escaped; special characters or angle brackets around the address are ok.
=item --smtptls
=item --nosmtptls
Use this to enable or disable TLS/AUTH for the SMTP plugin.
=item --libexec
Use this option to set the path of the Nagios libexec directory. The default is
/usr/local/monitoring/nagios/libexec. This is where this plugin looks for the SMTP and IMAP
plugins that it depends on.
=item --plugin <command>
This is a new option introduced in version 0.5 of the check_email_delivery plugin.
It frees the plugin from depending on specific external plugins and generalizes the
work done to determine that the email loop is operational. When using the --plugin
option, the following options are ignored: libexec, imapssl, smtptls, hostname,
username, password, smtp*, imap*, mailto, mailfrom, body, header, search.
Use this option multiple times to specify the complete trip. Typically, you would use
this twice to specify plugins for SMTP and IMAP, or SMTP and POP3.
The output will be success if all the plugins return success. Each plugin should be a
standard Nagios plugin.
A random token will be automatically generated and passed to each plugin specified on
the command line by substituting the string %TOKEN1%.
Example usage:
command_name check_email_delivery
command_line check_email_delivery
--plugin "$USER1$/check_smtp_send -H $ARG1$ --mailto recipient@your.net --mailfrom sender@your.net --header 'Subject: Nagios Test %TOKEN1%.'"
--plugin "$USER1$/check_imap_receive -H $ARG1$ -U $ARG1$ -P $ARG2$ -s SUBJECT -s 'Nagios Test %TOKEN1%.'"
This technique allows for a lot of flexibility in configuring the plugins that test
each part of your email delivery loop.
See also: --token.
Also known as: -p <command>
=item --token <format>
This is a new option introduced in version 0.5 of the check_email_delivery plugin.
It can be used in conjunction with --plugin to control the tokens that are generated
and passed to the plugins, like %TOKEN1%.
Use this option multiple times to specify formats for different tokens. For example,
if you want %TOKEN1% to consist of only alphabetical characters but want %TOKEN2% to
consist of only digits, then you might use these options: --token aaaaaa --token nnnnn
Any tokens used in your plugin commands that have not been specified by --token <format>
will default to --token U-X-Y
Token formats:
a - alpha character (a-z)
n - numeric character (0-9)
c - alphanumeric character (a-z0-9)
h - hexadecimal character (0-9a-f)
U - unix time, seconds from epoch. eg 1193012441
X - a word from the pgp even list. eg aardvark
Y - a word from the pgp odd list. eg adroitness
Caution: It has been observed that some IMAP servers do not handle underscores well in the
search criteria. For best results, avoid using underscores in your tokens. Use hyphens or commas instead.
See also: --plugin.
Also known as: -T <format>
The PGP word list was obtained from http://en.wikipedia.org/wiki/PGP_word_list
=item --file <file>
Save (append) status information into the given tab-delimited file. Format used:
token start-time end-time status plugin-num output
Note: format may change in future versions and may become configurable.
This option available as of version 0.6.2.
Also known as: -F <file>
=item --hires
Use the Time::HiRes module to measure time, if available.
=item --verbose
Display additional information. Useful for troubleshooting. Use together with --version to see the default
warning and critical timeout values.
Also known as: -v
=item --version
Display plugin version and exit.
Also known as: -V
=item --help
Display this documentation and exit. Does not work in the ePN version.
Also known as: -h
=item --usage
Display a short usage instruction and exit.
=back
=head1 EXAMPLES
=head2 Send a message with custom headers
$ check_email_delivery -H mail.server.net --mailto recipient@your.net --mailfrom sender@your.net
--username recipient --password secret
EMAIL DELIVERY OK - 1 seconds
=head2 Set warning and critical timeouts for receive plugin only:
$ check_email_delivery -H mail.server.net --mailto recipient@your.net --mailfrom sender@your.net
--username recipient --password secret -w ,,5 -c ,,15
EMAIL DELIVERY OK - 1 seconds
=head1 EXIT CODES
Complies with the Nagios plug-in specification:
0 OK The plugin was able to check the service and it appeared to be functioning properly
1 Warning The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly
2 Critical The plugin detected that either the service was not running or it was above some "critical" threshold
3 Unknown Invalid command line arguments were supplied to the plugin or the plugin was unable to check the status of the given hosts/service
=head1 NAGIOS PLUGIN NOTES
Nagios plugin reference: http://nagiosplug.sourceforge.net/developer-guidelines.html
This plugin does NOT use Nagios DEFAULT_SOCKET_TIMEOUT (provided by utils.pm as $TIMEOUT) because
the path to utils.pm must be specified completely in this program and forces users to edit the source
code if their install location is different (if they realize this is the problem). You can view
the default timeout for this module by using the --verbose and --version options together. The
short form is -vV.
Other than that, it attempts to follow published guidelines for Nagios plugins.
=head1 CHANGES
Wed Oct 29 13:08:00 PST 2005
+ version 0.1
Wed Nov 9 17:16:09 PST 2005
+ updated arguments to check_smtp_send and check_imap_receive
+ added eval/alarm block to implement -c option
+ added wait option to adjust sleep time between smtp and imap calls
+ added delay-warn and delay-crit options to adjust email delivery warning thresholds
+ now using an inline PluginReport package to generate the report
+ copyright notice and GNU GPL
+ version 0.2
Thu Apr 20 14:00:00 CET 2006 (by Johan Nilsson <johann (at) axis.com>)
+ version 0.2.1
+ corrected bug in getoptions ($imap_server would never ever be set from command-line...)
+ will not make $smtp_server and $imap_server == $host if they're defined on commandline
+ added support for multiple polls of imap-server, with specified intervals
+ changed default behaviour in check_imap_server (searches for the specific id in subject and deletes mails found)
+ increased default delay_warn from 65 seconds to 95 seconds
Thu Apr 20 16:00:00 PST 2006 (by Geoff Crompton <geoff.crompton@strategicdata.com.au>)
+ fixed a bug in getoptions
+ version 0.2.2
Tue Apr 24 21:17:53 PDT 2007
+ now there is an alternate version (same but without embedded perl POD) that is compatible with the new new embedded-perl Nagios feature
+ version 0.2.3
Fri Apr 27 20:32:53 PDT 2007
+ documentation now mentions every command-line option accepted by the plugin, including abbreviations
+ changed connection error to display timeout only if timeout was the error
+ default IMAP plugin is libexec/check_imap_receive (also checking for same but with .pl extension)
+ default SMTP plugin is libexec/check_smtp_send (also checking for same but with .pl extension)
+ removed default values for SMTP port and IMAP port to allow those plugins to set the defaults; so current behavior stays the same and will continue to make sense with SSL
+ version 0.3
Thu Oct 11 10:00:00 EET 2007 (by Timo Virtaneva <timo (at) virtaneva dot com>
+ Changed the header and the search criteria so that the same email-box can be used for all smtp-servers
+ version 0.3.1
Sun Oct 21 11:01:03 PDT 2007
+ added support for TLS options to the SMTP plugin
+ version 0.4
Sun Oct 21 16:17:14 PDT 2007
+ added support for arbitrary plugins to send and receive mail (or anthing else!). see the --plugin option.
+ version 0.5
Tue Dec 4 07:36:20 PST 2007
+ added --usage option because the official nagios plugins have both --help and --usage
+ added --timeout option to match the official nagios plugins
+ shortcut option for --token is now -T to avoid clash with standard shortcut -t for --timeout
+ fixed some minor pod formatting issues for perldoc
+ version 0.5.1
Sat Dec 15 07:39:59 PST 2007
+ improved compatibility with Nagios embedded perl (ePN)
+ version 0.5.2
Thu Jan 17 20:27:36 PST 2008 (by Timo Virtaneva <timo (at) virtaneva dot com> on Thu Oct 11 10:00:00 EET 2007)
+ Changed the header and the search criteria so that the same email-box can be used for all smtp-servers
+ version 0.5.3
Mon Jan 28 22:11:02 PST 2008
+ fixed a bug, smtp-password and imap-password are now string parameters
+ added --alert option to allow selection of which plugin(s) should cause a WARNING or CRITICAL alert
+ version 0.6
Mon Feb 11 19:09:37 PST 2008
+ fixed a bug for embedded perl version, variable "%status" will not stay shared in load_modules
+ version 0.6.1
Mon May 26 10:39:19 PDT 2008
+ added --file option to allow plugin to record status information into a tab-delimited file
+ changed default token from U_X_Y to U-X-Y
+ version 0.6.2
Wed Jan 14 08:29:35 PST 2009
+ fixed a bug that the --header parameter was not being passed to the smtp plugin.
+ version 0.6.3
Mon Jun 8 15:43:48 PDT 2009
+ added performance data for use with PNP4Nagios! (thanks to Ben Ritcey for the patch)
+ version 0.6.4
Wed Sep 16 07:10:10 PDT 2009
+ added elapsed time in seconds to performance data
+ version 0.6.5
Fri Oct 8 19:48:44 PDT 2010
+ fixed uniform IMAP and SMTP username and password bug (thanks to Micle Moerenhout for pointing it out)
+ version 0.6.6
Mon Jan 3 08:24:23 PST 2011
+ added shell escaping for smtp-username, smtp-password, mailto, mailfrom, imap-username, and imap-password arguments
+ version 0.7.0
Fri May 6 08:35:09 AST 2011
+ added --hires option to enable use of Time::Hires if available
+ version 0.7.1
Sun Jun 12 17:17:06 AST 2011
+ added --imap-mailbox option to pass through to check_imap_receive --mailbox option
+ added --ssl option to conveniently enable both --smtp-tls and --imap-ssl
+ version 0.7.2
=head1 AUTHOR
Jonathan Buhacoff <jonathan@buhacoff.net>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2005-2011 Jonathan Buhacoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
http://www.gnu.org/licenses/gpl.txt
=cut

@ -0,0 +1,840 @@
#!/usr/local/monitoring/bin/python
# -*- coding: UTF-8 -*-
#
# Script for checking global health of host running VMware ESX/ESXi
#
# Licence : GNU General Public Licence (GPL) http://www.gnu.org/
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Pre-req : pywbem
#
# Copyright (c) 2008 David Ligeret
# Copyright (c) 2009 Joshua Daniel Franklin
# Copyright (c) 2010 Branden Schneider
# Copyright (c) 2010-2013 Claudio Kuenzler
# Copyright (c) 2010 Samir Ibradzic
# Copyright (c) 2010 Aaron Rogers
# Copyright (c) 2011 Ludovic Hutin
# Copyright (c) 2011 Carsten Schoene
# Copyright (c) 2011-2012 Phil Randal
# Copyright (c) 2011 Fredrik Aslund
# Copyright (c) 2011 Bertrand Jomin
# Copyright (c) 2011 Ian Chard
# Copyright (c) 2012 Craig Hart
# Copyright (c) 2013 Carl R. Friend
#
# The VMware 4.1 CIM API is documented here:
# http://www.vmware.com/support/developer/cim-sdk/4.1/smash/cim_smash_410_prog.pdf
# http://www.vmware.com/support/developer/cim-sdk/smash/u2/ga/apirefdoc/
#
# The VMware 5.x CIM API is documented here:
# http://pubs.vmware.com/vsphere-50/index.jsp?nav=/5_1_1
#
# This Nagios plugin is maintained here:
# http://www.claudiokuenzler.com/nagios-plugins/check_esxi_hardware.php
#
#@---------------------------------------------------
#@ History
#@---------------------------------------------------
#@ Date : 20080820
#@ Author : David Ligeret
#@ Reason : Initial release
#@---------------------------------------------------
#@ Date : 20080821
#@ Author : David Ligeret
#@ Reason : Add verbose mode
#@---------------------------------------------------
#@ Date : 20090219
#@ Author : Joshua Daniel Franklin
#@ Reason : Add try/except to catch AuthError and CIMError
#@---------------------------------------------------
#@ Date : 20100202
#@ Author : Branden Schneider
#@ Reason : Added HP Support (HealthState)
#@---------------------------------------------------
#@ Date : 20100512
#@ Author : Claudio Kuenzler www.claudiokuenzler.com
#@ Reason : Combined different versions (Joshua and Branden)
#@ Reason : Added hardware type switch (dell or hp)
#@---------------------------------------------------
#@ Date : 20100626/28
#@ Author : Samir Ibradzic www.brastel.com
#@ Reason : Added basic server info
#@ Reason : Wanted to have server name, serial number & bios version at output
#@ Reason : Set default return status to Unknown
#@---------------------------------------------------
#@ Date : 20100702
#@ Author : Aaron Rogers www.cloudmark.com
#@ Reason : GlobalStatus was incorrectly getting (re)set to OK with every CIM element check
#@---------------------------------------------------
#@ Date : 20100705
#@ Author : Claudio Kuenzler www.claudiokuenzler.com
#@ Reason : Due to change 20100702 all Dell servers would return UNKNOWN instead of OK...
#@ Reason : ... so added Aaron's logic at the end of the Dell checks as well
#@---------------------------------------------------
#@ Date : 20101028
#@ Author : Claudio Kuenzler www.claudiokuenzler.com
#@ Reason : Changed text in Usage and Example so people dont forget to use https://
#@---------------------------------------------------
#@ Date : 20110110
#@ Author : Ludovic Hutin (Idea and Coding) / Claudio Kuenzler (Bugfix)
#@ Reason : If Dell Blade Servers are used, Serial Number of Chassis was returned
#@---------------------------------------------------
#@ Date : 20110207
#@ Author : Carsten Schoene carsten.schoene.cc
#@ Reason : Bugfix for Intel systems (in this case Intel SE7520) - use 'intel' as system type
#@---------------------------------------------------
#@ Date : 20110215
#@ Author : Ludovic Hutin
#@ Reason : Plugin now catches Socket Error (Timeout Error) and added a timeout parameter
#@---------------------------------------------------
#@ Date : 20110217/18
#@ Author : Ludovic Hutin / Tom Murphy
#@ Reason : Bugfix in Socket Error if clause
#@---------------------------------------------------
#@ Date : 20110221
#@ Author : Claudio Kuenzler www.claudiokuenzler.com
#@ Reason : Remove recently added Timeout due to incompabatility on Windows
#@ Reason : and changed name of plugin to check_esxi_hardware
#@---------------------------------------------------
#@ Date : 20110426
#@ Author : Claudio Kuenzler www.claudiokuenzler.com
#@ Reason : Added 'ibm' hardware type (compatible to Dell output). Tested by Keith Erekson.
#@---------------------------------------------------
#@ Date : 20110426
#@ Author : Phil Randal
#@ Reason : URLise Dell model and tag numbers (as in check_openmanage)
#@ Reason : Return performance data (as in check_openmanage, using similar names where possible)
#@ Reason : Minor code tidyup - use elementName instead of instance['ElementName']
#@---------------------------------------------------
#@ Date : 20110428
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : If hardware type is specified as 'auto' try to autodetect vendor
#@ Reason : Return performance data for some HP models
#@ Reason : Indent 'verbose' output to make it easier to read
#@ Reason : Use OptionParser to give better parameter parsing (retaining compatability with original)
#@---------------------------------------------------
#@ Date : 20110503
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : Fix bug in HP Virtual Fan percentage output
#@ Reason : Slight code reorganisation
#@ Reason : Sort performance data
#@ Reason : Fix formatting of current output
#@---------------------------------------------------
#@ Date : 20110504
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : Minor code changes and documentation improvements
#@ Reason : Remove redundant mismatched ' character in performance data output
#@ Reason : Output non-integral values for all sensors to fix problem seen with system board voltage sensors
#@ on an IBM server (thanks to Attilio Drei for the sample output)
#@---------------------------------------------------
#@ Date : 20110505
#@ Author : Fredrik Aslund
#@ Reason : Added possibility to use first line of a file as password (file:)
#@---------------------------------------------------
#@ Date : 20110505
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : Simplfy 'verboseoutput' to use 'verbose' as global variable instead of as parameter
#@ Reason : Don't look at performance data from CIM_NumericSensor if we're not using it
#@ Reason : Add --no-power, --no-volts, --no-current, --no-temp, and --no-fan options
#@---------------------------------------------------
#@ Date : 20110506
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : Reinstate timeouts with --timeout parameter (but not on Windows)
#@ Reason : Allow file:passwordfile in old-style arguments too
#@---------------------------------------------------
#@ Date : 20110507
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : On error, include numeric sensor value in output
#@---------------------------------------------------
#@ Date : 20110520
#@ Author : Bertrand Jomin
#@ Reason : Plugin had problems to handle some S/N from IBM Blade Servers
#@---------------------------------------------------
#@ Date : 20110614
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Rewrote file handling and file can now be used for user AND password
#@---------------------------------------------------
#@ Date : 20111003
#@ Author : Ian Chard (ian@chard.org)
#@ Reason : Allow a list of unwanted elements to be specified, which is useful
#@ in cases where hardware isn't well supported by ESXi
#@---------------------------------------------------
#@ Date : 20120402
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Making plugin GPL compatible (Copyright) and preparing for OpenBSD port
#@---------------------------------------------------
#@ Date : 20120405
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : Fix lookup of warranty info for Dell
#@---------------------------------------------------
#@ Date : 20120501
#@ Author : Craig Hart
#@ Reason : Bugfix in manufacturer discovery when cim entry not found or empty
#@---------------------------------------------------
#@ Date : 20121027
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Added workaround for Dell PE x620 where "System Board 1 Riser Config Err 0: Connected"
#@ element outputs wrong return code. Dell, please fix that.
#@ Added web-link to VMware CIM API 5.x at top of script.
#@---------------------------------------------------
#@ Date : 20130424
#@ Author : Claudio Kuenzler (www.claudiokuenzler.com)
#@ Reason : Another workaround for Dell systems "System Board 1 LCD Cable Pres 0: Connected"
#@---------------------------------------------------
#@ Date : 20130702
#@ Author : Carl R. Friend
#@ Reason : Improving wrong authentication timeout and exit UNKNOWN
#@---------------------------------------------------
#@ Date : 20130725
#@ Author : Phil Randal (phil.randal@gmail.com)
#@ Reason : Fix lookup of warranty info for Dell
#@---------------------------------------------------
import sys
sys.path.append('/usr/local/monitoring/python/lib/python2.7/site-packages')
import time
import pywbem
import re
import string
from optparse import OptionParser,OptionGroup
version = '20130725'
NS = 'root/cimv2'
# define classes to check 'OperationStatus' instance
ClassesToCheck = [
'OMC_SMASHFirmwareIdentity',
'CIM_Chassis',
'CIM_Card',
'CIM_ComputerSystem',
'CIM_NumericSensor',
'CIM_Memory',
'CIM_Processor',
'CIM_RecordLog',
'OMC_DiscreteSensor',
'OMC_Fan',
'OMC_PowerSupply',
'VMware_StorageExtent',
'VMware_Controller',
'VMware_StorageVolume',
'VMware_Battery',
'VMware_SASSATAPort'
]
sensor_Type = {
0:'unknown',
1:'Other',
2:'Temperature',
3:'Voltage',
4:'Current',
5:'Tachometer',
6:'Counter',
7:'Switch',
8:'Lock',
9:'Humidity',
10:'Smoke Detection',
11:'Presence',
12:'Air Flow',
13:'Power Consumption',
14:'Power Production',
15:'Pressure',
16:'Intrusion',
32768:'DMTF Reserved',
65535:'Vendor Reserved'
}
data = []
perf_Prefix = {
1:'Pow',
2:'Vol',
3:'Cur',
4:'Tem',
5:'Fan',
6:'FanP'
}
# parameters
# host name
hostname=''
# user
user=''
# password
password=''
# vendor - possible values are 'unknown', 'auto', 'dell', 'hp', 'ibm', 'intel'
vendor='unknown'
# verbose
verbose=False
# Produce performance data output for nagios
perfdata=False
# timeout
timeout = 0
# elements to ignore (full SEL, broken BIOS, etc)
ignore_list=[]
# urlise model and tag numbers (currently only Dell supported, but the code does the right thing for other vendors)
urlise_country=''
# collect perfdata for each category
get_power = True
get_volts = True
get_current = True
get_temp = True
get_fan = True
# define exit codes
ExitOK = 0
ExitWarning = 1
ExitCritical = 2
ExitUnknown = 3
def dell_country(country):
if country == 'at': # Austria
return 'at/de/'
if country == 'be': # Belgium
return 'be/nl/'
if country == 'cz': # Czech Republic
return 'cz/cs/'
if country == 'de': # Germany
return 'de/de/'
if country == 'dk': # Denmark
return 'dk/da/'
if country == 'es': # Spain
return 'es/es/'
if country == 'fi': # Finland
return 'fi/fi/'
if country == 'fr': # France
return 'fr/fr/'
if country == 'gr': # Greece
return 'gr/en/'
if country == 'it': # Italy
return 'it/it/'
if country == 'il': # Israel
return 'il/en/'
if country == 'me': # Middle East
return 'me/en/'
if country == 'no': # Norway
return 'no/no/'
if country == 'nl': # The Netherlands
return 'nl/nl/'
if country == 'pl': # Poland
return 'pl/pl/'
if country == 'pt': # Portugal
return 'pt/en/'
if country == 'ru': # Russia
return 'ru/ru/'
if country == 'se': # Sweden
return 'se/sv/'
if country == 'uk': # United Kingdom
return 'uk/en/'
if country == 'za': # South Africa
return 'za/en/'
if country == 'br': # Brazil
return 'br/pt/'
if country == 'ca': # Canada
return 'ca/en/'
if country == 'mx': # Mexico
return 'mx/es/'
if country == 'us': # United States
return 'us/en/'
if country == 'au': # Australia
return 'au/en/'
if country == 'cn': # China
return 'cn/zh/'
if country == 'in': # India
return 'in/en/'
# default
return 'en/us/'
def urlised_server_info(vendor, country, server_info):
#server_inf = server_info
if vendor == 'dell' :
# Dell support URLs (idea and tables borrowed from check_openmanage)
du = 'http://www.dell.com/support/troubleshooting/' + dell_country(country) + '19/Product/poweredge-'
if (server_info is not None) :
p=re.match('(.*)PowerEdge (.*) (.*)',server_info)
if (p is not None) :
md=p.group(2)
if md == 'R210 II':
md='r210-2'
md=md.lower()
server_info = p.group(1) + '<a href="' + du + md + '#ui-tabs-4">PowerEdge ' + p.group(2)+'</a> ' + p.group(3)
elif vendor == 'hp':
return server_info
elif vendor == 'ibm':
return server_info
elif vendor == 'intel':
return server_info
return server_info
# ----------------------------------------------------------------------
def system_tag_url(vendor,country):
if vendor == 'dell':
# Dell support sites
supportsite = 'http://www.dell.com/support/troubleshooting/'
dellsuffix = 'nodhs1/Index?t=warranty&servicetag='
# warranty URLs for different country codes
return supportsite + dell_country(country) + dellsuffix
# elif vendor == 'hp':
# elif vendor == 'ibm':
# elif vendor == 'intel':
return ''
# ----------------------------------------------------------------------
def urlised_serialnumber(vendor,country,SerialNumber):
if SerialNumber is not None :
tu = system_tag_url(vendor,country)
if tu != '' :
SerialNumber = '<a href="' + tu + SerialNumber + '">' + SerialNumber + '</a>'
return SerialNumber
# ----------------------------------------------------------------------
def verboseoutput(message) :
if verbose:
print "%s %s" % (time.strftime("%Y%m%d %H:%M:%S"), message)
# ----------------------------------------------------------------------
def getopts() :
global hosturl,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,get_power,get_volts,get_current,get_temp,get_fan
usage = "usage: %prog https://hostname user password system [verbose]\n" \
"example: %prog https://my-shiny-new-vmware-server root fakepassword dell\n\n" \
"or, using new style options:\n\n" \
"usage: %prog -H hostname -U username -P password [-V system -v -p -I XX]\n" \
"example: %prog -H my-shiny-new-vmware-server -U root -P fakepassword -V auto -I uk\n\n" \
"or, verbosely:\n\n" \
"usage: %prog --host=hostname --user=username --pass=password [--vendor=system --verbose --perfdata --html=XX]\n"
parser = OptionParser(usage=usage, version="%prog "+version)
group1 = OptionGroup(parser, 'Mandatory parameters')
group2 = OptionGroup(parser, 'Optional parameters')
group1.add_option("-H", "--host", dest="host", help="report on HOST", metavar="HOST")
group1.add_option("-U", "--user", dest="user", help="user to connect as", metavar="USER")
group1.add_option("-P", "--pass", dest="password", \
help="password, if password matches file:<path>, first line of given file will be used as password", metavar="PASS")
group2.add_option("-V", "--vendor", dest="vendor", help="Vendor code: auto, dell, hp, ibm, intel, or unknown (default)", \
metavar="VENDOR", type='choice', choices=['auto','dell','hp','ibm','intel','unknown'],default="unknown")
group2.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, \
help="print status messages to stdout (default is to be quiet)")
group2.add_option("-p", "--perfdata", action="store_true", dest="perfdata", default=False, \
help="collect performance data for pnp4nagios (default is not to)")
group2.add_option("-I", "--html", dest="urlise_country", default="", \
help="generate html links for country XX (default is not to)", metavar="XX")
group2.add_option("-t", "--timeout", action="store", type="int", dest="timeout", default=0, \
help="timeout in seconds - no effect on Windows (default = no timeout)")
group2.add_option("-i", "--ignore", action="store", type="string", dest="ignore", default="", \
help="comma-separated list of elements to ignore")
group2.add_option("--no-power", action="store_false", dest="get_power", default=True, \
help="don't collect power performance data")
group2.add_option("--no-volts", action="store_false", dest="get_volts", default=True, \
help="don't collect voltage performance data")
group2.add_option("--no-current", action="store_false", dest="get_current", default=True, \
help="don't collect current performance data")
group2.add_option("--no-temp", action="store_false", dest="get_temp", default=True, \
help="don't collect temperature performance data")
group2.add_option("--no-fan", action="store_false", dest="get_fan", default=True, \
help="don't collect fan performance data")
parser.add_option_group(group1)
parser.add_option_group(group2)
# check input arguments
if len(sys.argv) < 2:
print "no parameters specified\n"
parser.print_help()
sys.exit(-1)
# if first argument starts with 'https://' we have old-style parameters, so handle in old way
if re.match("https://",sys.argv[1]):
# check input arguments
if len(sys.argv) < 5:
print "too few parameters\n"
parser.print_help()
sys.exit(-1)
if len(sys.argv) > 5 :
if sys.argv[5] == "verbose" :
verbose = True
hosturl = sys.argv[1]
user = sys.argv[2]
password = sys.argv[3]
vendor = sys.argv[4]
else:
# we're dealing with new-style parameters, so go get them!
(options, args) = parser.parse_args()
# Making sure all mandatory options appeared.
mandatories = ['host', 'user', 'password']
for m in mandatories:
if not options.__dict__[m]:
print "mandatory parameter '--" + m + "' is missing\n"
parser.print_help()
sys.exit(-1)
hostname=options.host.lower()
# if user has put "https://" in front of hostname out of habit, do the right thing
# hosturl will end up as https://hostname
if re.match('^https://',hostname):
hosturl = hostname
else:
hosturl = 'https://' + hostname
user=options.user
password=options.password
vendor=options.vendor.lower()
verbose=options.verbose
perfdata=options.perfdata
urlise_country=options.urlise_country.lower()
timeout=options.timeout
ignore_list=options.ignore.split(',')
get_power=options.get_power
get_volts=options.get_volts
get_current=options.get_current
get_temp=options.get_temp
get_fan=options.get_fan
# if user or password starts with 'file:', use the first string in file as user, second as password
if (re.match('^file:', user) or re.match('^file:', password)):
if re.match('^file:', user):
filextract = re.sub('^file:', '', user)
filename = open(filextract, 'r')
filetext = filename.readline().split()
user = filetext[0]
password = filetext[1]
filename.close()
elif re.match('^file:', password):
filextract = re.sub('^file:', '', password)
filename = open(filextract, 'r')
filetext = filename.readline().split()
password = filetext[0]
filename.close()
# ----------------------------------------------------------------------
getopts()
# if running on Windows, don't use timeouts and signal.alarm
on_windows = True
os_platform = sys.platform
if os_platform != "win32":
on_windows = False
import signal
def handler(signum, frame):
print 'CRITICAL: Execution time too long!'
sys.exit(ExitCritical)
# connection to host
verboseoutput("Connection to "+hosturl)
wbemclient = pywbem.WBEMConnection(hosturl, (user,password), NS)
# Add a timeout for the script. When using with Nagios, the Nagios timeout cannot be < than plugin timeout.
if on_windows == False and timeout > 0:
signal.signal(signal.SIGALRM, handler)
signal.alarm(timeout)
# run the check for each defined class
GlobalStatus = ExitUnknown
server_info = ""
bios_info = ""
SerialNumber = ""
ExitMsg = ""
# if vendor is specified as 'auto', try to get vendor from CIM
# note: the default vendor is 'unknown'
if vendor=='auto':
try:
c=wbemclient.EnumerateInstances('CIM_Chassis')
except pywbem.cim_operations.CIMError,args:
if ( args[1].find('Socket error') >= 0 ):
print "UNKNOWN: %s" %args
sys.exit (ExitUnknown)
else:
verboseoutput("Unknown CIM Error: %s" % args)
except pywbem.cim_http.AuthError,arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitUnknown
print "UNKNOWN: Authentication Error"
sys.exit (GlobalStatus)
else:
man=c[0][u'Manufacturer']
if re.match("Dell",man):
vendor="dell"
elif re.match("HP",man):
vendor="hp"
elif re.match("IBM",man):
vendor="ibm"
elif re.match("Intel",man):
vendor="intel"
else:
vendor='unknown'
for classe in ClassesToCheck :
verboseoutput("Check classe "+classe)
try:
instance_list = wbemclient.EnumerateInstances(classe)
except pywbem.cim_operations.CIMError,args:
if ( args[1].find('Socket error') >= 0 ):
print "CRITICAL: %s" %args
sys.exit (ExitCritical)
else:
verboseoutput("Unknown CIM Error: %s" % args)
except pywbem.cim_http.AuthError,arg:
verboseoutput("Global exit set to UNKNOWN")
GlobalStatus = ExitCritical
print "UNKNOWN: Authentication Error"
sys.exit (GlobalStatus)
else:
# GlobalStatus = ExitOK #ARR
for instance in instance_list :
sensor_value = ""
elementName = instance['ElementName']
elementNameValue = elementName
verboseoutput(" Element Name = "+elementName)
# Ignore element if we don't want it
if elementName in ignore_list :
verboseoutput(" (ignored)")
continue
# BIOS & Server info
if elementName == 'System BIOS' :
bios_info = instance[u'Name'] + ': ' \
+ instance[u'VersionString'] + ' ' \
+ str(instance[u'ReleaseDate'].datetime.date())
verboseoutput(" VersionString = "+instance[u'VersionString'])
elif elementName == 'Chassis' :
man = instance[u'Manufacturer']
if man is None :
man = 'Unknown Manufacturer'
verboseoutput(" Manufacturer = "+man)
SerialNumber = instance[u'SerialNumber']
if SerialNumber:
verboseoutput(" SerialNumber = "+SerialNumber)
server_info = man + ' '
if vendor != 'intel':
model = instance[u'Model']
if model:
verboseoutput(" Model = "+model)
server_info += model + ' s/n:'
elif elementName == 'Server Blade' :
SerialNumber = instance[u'SerialNumber']
if SerialNumber:
verboseoutput(" SerialNumber = "+SerialNumber)
# Report detail of Numeric Sensors and generate nagios perfdata
if classe == "CIM_NumericSensor" :
sensorType = instance[u'sensorType']
sensStr = sensor_Type.get(sensorType,"Unknown")
if sensorType:
verboseoutput(" sensorType = %d - %s" % (sensorType,sensStr))
units = instance[u'BaseUnits']
if units:
verboseoutput(" BaseUnits = %d" % units)
# grab some of these values for Nagios performance data
scale = 10**instance[u'UnitModifier']
verboseoutput(" Scaled by = %f " % scale)
cr = int(instance[u'CurrentReading'])*scale
verboseoutput(" Current Reading = %f" % cr)
elementNameValue = "%s: %g" % (elementName,cr)
ltnc = 0
utnc = 0
ltc = 0
utc = 0
if instance[u'LowerThresholdNonCritical'] is not None:
ltnc = instance[u'LowerThresholdNonCritical']*scale
verboseoutput(" Lower Threshold Non Critical = %f" % ltnc)
if instance[u'UpperThresholdNonCritical'] is not None:
utnc = instance[u'UpperThresholdNonCritical']*scale
verboseoutput(" Upper Threshold Non Critical = %f" % utnc)
if instance[u'LowerThresholdCritical'] is not None:
ltc = instance[u'LowerThresholdCritical']*scale
verboseoutput(" Lower Threshold Critical = %f" % ltc)
if instance[u'UpperThresholdCritical'] is not None:
utc = instance[u'UpperThresholdCritical']*scale
verboseoutput(" Upper Threshold Critical = %f" % utc)
#
if perfdata:
perf_el = elementName.replace(' ','_')
# Power and Current
if sensorType == 4: # Current or Power Consumption
if units == 7: # Watts
if get_power:
data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),1) )
elif units == 6: # Current
if get_current:
data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),3) )
# PSU Voltage
elif sensorType == 3: # Voltage
if get_volts:
data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),2) )
# Temperatures
elif sensorType == 2: # Temperature
if get_temp:
data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),4) )
# Fan speeds
elif sensorType == 5: # Tachometer
if get_fan:
if units == 65: # percentage
data.append( ("%s=%g%%;%g;%g " % (perf_el, cr, utnc, utc),6) )
else:
data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),5) )
elif classe == "CIM_Processor" :
verboseoutput(" Family = %d" % instance['Family'])
verboseoutput(" CurrentClockSpeed = %dMHz" % instance['CurrentClockSpeed'])
# HP Check
if vendor == "hp" :
if instance['HealthState'] is not None :
elementStatus = instance['HealthState']
verboseoutput(" Element HealthState = %d" % elementStatus)
interpretStatus = {
0 : ExitOK, # Unknown
5 : ExitOK, # OK
10 : ExitWarning, # Degraded
15 : ExitWarning, # Minor
20 : ExitCritical, # Major
25 : ExitCritical, # Critical
30 : ExitCritical, # Non-recoverable Error
}[elementStatus]
if (interpretStatus == ExitCritical) :
verboseoutput("GLobal exit set to CRITICAL")
GlobalStatus = ExitCritical
ExitMsg += " CRITICAL : %s " % elementNameValue
if (interpretStatus == ExitWarning and GlobalStatus != ExitCritical) :
verboseoutput("GLobal exit set to WARNING")
GlobalStatus = ExitWarning
ExitMsg += " WARNING : %s " % elementNameValue
# Added the following for when GlobalStatus is ExitCritical and a warning is detected
# This way the ExitMsg gets added but GlobalStatus isn't changed
if (interpretStatus == ExitWarning and GlobalStatus == ExitCritical) : # ARR
ExitMsg += " WARNING : %s " % elementNameValue #ARR
# Added the following so that GlobalStatus gets set to OK if there's no warning or critical
if (interpretStatus == ExitOK and GlobalStatus != ExitWarning and GlobalStatus != ExitCritical) : #ARR
GlobalStatus = ExitOK #ARR
# Dell, Intel, IBM and unknown hardware check
elif (vendor == "dell" or vendor == "intel" or vendor == "ibm" or vendor=="unknown") :
# Added 20121027 As long as Dell doesnt correct these CIM elements return code we have to ignore it
ignore_list.append("System Board 1 Riser Config Err 0: Connected")
ignore_list.append("System Board 1 LCD Cable Pres 0: Connected")
if instance['OperationalStatus'] is not None :
elementStatus = instance['OperationalStatus'][0]
verboseoutput(" Element Op Status = %d" % elementStatus)
interpretStatus = {
0 : ExitOK, # Unknown
1 : ExitCritical, # Other
2 : ExitOK, # OK
3 : ExitWarning, # Degraded
4 : ExitWarning, # Stressed
5 : ExitWarning, # Predictive Failure
6 : ExitCritical, # Error
7 : ExitCritical, # Non-Recoverable Error
8 : ExitWarning, # Starting
9 : ExitWarning, # Stopping
10 : ExitCritical, # Stopped
11 : ExitOK, # In Service
12 : ExitWarning, # No Contact
13 : ExitCritical, # Lost Communication
14 : ExitCritical, # Aborted
15 : ExitOK, # Dormant
16 : ExitCritical, # Supporting Entity in Error
17 : ExitOK, # Completed
18 : ExitOK, # Power Mode
19 : ExitOK, # DMTF Reserved
20 : ExitOK # Vendor Reserved
}[elementStatus]
if (interpretStatus == ExitCritical) :
verboseoutput("Global exit set to CRITICAL")
GlobalStatus = ExitCritical
ExitMsg += " CRITICAL : %s " % elementNameValue
if (interpretStatus == ExitWarning and GlobalStatus != ExitCritical) :
verboseoutput("GLobal exit set to WARNING")
GlobalStatus = ExitWarning
ExitMsg += " WARNING : %s " % elementNameValue
# Added same logic as in 20100702 here, otherwise Dell servers would return UNKNOWN instead of OK
if (interpretStatus == ExitWarning and GlobalStatus == ExitCritical) : # ARR
ExitMsg += " WARNING : %s " % elementNameValue #ARR
if (interpretStatus == ExitOK and GlobalStatus != ExitWarning and GlobalStatus != ExitCritical) : #ARR
GlobalStatus = ExitOK #ARR
if elementName == 'Server Blade' :
if SerialNumber :
if SerialNumber.find(".") != -1 :
SerialNumber = SerialNumber.split('.')[1]
# Munge the ouptput to give links to documentation and warranty info
if (urlise_country != '') :
SerialNumber = urlised_serialnumber(vendor,urlise_country,SerialNumber)
server_info = urlised_server_info(vendor,urlise_country,server_info)
# Output performance data
perf = '|'
if perfdata:
sdata=[]
ctr=[0,0,0,0,0,0,0]
# sort the data so we always get perfdata in the right order
# we make no assumptions about the order in which CIM returns data
# first sort by element name (effectively) and insert sequence numbers
for p in sorted(data):
p1 = p[1]
sdata.append( ("P%d%s_%d_%s") % (p1,perf_Prefix[p1], ctr[p1], p[0]) )
ctr[p1] += 1
# then sort perfdata into groups and output perfdata string
for p in sorted(sdata):
perf += p
# sanitise perfdata - don't output "|" if nothing to report
if perf == '|':
perf = ''
if GlobalStatus == ExitOK :
print "OK - Server: %s %s %s%s" % (server_info, SerialNumber, bios_info, perf)
elif GlobalStatus == ExitUnknown :
print "UNKNOWN: %s" % (ExitMsg) #ARR
else:
print "%s- Server: %s %s %s%s" % (ExitMsg, server_info, SerialNumber, bios_info, perf)
sys.exit (GlobalStatus)

@ -0,0 +1,48 @@
#!/usr/bin/perl
use Getopt::Std;
use File::Basename;
getopts('wch');
if ($opt_h or $ARGV[0] eq '') {
print "Usage:\n";
print " check_file -w|-c file1,file2,file3,...\n";
print " check_file -h\n";
exit 0;
}
(@files) = split(/,/, $ARGV[0]);
foreach $f (@files) {
($n, $p, $s) = fileparse($f, ());
$ff = "$n$s";
@st = stat $f;
if ($st[7] eq '') {
$bad = $bad . " $ff(?)";
}
elsif ($st[7] == 0) {
$bad = $bad . " $ff(0)";
}
else {
$ok = $ok . " $ff";
}
}
if ($bad ne '') {
if ($opt_w) {
print "FILES WARNING:$bad\n";
exit 1;
}
if ($opt_c) {
print "FILES CRITICAL:$bad\n";
exit 2;
}
}
print "FILES OK:$ok\n";
exit 0;

@ -0,0 +1,127 @@
#!/usr/local/bin/perl -w
# check_file_age.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com>
#
# Checks a file's size and modification time to make sure it's not empty
# and that it's sufficiently recent.
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# you should have received a copy of the GNU General Public License
# along with this program if not, write to the Free Software Foundation,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
use strict;
use English;
use Getopt::Long;
use File::stat;
use vars qw($PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '/usr/local/monitoring/libexec';
use utils qw (%ERRORS &print_revision &support);
sub print_help ();
sub print_usage ();
my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i);
my ($result, $message, $age, $size, $st, $perfdata);
$PROGNAME="check_file_age";
$ENV{'PATH'}='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$opt_w = 240;
$opt_c = 600;
$opt_W = 0;
$opt_C = 0;
$opt_f = "";
Getopt::Long::Configure('bundling');
GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"i" => \$opt_i, "ignore-missing" => \$opt_i,
"f=s" => \$opt_f, "file" => \$opt_f,
"w=f" => \$opt_w, "warning-age=f" => \$opt_w,
"W=f" => \$opt_W, "warning-size=f" => \$opt_W,
"c=f" => \$opt_c, "critical-age=f" => \$opt_c,
"C=f" => \$opt_C, "critical-size=f" => \$opt_C);
if ($opt_V) {
print_revision($PROGNAME, '2.1.1');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
$opt_f = shift unless ($opt_f);
if (! $opt_f) {
print "FILE_AGE UNKNOWN: No file specified\n";
exit $ERRORS{'UNKNOWN'};
}
# Check that file exists (can be directory or link)
unless (-e $opt_f) {
if ($opt_i) {
$result = 'OK';
print "FILE_AGE $result: $opt_f doesn't exist, but ignore-missing was set\n";
exit $ERRORS{$result};
} else {
print "FILE_AGE CRITICAL: File not found - $opt_f\n";
exit $ERRORS{'CRITICAL'};
}
}
$st = File::stat::stat($opt_f);
$age = time - $st->mtime;
$size = $st->size;
$perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";
$result = 'OK';
if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) {
$result = 'CRITICAL';
}
elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) {
$result = 'WARNING';
}
print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n";
exit $ERRORS{$result};
sub print_usage () {
print "Usage:\n";
print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] [-i] -f <file>\n";
print " $PROGNAME [-h | --help]\n";
print " $PROGNAME [-V | --version]\n";
}
sub print_help () {
print_revision($PROGNAME, '2.1.1');
print "Copyright (c) 2003 Steven Grimm\n\n";
print_usage();
print "\n";
print " -i | --ignore-missing : return OK if the file does not exist\n";
print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n";
print "\n";
support();
}

@ -0,0 +1,246 @@
#!/usr/local/bin/perl -w
#
# usage:
# check_flexlm.pl license_file
#
# Check available flexlm license managers.
# Use lmstat to check the status of the license server
# described by the license file given as argument.
# Check and interpret the output of lmstat
# and create returncodes and output.
#
# Contrary to most other plugins, this script takes
# a file, not a hostname as an argument and returns
# the status of hosts and services described in that
# file. Use these hosts.cfg entries as an example
#
#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1;
#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic
#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic
#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$
#
# Notes:
# - you need the lmstat utility which comes with flexlm.
# - set the correct path in the variable $lmstat.
#
# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com
#
# License: GPL
#
# lmstat output patches from Steve Rigler/Cliff Rice 13-Apr-2002
# srigler@marathonoil.com,cerice@marathonoil.com
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
use lib '/usr/local/monitoring/libexec';
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME="check_flexlm";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v" => \$verbose, "verbose" => \$verbose,
"F=s" => \$opt_F, "filename=s" => \$opt_F,
"t=i" => \$opt_t, "timeout=i" => \$opt_t);
if ($opt_V) {
print_revision($PROGNAME,'2.1.1');
exit $ERRORS{'OK'};
}
unless (defined $opt_t) {
$opt_t = $utils::TIMEOUT ; # default timeout
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
unless (defined $opt_F) {
print "Missing license.dat file\n";
print_usage();
exit $ERRORS{'UNKNOWN'};
}
# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "Timeout: No Answer from Client\n";
exit $ERRORS{'UNKNOWN'};
};
alarm($opt_t);
my $lmstat = $utils::PATH_TO_LMSTAT ;
unless (-x $lmstat ) {
print "Cannot find \"lmstat\"\n";
exit $ERRORS{'UNKNOWN'};
}
($opt_F) || ($opt_F = shift) || usage("License file not specified\n");
my $licfile = $1 if ($opt_F =~ /^(.*)$/);
($licfile) || usage("Invalid filename: $opt_F\n");
print "$licfile\n" if $verbose;
if ( ! open(CMD,"$lmstat -c $licfile |") ) {
print "ERROR: Could not open \"$lmstat -c $licfile\" ($!)\n";
exit exit $ERRORS{'UNKNOWN'};
}
my $serverup = 0;
my @upsrv;
my @downsrv; # list of servers up and down
#my ($ls1,$ls2,$ls3,$lf1,$lf2,$lf3,$servers);
# key off of the term "license server" and
# grab the status. Keep going until "Vendor" is found
#
#
# Collect list of license servers by their status
# Vendor daemon status is ignored for the moment.
while ( <CMD> ) {
next if (/^lmstat/); # ignore 1st line - copyright
next if (/^Flexible/); # ignore 2nd line - timestamp
(/^Vendor/) && last; # ignore Vendor daemon status
print $_ if $verbose;
if ($_ =~ /license server /) { # matched 1 (of possibly 3) license server
s/^\s*//; #some servers start at col 1, other have whitespace
# strip staring whitespace if any
if ( $_ =~ /UP/) {
$_ =~ /^(.*):/ ;
push(@upsrv, $1);
print "up:$1:\n" if $verbose;
} else {
$_ =~ /^(.*):/;
push(@downsrv, $1);
print "down:$1:\n" if $verbose;
}
}
# if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) {
# $ls1 = $1;
# $ls2 = $2;
# $ls3 = $3;
# $lf1 = $lf2 = $lf3 = 0;
# $servers = 3;
# } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) {
# $ls1 = $1;
# $ls2 = $ls3 = "";
# $lf1 = $lf2 = $lf3 = 0;
# $servers = 1;
# } elsif ( / *$ls1: license server UP/ ) {
# print "$ls1 UP, ";
# $lf1 = 1
# } elsif ( / *$ls2: license server UP/ ) {
# print "$ls2 UP, ";
# $lf2 = 1
# } elsif ( / *$ls3: license server UP/ ) {
# print "$ls3 UP, ";
# $lf3 = 1
# } elsif ( / *([^:]*: UP .*)/ ) {
# print " license server for $1\n";
# $serverup = 1;
# }
}
#if ( $serverup == 0 ) {
# print " license server not running\n";
# exit 2;
#}
close CMD;
if ($verbose) {
print "License Servers running: ".scalar(@upsrv) ."\n";
foreach my $upserver (@upsrv) {
print "$upserver\n";
}
print "License servers not running: ".scalar(@downsrv)."\n";
foreach my $downserver (@downsrv) {
print "$downserver\n";
}
}
#
# print list of servers which are up.
#
if (scalar(@upsrv) > 0) {
print "License Servers running:";
foreach my $upserver (@upsrv) {
print "$upserver,";
}
}
#
# Ditto for those which are down.
#
if (scalar(@downsrv) > 0) {
print "License servers NOT running:";
foreach my $downserver (@downsrv) {
print "$downserver,";
}
}
# perfdata
print "\n|flexlm::up:".scalar(@upsrv).";down:".scalar(@downsrv)."\n";
exit $ERRORS{'OK'} if ( scalar(@downsrv) == 0 );
exit $ERRORS{'WARNING'} if ( (scalar(@upsrv) > 0) && (scalar(@downsrv) > 0));
#exit $ERRORS{'OK'} if ( $servers == $lf1 + $lf2 + $lf3 );
#exit $ERRORS{'WARNING'} if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
exit $ERRORS{'CRITICAL'};
sub print_usage () {
print "Usage:
$PROGNAME -F <filename> [-v] [-t] [-V] [-h]
$PROGNAME --help
$PROGNAME --version
";
}
sub print_help () {
print_revision($PROGNAME,'2.1.1');
print "Copyright (c) 2000 Ernst-Dieter Martin/Karl DeBisschop
Check available flexlm license managers
";
print_usage();
print "
-F, --filename=FILE
Name of license file (usually \"license.dat\")
-v, --verbose
Print some extra debugging information (not advised for normal operation)
-t, --timeout
Plugin time out in seconds (default = $utils::TIMEOUT )
-V, --version
Show version and license information
-h, --help
Show this help screen
Flexlm license managers usually run as a single server or three servers and a
quorum is needed. The plugin return OK if 1 (single) or 3 (triple) servers
are running, CRITICAL if 1(single) or 3 (triple) servers are down, and WARNING
if 1 or 2 of 3 servers are running\n
";
support();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,651 @@
#!/usr/bin/perl -w
#
# check_generic - nagios plugin
#
# Copyright (c) 2007 Matthias Flacke (matthias.flacke at gmx.de)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# TODO
#
#
# $Id$
#
#nagios: -epn
#
use strict;
use Getopt::Long qw(:config no_ignore_case bundling);
BEGIN { eval("use Time::HiRes qw(time)") }
use lib "/usr/local/monitoring/libexec";
use vars qw(
$MYSELF %opt %cmd %rc $command $returncode
$VERSION $OK $WARNING $CRITICAL $UNKNOWN
$DETAIL_LIST $DETAIL_RC $DETAIL_STDERR $DETAIL_PERFORMANCE
);
#-------------------------------------------------------------------------------
#--- vars ----------------------------------------------------------------------
#-------------------------------------------------------------------------------
$MYSELF="check_generic";
$VERSION='$Revision$ $Date$ $Author$';
#
#--- RC defines
$OK=0;
$WARNING=1;
$CRITICAL=2;
$UNKNOWN=3;
#
#--- report defines
$DETAIL_LIST=1;
$DETAIL_RC=2;
$DETAIL_STDERR=4;
$DETAIL_PERFORMANCE=8;
#
#--- vars
%cmd=(
matchlist => [],
);
%rc=(
label => { $OK => "OK", $WARNING => "WARNING", $CRITICAL => "CRITICAL", $UNKNOWN => "UNKNOWN", },
number => { "OK" => $OK, "WARNING" => $WARNING, "CRITICAL" => $CRITICAL, "UNKNOWN" => $UNKNOWN,
"ok" => $OK, "warning" => $WARNING, "critical" => $CRITICAL, "unknown" => $UNKNOWN,
"o" => $OK, "w" => $WARNING, "c" => $CRITICAL, "u" => $UNKNOWN, },
s2r => { 0 => $OK, 2 => $WARNING, 3 => $CRITICAL, 1 => $UNKNOWN, },
r2s => { $OK => 0, $WARNING => 2, $CRITICAL => 3, $UNKNOWN => 1, },
complement => { $OK => $CRITICAL, $WARNING => $OK, $CRITICAL => $OK, $UNKNOWN => $OK, },
minimum => { $OK => 0, $WARNING => 1, $CRITICAL => 1, $UNKNOWN => 1, },
maximum => { $OK => 0, $WARNING => 1, $CRITICAL => 1, $UNKNOWN => 1, },
list => { $OK => [],$WARNING => [],$CRITICAL => [],$UNKNOWN => [], },
textsev => ["ok","unknown","warning","critical"],
top => $OK,
error => [ ],
starttime => 0.0,
endtime => 0.0,
);
my %opt=(
"configfile" => "",
"ignore_rc" => 0,
"libexec" => "/usr/local/nagios/libexec",
"maxage" => 24, #hours
"name" => "CHANGEME",
"performance" => undef,
"report" => 15,
"string" => {},
"timeout" => 10,
"tmpdir" => "/usr/tmp/check_generic",
"type" => "scalar",
"verbose" => 0,
#"ok" => "0:0",
#"warning" => "1:1",
#"critical" => "1:1",
#"unknown" => "1:1",
);
#-------------------------------------------------------------------------------
#--- subs ----------------------------------------------------------------------
#-------------------------------------------------------------------------------
sub process_parameters {
if (! GetOptions(
"c|critical=s" => \$opt{critical},
"d|tmpdir=s" => \$opt{tmpdir},
"e|execute=s" => \$opt{execute},
"h|help" => \$opt{help},
"i|ignore_rc" => \$opt{ignore_rc},
"n|name=s" => \$opt{name},
"o|ok=s" => \$opt{ok},
"p|performance=s" => \$opt{performance},
"r|report:i" => \$opt{report},
"f|false=s" => \$opt{false},
"t|timeout=i" => \$opt{timeout},
"u|unknown=s" => \$opt{unknown},
"v|verbose+" => \$opt{verbose},
"V|version" => \$opt{version},
"w|warning=s" => \$opt{warning},
"y|type=s" => \$opt{type},
)
) {
short_usage();
return $UNKNOWN;
}
if ($opt{version}) {
print "$MYSELF: v$VERSION\n";
return $UNKNOWN;
}
if ($opt{help}) {
short_usage();
long_usage();
return $UNKNOWN;
}
if (!$opt{execute}) {
print "$MYSELF error: no commandline specified\n";
short_usage();
return $UNKNOWN;
} else {
$cmd{command}=$opt{execute};
$cmd{name}=$opt{execute};
}
if (!$opt{ok} && !$opt{warning} && !$opt{critical} && !$opt{unknown}) {
print "$MYSELF error: no evaluation expression specified\n";
short_usage();
return $UNKNOWN;
} else {
foreach my $state (reverse @{$rc{textsev}}) {
if (defined($opt{$state})) {
$opt{string}=is_string_cmp($opt{$state});
debug(3,"process_parameters: state $state defined:$opt{$state}, text evaluation:$opt{string}");
} else {
debug(3,"process_parameters: state $state not defined");
}
}
}
if ($opt{false} && (
$opt{false} ne "o" && $opt{false} ne "OK" &&
$opt{false} ne "u" && $opt{false} ne "UNKNOWN" &&
$opt{false} ne "w" && $opt{false} ne "WARNING" &&
$opt{false} ne "c" && $opt{false} ne "CRITICAL")) {
print "$MYSELF error: unknown false $opt{false}, should be u|UNKNOWN w|WARNING c|critical o|OK\n";
short_usage();
return $UNKNOWN;
}
while (!defined($opt{false})) {
foreach my $state (reverse @{$rc{textsev}}) {
#print "DEBUG:state:$state opt{state}:$opt{$state}\n";
if (defined($opt{$state})) {
$opt{false}=$rc{label}{$rc{complement}{$rc{number}{$state}}};
last;
}
}
}
if (! -d $opt{tmpdir}) {
mkdir $opt{tmpdir} || debug(0,"mkdir $opt{tmpdir} failed:$!");
if (! -d $opt{tmpdir}) {
return $UNKNOWN if (defined($opt{delta}));
}
}
if ($opt{type} eq "delta") {
#--- create tmpfile name from 1. tag 2. command 3. expressions
$opt{tmpfile}=$opt{name} . "_" . $opt{execute};
foreach my $state (reverse @{$rc{textsev}}) {
$opt{tmpfile} .= '_' . $opt{$state} if (defined($opt{$state}));
}
$opt{tmpfile}=~s/\W/_/g;
$opt{tmpfile}="$MYSELF.$opt{tmpfile}.tmp";
debug(2, "process_parameter: tmpfile:$opt{tmpfile}");
#--- read content of old tmpfile if available
my $content=readfile("$opt{tmpdir}/$opt{tmpfile}");
if ($content ne "") {
chomp $content;
($cmd{old_timestamp},$cmd{old_output})=split(/\s+/,$content);
debug(2, "process_parameter: old_timestamp:$cmd{old_timestamp} old_output:$cmd{old_output}");
}
#--- remove old files in tmpdir older than one day
&garbage_collection($opt{maxage});
}
debug(2, "verbosity:$opt{verbose}");
return $OK;
}
sub short_usage {
print <<SHORTEOF;
$MYSELF -e <cmdline> -o|u|w|c <expression> [-f false_state] [-n name] [-t timeout] [-r level]
$MYSELF [-h | --help]
$MYSELF [-V | --version]
SHORTEOF
}
sub long_usage {
print <<LONGEOF;
Options:
-e, --execute <cmdline>
string which contains commands to be executed
(can be a complete filter chain)
-u|w|c|o, --unknown,warning,critical,ok <expression>
operator is perl operators, e.g.
'= n' - numerically equal
'< n' - numerically equal
'> n' - numerically equal
'eq s' - string equal
'ne s' - string non equal
'=~/s/ - pattern matching
default: CRITICAL
-f, --false [u|UNKNOWN|w|WARNING|c|CRITICAL|o|OK]
which state the plugin should become if the expression is false
default: complement of state
-y, --type [SCALAR,ARRAY,DELTA]
type of data value
-i, --ignore_rc
normally the return code of the command executed is taken into account
use this option to explicitly ignore it, default: $opt{ignore_rc}
-n, --name
plugin name (shown in output), default: $opt{name}
-t, --timeout
timeout for one command, default: $opt{timeout}
-d, --tmpdir
specify directory for tmpfiles, default: $opt{tmpdir}
(garbage collection for files \'${MYSELF}*\' removes files older than )
-v, --verbose
increase verbosity (can be called multiple), default: $opt{verbose}
-h, --help
print detailed help screen
-V, --version
print version information
LONGEOF
#-s, --state [u|UNKNOWN|w|WARNING|c|CRITICAL|o|OK]
# which state the plugin should become if the expression is true
#-r, --report <level>
# specify level of details in output (level is binary coded, just add all options)
# default: $opt{report}
# 1: mention service names in plugin_output, e.g.
# "24 plugins checked, 1 critical (http), 0 warning, 0 unknown, 23 ok"
# 2: show STATE in front of each line of plugin output, e.g.
# "[16] OK system_ssh - SSH OK - OpenSSH_4.4 (protocol 1.99)"
# 4: show STDERR (if any) in each line of plugin output
# 8: show performance data
}
#---
#--- debug output routine
#---
sub debug {
my ($level,$message)=@_;
print "$message\n" if ($level <= $opt{verbose});
}
#---
#--- read file and return its contents
#---
sub readfile {
my ($filename)=@_;
open(FILE,$filename) || add_error("readfile: error opening $filename:$!") && return "";
my @lines=<FILE>;
close(FILE);
return join("", @lines);
}
#---
#--- write to file
#---
sub writefile {
my ($filename, $content)=@_;
open(FILE,">$filename") || add_error("writefile: error opening $filename:$!") && return 0;
print FILE $content;
close(FILE);
return -s $filename;
}
#---
#--- check if expression is string evaluation
#---
sub is_string_cmp {
my $expression=shift;
my %stringop=(' lt ',' gt ',' le ',' ge ','\=\~','\!\~',' eq ',' ne ');
foreach my $key (keys(%stringop)) {
return 1 if ($expression=~/^\s*$key/);
}
return 0;
}
#
#---
sub match_env {
my ($string, $expr, $wanted_length)=@_;
my @match=();
my @len=();
my $total="";
my $cute_little_proc="if (\'${string}\'${expr}) { \@match=(\$\`,\$\&,\$\'); }";
my $rc=eval($cute_little_proc);
#print "match_env: cute_little_proc:$cute_little_proc\n";
#print "match_env: string:$string expr:$expr wanted_length:$wanted_length rc eval:$rc eval:$@\n";
for my $i (0..$#match) {
$len[$i]=length($match[$i]);
#print "match $i: $match[$i] ($len[$i])\n";
}
return squeeze($match[0],"right",$wanted_length/3) .
squeeze($match[1],"middle",$wanted_length/3) .
squeeze($match[2],"left",$wanted_length/3);
}
#---
#--- squeeze string
#---
sub squeeze {
my ($string,$fromwhere,$num)=@_;
return "" if (!defined($string));
my $len=length($string);
my $replacement="[...]";
my $rlen=5; # length($replacement)
#--- nothing to squeeze ;-)
return $string if ($len<=$num);
if ($fromwhere eq "left") {
return substr($string,0,$num-$rlen) . $replacement;
} elsif ($fromwhere eq "middle") {
return $replacement . substr($string,($len/2)-($num/2)+$rlen,$num-($rlen*2)) . $replacement;
} elsif ($fromwhere eq "right") {
return $replacement . substr($string,$num*-1+$rlen);
} elsif ($fromwhere eq "both") {
return substr($string,0,$num/2-($rlen/2)) . $replacement . substr($string,($num*-1)/2+($rlen/2));
} else {
return "squeeze error: unknown fromwhere parameter $fromwhere\n";
}
}
#---
#--- taken from Perl Cookbook ;-)
#---
sub is_valid_regex {
my $pat = shift;
return eval { "" =~ /$pat/; 1 } || 0;
}
#---
#--- trim input string if found any chars from trim string
#---
sub mytrim {
my ($src, $trim)=@_;
return ($src=~/[$trim]*(.*)[$trim]*/) ? $1 : $src;
}
#---
#---
#---
sub mysubst {
my ($src,$pattern,$substitution)=@_;
$src=~s/$pattern/$substitution/g;
return $src;
}
#---
#--- substitute macros a la $HOSTNAME$ from environment
#---
sub substitute_macros {
my ($input)=@_;
while ((my $var)=($input=~/\$([A-Z0-9^\$]+)\$/)) {
$input=~s/\$$var\$/$ENV{"NAGIOS_$var"}/g;
}
return $input;
}
#---
#--- add error(s) to global error list
#---
sub add_error {
push @{$rc{error}}, @_;
}
#---
#--- create unique tmpfile and try to create it
#---
sub get_tmpfile {
my ($path,$prefix)=@_;
my $attempt=0;
my $tmpfile="";
#--- check existance of path and create it if necessary
if (! -d $path && ! mkdir($path,0700)) {
die("get_tmpfile: error creating tmp_path $path:$!");
return "";
}
#--- do 5 attempts to create tmpfile
while (++$attempt <= 5) {
my $suffix=int(rand(89999))+10000;
$tmpfile="$path/$prefix.$suffix";
next if (-f $tmpfile);
if (open(TMP,">$tmpfile")) {
close TMP;
return $tmpfile;
}
}
die("get_tmpfile: giving up opening $tmpfile:$!");
return "";
}
#---
#--- remove too old files from $tmpdir
#---
sub garbage_collection {
my $interval=shift;
opendir(DIR, $opt{tmpdir}) or die "garbage_collection: cannot open directory $opt{tmpdir}: $!";
while (defined(my $filename = readdir(DIR))) {
#--- basic security against weak tmpdirs: delete only files beginning with $MYSELF
next if ($filename!~/^$MYSELF/);
my $mtime=(stat("$opt{tmpdir}/$filename"))[9];
if (time-$mtime>($interval*60*60)) {
debug(2, sprintf("garbage collection: removing %d hours old $opt{tmpdir}/$filename", (time-$mtime)/(60*60)));
unlink "$opt{tmpdir}/$filename";
}
}
closedir(DIR);
}
#---
#--- execute $command, return result in %cmd
#---
sub exec_command {
my ($cmd)=@_;
my $tmp_stdout="";
my $tmp_stderr="";
#--- execute command with alarm timer to catch timeouts
$SIG{'ALRM'} = sub { die "timeout" };
eval {
alarm($opt{timeout});
#--- prepare tmpfiles for stdout and stderr
$tmp_stdout=&get_tmpfile($opt{tmpdir}, "${MYSELF}_stdout_$$");
$tmp_stderr=&get_tmpfile($opt{tmpdir}, "${MYSELF}_stderr_$$");
#--- execute command and store stdout/stderr/return code
`$cmd{command} 1>$tmp_stdout 2>$tmp_stderr`;
$cmd{rc}=$? >> 8;
$cmd{timestamp}=time;
#--- store stdout/stderr and cleanup tmpfiles
$cmd{output}=readfile($tmp_stdout);
$cmd{stderr}=readfile($tmp_stderr);
unlink $tmp_stdout, $tmp_stderr;
debug(3, "exec_command: raw output:>" . squeeze($cmd{output},"both",80) . "< raw stderr:>" . squeeze($cmd{stderr},"both",80) . "<");
$cmd{output} .= $cmd{stderr};
#--- unknown return code? change it explicitly to UNKNOWN
if (!defined($rc{r2s}{$cmd{rc}})) {
$cmd{stderr}.=" RC was $cmd{no}{rc}!";
$cmd{rc}=$UNKNOWN;
}
#--- remove white chars from output
chomp $cmd{output};
$cmd{output}=~s/'//mg;
#$cmd{output}=~s/\n/\\n/mg;
#$cmd{output}=mytrim($cmd{output},"\\n\\s");
#$cmd{stderr}=mytrim($cmd{stderr},"\\n\\s");
#print "DEBUG output:>$cmd{output}< stderr:>$cmd{stderr}<n";
alarm(0);
};
#--- any oddities during command execution?
if ($@) {
#--- timeout encountered: store status
if ($@ =~ /timeout/) {
$cmd{output}="UNKNOWN - \'$command\' cancelled after timeout ($opt{timeout}s)";
$cmd{rc}=$UNKNOWN;
#--- catchall for unknown errors
} else {
alarm(0);
die "$MYSELF: unexpected exception encountered:$@";
}
unlink $tmp_stdout, $tmp_stderr;
}
return $cmd{rc};
}
#---
#--- analyze results stored in %cmd
#---
sub do_analysis {
my ($cmd)=@_;
#debug(2,"do_analysis: state:$opt{state} false:$opt{false} number{false}:($rc{number}{$opt{false}})");
my $returncode=$rc{number}{$opt{false}};
#--- first: check return code
if ($opt{ignore_rc}) {
if ($cmd{rc} != 0) {
debug(2, "do_analysis: ignoring error return code $cmd{rc}");
}
} else {
if ($cmd{rc} != 0) {
printf "%s UNKNOWN - cmd %s: %s [%s]\n",
$opt{name},
# replace | with PIPE to avoid perfdata problems
mysubst($cmd{command},"\\|","PIPE"),
squeeze($cmd{output},"left",80),
squeeze($cmd{stderr},"left",80);
return $UNKNOWN;
}
}
#--- check type
if ($opt{type} eq "delta") {
if (defined($cmd{old_timestamp}) && $cmd{old_timestamp} > 0) {
$cmd{elapsed_seconds}=$cmd{timestamp}-$cmd{old_timestamp};
$cmd{delta}=$cmd{output}-$cmd{old_output};
writefile("$opt{tmpdir}/$opt{tmpfile}", "$cmd{timestamp} $cmd{output}");
debug(2, "do_analysis: elapsed_seconds:$cmd{elapsed_seconds} delta:$cmd{delta}");
if ($cmd{elapsed_seconds} > 0) {
$cmd{output}=sprintf "%.2f", $cmd{delta}/$cmd{elapsed_seconds};
}
} else {
writefile("$opt{tmpdir}/$opt{tmpfile}", "$cmd{timestamp} $cmd{output}");
$cmd{result}=squeeze($cmd{output},"left",80);
$cmd{match}="[ delta: no previous output available ]";
return $UNKNOWN;
}
}
#--- start with no match
$cmd{match}="none";
$cmd{matchlist}=[];
if ($opt{string}) {
#--- escape newlines in multiline pattern
$cmd{output}=~s/\n/\\n/mg;
$cmd{result}=squeeze($cmd{output},"left",50);
} else {
#--- remove last newline from numerical patterns
chomp($cmd{output}) if ($cmd{output}=~/\n$/);
$cmd{result}=$cmd{output};
}
#--- step forward in the order of severity from OK to CRITICAL
foreach my $severity (@{$rc{textsev}}) {
if (defined($opt{$severity})) {
my $expression="\'$cmd{output}\'$opt{$severity}";
debug(2,"do_analysis: evaluate expression for severity $severity >\'" . squeeze($cmd{output},"left",80) .
"\'" . squeeze($opt{$severity},"both",80)."<");
#--- can be numerical or string evaluation
if (eval($expression)) {
$cmd{match}=$opt{$severity};
push @{$cmd{matchlist}},$severity;
$returncode=$rc{number}{$severity};
if ($opt{string}) {
$cmd{result}="x" . match_env($cmd{output},$opt{$severity},50);
} else {
$cmd{result}=$cmd{output};
#$cmd{result}=squeeze($cmd{output},"both",80);
}
debug(2,"do_analysis: eval was successful rc:$returncode result:\'$cmd{result}\' match:\'$cmd{match}\'");
} else {
$cmd{result}=squeeze($cmd{output},"both",80);
debug(2,"do_analysis: eval was *not* successful rc:$returncode severity:$severity expression:>\'" .
squeeze($cmd{output},"both",80) . "\'$opt{$severity}<");
}
}
}
return $returncode;
}
#---
#---
#---
sub do_report {
my $cmd=shift;
foreach my $var ('$opt{name}','$rc{rc}','$rc{label}{$rc{rc}}','$cmd{result}','$cmd{match}','$cmd{matchlist}') {
defined_var("do_report",$var);
}
#--- report results
my $report_output=sprintf "%s %s - result:%s match:%s %s",
$opt{name},
$rc{label}{$rc{rc}},
defined($cmd{result}) ? $cmd{result} : "[...]",
defined($cmd{match}) ? $cmd{match} : "[...]",
(@{$cmd{matchlist}}) ? "severities:" . join(',',@{$cmd{matchlist}}) : "";
#print mysubst($report_output,"\\|","PIPE");
print $report_output;
#printf "|%s=%s", $opt{performance}, squeeze($cmd{output},"left",80) if ($opt{performance});
printf "\n";
}
#
#
#
sub defined_var {
my ($prefix,$var)=@_;
if (! eval "defined($var)") {
debug(0,"$prefix: var $var is not defined");
return 0;
}
return 1;
}
#-------------------------------------------------------------------------------
#--- main ----------------------------------------------------------------------
#-------------------------------------------------------------------------------
#--- parse command line options
if (&process_parameters != $OK) {
exit $UNKNOWN;
}
#--- initialize timer for overall timeout
$rc{starttime}=time;
$rc{endtime}=$rc{starttime} + $opt{timeout};
#--- execute command
&exec_command(\%cmd);
#--- analyze results
$rc{rc}=&do_analysis(\%cmd);
#--- report
&do_report(\%cmd);
#--- return rc with highest severity
exit $rc{rc};

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

@ -0,0 +1,125 @@
#!/usr/bin/perl -w
#
# A check to log in a website
#
# By Igor Gubenko (igubenko@Princeton.EDU), 12/15/2011
#
use strict;
use warnings;
use lib qw(/usr/local/perl/lib/perl5);
use Switch;
use Getopt::Std;
use IO::Socket::SSL;
my $context = new IO::Socket::SSL::SSL_Context(
SSL_version => 'tlsv1_2',
SSL_verify_mode => Net::SSLeay::VERIFY_NONE(),
);
IO::Socket::SSL::set_default_context($context);
use LWP::UserAgent;
use HTTP::Request::Common;
#use Net::SSL; # From Crypt-SSLeay
#use LWP::Protocol::https;
#BEGIN {
# $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
# $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
#}
#$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
#$ENV{HTTPS_VERSION} = 3;
sub usage;
my $progname = $0;
my %opt;
# (U)RL, Auth (t)ype, (h)elp, (u)sername, (p)assword, (s)tring to expect, (w)arning threshold, (c)ritical threshold
getopts ("U:t:hu:p:s:w:c:", \%opt);
foreach (qw(U u p)) {
usage unless exists $opt{$_} && not exists $opt{h};
}
my ($url, $type, $user, $pass, $str, $warn, $crit) = (
$opt{U},
exists $opt{t} ? $opt{t} : 'basic',
$opt{u},
$opt{p},
exists $opt{s} ? $opt{s} : undef,
exists $opt{w} ? $opt{w} : 3,
exists $opt{c} ? $opt{c} : 5
);
$url =~ m#^http([s]?)://([^/]+)#i;
my $hst = $2;
$hst .= defined $1 && $1 eq 's' ? ':443' : ':80';
#$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
#$ENV{PERL_LWP_SSL_VERIFY_MODE}='SSL_VERIFY_NONE';
#$ENV{'HTTPS_PROXY'} = 'http://malka.princeton.edu:8888';
my $ua = LWP::UserAgent->new( keep_alive => 1 );
my $tstart = time;
#$ua->proxy ('https', 'http://malka.princeton.edu:8888');
#$ua->proxy ('http', 'http://malka.princeton.edu:3128');
$ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)');
#### FOR DEBUG
#$ua->add_handler("request_send", sub { shift->dump; return });
#$ua->add_handler("response_done", sub { shift->dump; return });
my ($req, $response);
$req = GET $url;
switch ($type) {
case 'ntlm' {
$user =~ s#%#\\#;
$ua->credentials ($hst, '', $user, $pass);
#$ua->credentials ('140.180.227.33:8888', '', $user, $pass);
#print "hst = #$hst#, user = #$user#\n";
}
case 'digest' {
$user =~ m#^([^\\%]+)[\\%]{1}(.*)#;
my $realm = $1;
$user = $2;
#print "user = #$user#, realm = #$realm#\n";
$ua->credentials ($hst, $realm, $user, $pass);
}
case 'basic' {
$req->authorization_basic($user, $pass);
}
else { usage; }
}
#$response = $ua -> request ($req);
$response = $ua -> request ($req, undef, 1024 * 1024);
my $tdiff = time - $tstart;
unless ($response->is_success && (defined $str ? $response->decoded_content =~ m#$str# : 1)) {
print "Error retrieving \"$url\". Error: " . $response->status_line . "\n";
exit 2;
}
#print $response->decoded_content . "\n";
if ($tdiff > $crit) {
print "CRITICAL: Login succeeded, but the request took $tdiff seconds!\n";
exit 2;
} elsif ($tdiff > $warn) {
print "WARNING: Login succeeded, but the request took $tdiff seconds!\n";
exit 1;
}
print "Success retrieving and logging in to \"$url\". Response: " . $response->status_line . "; Time elapsed: $tdiff seconds\n";
exit 0;
sub usage {
print "Usage: $progname <-U URL> <-u username> <-p password> [-w warn_thres] [-c crit_thres] [-t type] [-h] [-s regex_in_response]\n";
print "For digest or ntlm auth, username **MUST** be in the form of DOMAIN%username\n";
exit 2;
}

@ -0,0 +1,22 @@
#!/bin/bash
#
# Wrapper for check_generic
#
plugins="$1"
shift
name="$6"
# This crazy ass shit does the following:
#
# 1) Runs a web check on the first argument given (http://admitted.Princeton.EDU in the example below)
# 2) Looks for a string or regex given by the second argument (Congratulations)
# 3) Substitutes the wrong output given by the third argument (403 Forbidden) to the fourth argument (OK)
# 4) If the resultant output looks like the fifth argument (=~/HTTP\/1.1 OK/), the success, else failure
#
# Example:
# check_command check_http_string!admitted.Princeton.EDU!Congratulations!403 Forbidden!OK!'=~/HTTP\/1.1 OK/'
# command $USER1$/check_http_generic $USER1$ '$ARG1$' '$ARG2$' '$ARG3$' '$ARG4$' "$ARG5$" "$SERVICEDESC$"
#${plugins}/check_generic -e $(/usr/local/monitoring/princeton/generic_http.cmd $plugins "$1" "$2" "$3" "$4") -o "$5" -n $name -i -p test -vvv
${plugins}/check_generic -e "${plugins}/check_http -H $1 -f follow -v | sed -n '/$2/ { h; b }; $ { x; /$2/ { x; s/^[^:]\+: //; s/$3/$4/; x }; x; p }'" -o "$5" -n $name -i -p test ### -vvv

@ -0,0 +1,47 @@
#!/usr/bin/perl -w
#
# Test Kaltura login page accessibility
#
# By Igor Gubenko (igubenko@Princeton.EDU), 06/08/2012
#
use lib qw(/usr/local/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /var/local/groundwork/perl/lib/site_perl/5.8.8/);
#use lib qw(/usr/local/perl/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/local/perl/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/local/perl/lib/perl5/5.8.8 /usr/local/perl/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/ /usr/lib/perl5/5.8.8);
use strict;
use WWW::Mechanize;
sub usage;
my $progname = $0;
usage unless @ARGV == 0;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '1', quiet => '1', timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
my $url_ini = "http://kaltura.princeton.edu";
# Retrieve initial URL
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() && $mech->title() =~ m#Kaltura Video Platform - Home Page#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
# Go to login link
$mech->follow_link (text => 'Kaltura Management Console (KMC)');
unless ($mech -> success() && $mech->title() =~ m#Kaltura - Open Source Video Platform#) {
print "Error going to the login page. Web server returned " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
print "Successfully accessed \"$url_ini\", and navigated to the login page.\n";
exit 0;
sub usage {
print "Usage: $progname\n";
exit 2;
}

@ -0,0 +1,182 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use lib qw(/usr/local/perl/lib/perl5);
use WWW::Mechanize;
$ENV{HTTPS_CA_DIR}='/etc/pki/tls/certs';
use Data::Dumper;
my %args;
sub sub_var {
my $var = shift (@_);
#print "####$var#####\n";
foreach (keys %args) {
my $argv = $args{$_};
$var =~ s#%%$_%%#$argv#g;
}
#print "NEW####$var#####\n";
return $var;
}
unless (@ARGV) {
print STDERR "The first argument should be the web script configuration file\n";
exit 3;
}
my $config_file = shift @ARGV;
unless (-f $config_file) {
print STDERR "Unable to locate or access configuration file \"$config_file\"\n";
exit 3;
}
my %exp;
my ($usage, $url);
my $stat = 0;
my $expect = 0;
open FL, "< $config_file" or do { print STDERR "Unable to open the configuration file \"$config_file\" for reading"; exit 3; };
my @fllines = <FL>;
close FL;
my @usg = grep (/^usage: /, @fllines);
$usage = $usg[0] =~ /^usage: (.*)/ && defined $1 ? $1 : "USAGE CHANGEME IN FILE";
my @arg = grep (/^arg: /, @fllines);
if (@arg) {
$arg[0] =~ s/^arg: //; chomp $arg[0];
my @argn = split (/\s*,\s*/, $arg[0]);
unless (@argn == @ARGV) { print STDERR "Usage: $0 $usage\n"; exit 3; }
foreach (@argn) {
my $argv = shift @ARGV;
$args{$_} = $argv;
}
}
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or do {
print STDERR "Unable to instantiate WWW::Mechanize!\n";
exit 3;
};
#$mech -> add_handler("request_send", sub { shift->dump; return });
#$mech -> add_handler("response_done", sub { shift->dump; return });
foreach (@fllines) {
next if /^\s*(|#.*)$/;
/^\s*;;\s*(|#.*)$/ and do {
if ($mech -> success()) {
$stat = 0;
} else {
$stat = exists $exp{'abort'} ? $exp{'abort'} : 3;
}
if (exists $exp{'title'}) {
if (defined $mech -> title() && $mech -> title() =~ m#$exp{'title'}#) {
$stat = 0;
} else {
$stat = $exp{'abort'} if exists $exp{'abort'};
}
}
if (exists $exp{'content_type'}) {
if (defined $mech -> ct() && $mech -> ct() =~ m#$exp{'content_type'}#) {
$stat = 0;
} else {
$stat = $exp{'abort'} if exists $exp{'abort'};
}
}
if (exists $exp{'exists'}) {
if (defined $mech -> response() -> decoded_content && $mech -> response() -> decoded_content =~ m#$exp{'exists'}#) {
$stat = 0;
} else {
$stat = $exp{'abort'} if exists $exp{'abort'};
}
}
#print Dumper (\%exp);
if ($stat) {
print "$exp{'error'}\n" if exists $exp{'error'};
} else {
print "$exp{'ok'}\n" if exists $exp{'ok'};
}
%exp = ();
$expect = 0;
next;
};
if ($expect) {
/^\s*(\S+)\s*=>\s*(.+)/ and do {
my ($fldk, $fldv) = ($1, $2);
my $m_stat = defined $mech -> status ? $mech -> status : 'not defined';
my $m_answer = defined $mech -> response() && defined $mech -> response() -> decoded_content ? $mech -> response() -> decoded_content : 'not defined';
my $m_title = defined $mech -> title() ? $mech -> title : 'not defined';
my $m_cururl = defined $mech -> uri -> as_string ? $mech -> uri -> as_string : 'not defined';
$fldv =~ s/%%url%%/$url/g;
$fldv =~ s/%%cururl%%/$m_cururl/g;
$fldv =~ s/%%code%%/$m_stat/g;
$fldv =~ s/%%answer%%/$m_answer/g;
$fldv =~ s/%%title%%/$m_title/g;
$exp{$fldk} = $fldv;
};
next;
}
/^GET:\s*(.*)/ and do {
$expect = 1;
$url = sub_var $1;
if ($url =~ m#%%\w+%%#) {
print "Unable to resolve all of the needed arguments in the URL";
exit 3;
}
$mech -> get ($url);
next;
};
/^POST:\s*(.*)$/ and do {
$expect = 1;
if ((not defined $1) || ($1 =~ /^\s*$/)) {
$mech -> submit();
next;
}
my @argpairs = split /\s*,\s*/;
my (%field_args, %submit_args);
foreach (@argpairs) {
/(\S+) => (.*)/ and do {
my ($fldk, $fldv) = ($1, $2);
if ($fldk eq 'button') {
$submit_args{'button'} = $fldv;
} else {
$fldk = sub_var $fldk;
$fldv = sub_var $fldv;
$field_args{$fldk} = $fldv;
}
};
}
#foreach (keys %field_args) {
# print $_, "###", $field_args{$_}, "\n";
#}
$mech -> submit_form (
with_fields => \%field_args,
%submit_args,
);
next;
};
}
exit $stat;

@ -0,0 +1,85 @@
#!/usr/bin/perl -w
#
# Check to login to http://www.princeton.edu/rms, and perform policy accessibility checks - ticket #1717662
#
# By Igor Gubenko (igubenko@Princeton.EDU), 12/15/2011
#
use lib qw(/usr/local/monitoring/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /var/local/groundwork/perl/lib/site_perl/5.8.8/);
use strict;
use WWW::Mechanize;
#use Net::SSL; # From Crypt-SSLeay
#use LWP::Protocol::https;
#BEGIN {
# $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
# $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
#}
#$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
#$ENV{HTTPS_VERSION} = 3;
sub usage;
my $progname = $0;
usage unless @ARGV == 2;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
my $url_ini = "http://www.princeton.edu/rms";
my ($user, $pass) = @ARGV;
# Retrieve initial URL - this is just a very silly bunch of redirects
$mech->get ($url_ini);
unless ($mech -> success() && defined $mech->title() && $mech->title() =~ m#LC SSO Request#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "\n";
exit 2;
}
$url_ini = "https://rms.princeton.edu/edc/Login.do";
# Retrieve the actual website
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#LiveCycle Rights Management#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "\n";
exit 2;
}
# Login
$mech->submit_form (
fields => {
j_username => $user,
j_password => $pass,
}
);
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Manage policies, policy sets#) {
print $mech->response()->decoded_content =~ m#Login failed# ? "Unable to login to Adobe Rights Management. Login failed\n" : 'Error after trying to login. Web server returned ' . $mech->status() . "\n";
exit 2;
}
# Click on Policies
$mech->follow_link (text => 'Policies');
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Policy sets you have access to appear below#) {
print "Error clicking on \"Policies\". Web server returned " . $mech->status() . "\n";
exit 2;
}
# Click on Test Policy Set
$mech->follow_link (text => 'Test Policy Set');
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Edit Policy Set: Test Policy Set#) {
print "Error navigating to \"Test Policy Set\". Web server returned " . $mech->status() . "\n";
exit 2;
}
print "Successfully logged in to \"$url_ini\", navigated to \"Policies\", and then \"Test Policy Set\".\n";
exit 0;
sub usage {
print "Usage: $progname <login_for_www.princeton.edu/rms> <password>\n";
exit 2;
}

@ -0,0 +1,73 @@
#!/usr/bin/perl -w
#
# Test CAS (fed's)
#
# By Igor Gubenko (igubenko@Princeton.EDU), 09/25/2013
#
use strict;
use lib qw(/usr/local/perl/lib/perl5/x86_64-linux-thread-multi /usr/local/perl/lib/perl5);
use WWW::Mechanize;
use Net::SSL; # From Crypt-SSLeay
use LWP::Protocol::https;
BEGIN {
$Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
}
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$ENV{HTTPS_VERSION} = 3;
sub usage;
my $progname = $0;
usage unless @ARGV == 3;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
#$mech->proxy (['http', 'https'], 'http://malka.princeton.edu:8888');
#$mech -> add_handler("request_send", sub { shift->dump; return });
#$mech -> add_handler("response_done", sub { shift->dump; return });
my ($URL, $user, $pass) = @ARGV;
$mech->get ($URL);
unless ($mech -> success() && $mech->title() =~ m#AdminCAS - Login#) {
print "Failed to fetch \"$URL\". Current URL: " . $mech->uri->as_string . ". Answer: " . $mech->status() . ";\n";
exit 2;
}
#my @tmp = $mech->find_all_inputs;
#foreach (@tmp) { print $_->type, "###", $_->name, "\n"; }
#exit 1;
# Login
$mech->submit_form (
with_fields => {
username => $user,
password => $pass,
},
image => '',
);
unless ($mech -> success() && $mech->title() =~ m#Admin CAS - Success#) {
print "Failed to login to CAS. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "\n";
exit 2;
}
$mech->follow_link (text => 'logout');
unless ($mech -> success() && $mech->response()->decoded_content =~ m#You have been logged out#) {
print "Failed to sign out of CAS. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 1;
}
#print "\n#########################\n\n\n", $mech -> response() -> decoded_content, "\n";
print "Successfully accessed CAS, logged in and logged out\n";
exit 0;
sub usage {
print "Usage: $progname <URL> <login> <password>\n";
exit 2;
}

@ -0,0 +1,93 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff = puselenium.init_selenium (['monitor'])
ff, fp = init_selenium ()
try:
#ff.implicitly_wait (10)
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("Sign On"))
uid = ff.find_element_by_id ("userid")
uid.send_keys (usr)
uid.submit()
except:
print "Error retrieving the initial page with user ID entry"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
pupass = ff.find_element_by_id ("Bharosa_Password_PadDataField")
pupass.send_keys (usrpass)
pupass.submit()
except:
print "Error retrieving the password page with the password pad"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='logout']")))
logout1 = ff.find_element_by_xpath ("//a[text()='logout']")
logout1.click()
except:
print "Error logging in or retrieving the page post login"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "close")))
except:
print "Successfully logged in but couldn't get the expected logout page"
sys.exit (1)
time.sleep(2)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to Admin CAS and logged off"
sys.exit (0)

@ -0,0 +1,110 @@
#!/usr/bin/perl -w
use lib qw(/usr/local/perl/lib/perl5 /usr/local/perl/lib/perl5/x86_64-linux-thread-multi);
use strict;
use WWW::Mechanize::Firefox;
use Capture::Tiny ':all';
sub ffquit;
sub waituntilappears;
my ($URL, $id, $pass) = @ARGV;
unless (@ARGV == 3) {
print "Usage: $0 <URL> <login> <password>\n";
exit 3;
}
#print "###$URL###$id###$pass##\n";
#exit 0;
$ENV{'DISPLAY'}=':1';
$ENV{'HOME'}='/home/nagios';
`/usr/bin/killall -9 firefox >/dev/null 2>&1`;
my ($stdout, $stderr, $mech) = capture {
WWW::Mechanize::Firefox->new(launch => 'firefox', create => 1, autoclose => 1, log => [ qw/ error / ]);
};
$mech -> autoclose_tab (0);
#print "####stdout:###$stdout###\n";
#print "####stderr:###$stderr###\n";
#print "####res:#####", @res, "###\n";
sleep 1;
$mech->get ($URL);
#my @tabs = $mech->application->openTabs();
#foreach (@tabs) {
#print "title:##", $_->{title}, "##location:##", $_->{location}, "##\n";
# $mech -> application -> closeTab ($_) if $_ -> {location} =~ m#blank#;
#}
if (waituntilappears '//input[@value="blackboardId"]') {
print "Failed to retrieve \"$URL\". Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
$mech->click ({xpath => '//input[@value="blackboardId"]', single => 'true', synchronize => 0});
if (waituntilappears '//form[@id="bbLoginForm"]') {
print "Failed to retrieve the Blackboard login form. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
$mech -> form_id ('bbLoginForm');
$mech -> set_fields (
user_id => $id,
password => $pass,
);
$mech -> click ({selector => '.btn'});
### TEMP
if (waituntilappears '//a[@title="Logout"]') {
print "Failed to login to Blackboard. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
my @logout = $mech -> xpath ('//a[@title="Logout"]');
unless ($mech -> success() && @logout > 0) {
##unless ($mech -> success()) {# && $mech->response()->decoded_content =~ m#Rover Account#) {
print "Failed to login to Blackboard. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
##sleep 2;
$mech -> follow_link ($logout[0]);
##$mech -> get ("https://blackboard.princeton.edu/webapps/login?action=logout");
if (waituntilappears '//input[@value="blackboardId"]') {
print "Failed to logout out of Blackboard. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
#$mech -> autoclose_tab(0);
print "Successfully logged in to Blackboard and logged out\n";
ffquit 0;
sub ffquit {
my $err = shift;
$mech -> application -> closeTab ($mech -> tab);
$mech -> application -> quit if $mech -> application -> openTabs < 2 || $mech -> application -> openTabs > 2;
sleep 2;
exit $err;
}
sub waituntilappears {
my $retries = 20;
my $fnd = shift;
while ($retries-- > 0) {
return 0 if $mech->is_visible (xpath => $fnd);
sleep 1;
}
return 1;
}

@ -0,0 +1,73 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puseleniumnew import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
ff, fp = init_selenium()
try:
ff.implicitly_wait (10)
ff.get (url)
bbid = ff.find_element_by_xpath ("//input[@type='radio'][@value='blackboardId']")
bbid.click()
loginid = ff.find_element_by_id ("user_id")
loginid.send_keys (usr)
loginpass = ff.find_element_by_id ("password")
loginpass.send_keys (usrpass)
continuebtn = ff.find_element_by_xpath ("//div[text()='Login']")
continuebtn.click()
logout = ff.find_element_by_xpath ("//a[@title='Logout']")
logout.click()
WebDriverWait (ff, 10).until (EC.element_to_be_clickable((By.XPATH, "//input[@type='radio'][@value='blackboardId']")))
time.sleep(5)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to Blackboard and logged off"
sys.exit (0)

@ -0,0 +1,73 @@
#!/usr/bin/perl -w
#
# Test CAS (fed's)
#
# By Igor Gubenko (igubenko@Princeton.EDU), 09/25/2013
#
use strict;
use lib qw(/usr/local/perl/lib/perl5/x86_64-linux-thread-multi /usr/local/perl/lib/perl5);
use WWW::Mechanize;
#use Net::SSL; # From Crypt-SSLeay
#use LWP::Protocol::https;
#BEGIN {
# $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
# $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
#}
#$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
#$ENV{HTTPS_VERSION} = 3;
sub usage;
my $progname = $0;
usage unless @ARGV == 3;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
#$mech->proxy (['http', 'https'], 'http://malka.princeton.edu:8888');
#$mech -> add_handler("request_send", sub { shift->dump; return });
#$mech -> add_handler("response_done", sub { shift->dump; return });
my ($URL, $user, $pass) = @ARGV;
$mech->get ($URL);
unless ($mech -> success() && $mech->title() =~ m#Princeton University Authentication Service#) {
print "Failed to fetch \"$URL\". Current URL: " . $mech->uri->as_string . ". Answer: " . $mech->status() . ";\n";
exit 2;
}
#my @tmp = $mech->find_all_inputs;
#foreach (@tmp) { print $_->type, "###", $_->name, "\n"; }
#exit 1;
# Login
$mech->submit_form (
with_fields => {
username => $user,
password => $pass,
},
image => '',
);
unless ($mech -> success() && $mech->title() =~ m#Princeton University Authentication Service - Success#) {
print "Failed to login to CAS. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; \n";
exit 2;
}
$mech->follow_link (text => 'logout');
unless ($mech -> success() && $mech->response()->decoded_content =~ m#You have been logged out#) {
print "Failed to sign out of CAS. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . ((defined $mech->title() ? $mech->title() : "" )) . "\n";
exit 1;
}
#print "\n#########################\n\n\n", $mech -> response() -> decoded_content, "\n";
print "Successfully accessed CAS, logged in and logged out\n";
exit 0;
sub usage {
print "Usage: $progname <URL> <login> <password>\n";
exit 2;
}

@ -0,0 +1,75 @@
#!/usr/bin/perl -w
#
# Test CAS (fed's)
#
# By Igor Gubenko (igubenko@Princeton.EDU), 09/25/2013
#
use strict;
use lib qw(/usr/local/perl/lib/perl5/x86_64-linux-thread-multi /usr/local/perl/lib/perl5);
use WWW::Mechanize;
use Net::SSL; # From Crypt-SSLeay
use LWP::Protocol::https;
BEGIN {
$Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
}
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$ENV{HTTPS_VERSION} = 3;
sub usage;
my $progname = $0;
usage unless @ARGV == 3;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
#$mech->proxy (['http', 'https'], 'http://malka.princeton.edu:8888');
#$mech -> add_handler("request_send", sub { shift->dump; return });
#$mech -> add_handler("response_done", sub { shift->dump; return });
my ($URL, $user, $pass) = @ARGV;
$mech->get ($URL);
unless ($mech -> success() && $mech->title() =~ m#Princeton University Authentication Service#) {
print "Failed to fetch \"$URL\". Current URL: " . $mech->uri->as_string . ". Answer: " . $mech->status() . ";\n";
exit 2;
}
#my @tmp = $mech->find_all_inputs;
#foreach (@tmp) { print $_->type, "###", $_->name, "\n"; }
#exit 1;
# Login
$mech->submit_form (
with_fields => {
username => $user,
password => $pass,
},
image => '',
);
unless ($mech -> success() && $mech->title() =~ m#Princeton University Authentication Service - Success#) {
print "Failed to login to CAS. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; \n";
exit 2;
}
$URL =~ s#login#logout#;
#print "####$URL#####\n";
$mech->get ($URL);
#unless ($mech -> success() && $mech->response()->decoded_content =~ m#You have been logged out#) {
# print "Failed to sign out of CAS. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . ((defined $mech->title() ? $mech->title() : "" )) . "\n";
# exit 1;
#}
#print "\n#########################\n\n\n", $mech -> response() -> decoded_content, "\n";
print "Successfully accessed CAS, logged in and logged out\n";
exit 0;
sub usage {
print "Usage: $progname <URL> <login> <password>\n";
exit 2;
}

@ -0,0 +1,90 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff, fp = init_selenium (['mon202w'])
ff, fp = init_selenium()
try:
#ff.implicitly_wait (10)
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("Central Authentication Service - CAS"))
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.NAME, "submit")))
uid = ff.find_element_by_id ("username")
uid.send_keys (usr)
pupass = ff.find_element_by_id ("password")
pupass.send_keys (usrpass)
submt = ff.find_element_by_name ("submit")
submt.click()
except:
print "Error retrieving the initial login page"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='log out']")))
logout1 = ff.find_element_by_xpath ("//a[text()='log out']")
logout1.click()
except:
print "Error logging in, or retrieving the page post login"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.title_contains("Logout successful - CAS"))
except:
print "Successfully logged in, but couldn't log out"
sys.exit (1)
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to CAS and logged off"
sys.exit (0)

@ -0,0 +1,90 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff, fp = init_selenium (['mon202w'])
ff, fp = init_selenium()
try:
#ff.implicitly_wait (10)
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("Princeton University Authentication Service"))
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.NAME, "submit")))
uid = ff.find_element_by_id ("username")
uid.send_keys (usr)
pupass = ff.find_element_by_id ("password")
pupass.send_keys (usrpass)
submt = ff.find_element_by_name ("submit")
submt.click()
except:
print "Error retrieving the initial login page"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='logout']")))
logout1 = ff.find_element_by_xpath ("//a[text()='logout']")
logout1.click()
except:
print "Error logging in, or retrieving the page post login"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "close")))
except:
print "Successfully logged in, but couldn't log out"
sys.exit (1)
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to CAS and logged off"
sys.exit (0)

@ -0,0 +1,90 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff, fp = init_selenium (['mon202w'])
ff, fp = init_selenium()
try:
#ff.implicitly_wait (10)
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("Central Authentication Service - CAS"))
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.NAME, "submit")))
uid = ff.find_element_by_id ("username")
uid.send_keys (usr)
pupass = ff.find_element_by_id ("password")
pupass.send_keys (usrpass)
submt = ff.find_element_by_name ("submit")
submt.click()
except:
print "Error retrieving the initial login page"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='log out']")))
logout1 = ff.find_element_by_xpath ("//a[text()='log out']")
logout1.click()
except:
print "Error logging in, or retrieving the page post login"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.title_contains("Logout successful - CAS"))
except:
print "Successfully logged in, but couldn't log out"
sys.exit (1)
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to CAS and logged off"
sys.exit (0)

@ -0,0 +1,90 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff, fp = init_selenium (['mon202w'])
ff, fp = init_selenium()
try:
#ff.implicitly_wait (10)
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("Princeton University Authentication Service"))
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.NAME, "submit")))
uid = ff.find_element_by_id ("username")
uid.send_keys (usr)
pupass = ff.find_element_by_id ("password")
pupass.send_keys (usrpass)
submt = ff.find_element_by_name ("submit")
submt.click()
except:
print "Error retrieving the initial login page"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='logout']")))
logout1 = ff.find_element_by_xpath ("//a[text()='logout']")
logout1.click()
except:
print "Error logging in, or retrieving the page post login"
sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "close")))
except:
print "Successfully logged in, but couldn't log out"
sys.exit (1)
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to CAS and logged off"
sys.exit (0)

@ -0,0 +1,287 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys, re, os
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
#sys.path.insert (2, '/usr/local/monitoring/python/lib/python2.7/site-packages')
#sys.path.insert (3, '/usr/local/monitoring/python/lib/python2.7')
#sys.path.insert (4, '/usr/local/monitoring/python/lib64/python2.6/site-packages')
#sys.path.insert (5, '/usr/local/monitoring/python/lib/python2.6/site-packages')
#sys.path.insert (6, '/usr/local/monitoring/python/lib/python2.6/site-packages/selenium-2.48.0-py2.6.egg')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample, randrange
verb = 0
def tm (tmconv):
return time.strftime("%D %H:%M:%S", time.localtime(tmconv))
def outp (str, level = 1):
if verb >= level:
print "%d: %s" % (level, str)
#print "%d %d" % (verb, level)
def usage ():
print "Usage: %s <ClearPass host or URL to test> <username> <password> [verbosity=1] [alloted_run_time=180]" % sys.argv[0]
sys.exit (3)
if len (sys.argv) < 4:
usage
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
atime = 180
if len (sys.argv) > 4:
verb = int (sys.argv[4])
if len (sys.argv) > 5:
atime = int (sys.argv[5])
outp ("%s: Starting program" % tm(time.time()), 2)
#ff = puselenium.init_selenium (['ims316', 'ims317', 'mon200w', 'mon201w', 'mon202w', 'mon203w'])
ff, fp = init_selenium ()
try:
### Load initial URL
t_ini = time.time()
outp ("%s: Loaded browser" % tm(t_ini), 2)
#ff.implicitly_wait (10)
main_window = ff.current_window_handle
outp ("Retrieving URL %s" % url, 1)
ff.get (url)
#ff.allowNativeXpath("false");
### Check for the sign on page to enter the username
#try:
# WebDriverWait (ff, 60).until (EC.title_contains("ClearPass Policy Manager"))
#except:
# outp ("Unable to reach the initial ClearPass page", 0)
# sys.exit (2)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.XPATH, "//a[contains(.,'ClearPass Guest')]")))
t_main = time.time()
outp ("%s: ClearPass initial page retrieved" % tm(t_main), 2)
outp ("Clicking on ClearPass Guest", 1)
ff.find_element_by_xpath ("//a[contains(.,'ClearPass Guest')]").click()
except:
outp ("Unable to locate the ClearPass Guest link", 0)
sys.exit (2)
time.sleep(2)
for win in ff.window_handles:
ff.switch_to.window (win)
#outp ("Found Window %s" % ff.current_url, 0)
if re.match ("/guest/(guest_index.php|auth_login.php)", ff.current_url, flags=re.IGNORECASE):
break
win = False
ff.maximize_window()
#next_window = ff.window_handles[-1]
#ff.switch_to.window (next_window)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.ID, "ID_form4da79e65_auth_login_username")))
t_login_cpguest = time.time()
outp ("%s: ClearPass Guest Login page retrieved" % tm(t_login_cpguest), 2)
outp ("Entering login fields and clicking on \"Log In\"", 1)
uidfield = ff.find_element_by_id ("ID_form4da79e65_auth_login_username")
uidfield.send_keys (usr)
passfield = ff.find_element_by_id ("ID_form4da79e65_auth_login_password")
passfield.send_keys (usrpass)
passfield.submit()
except:
outp ("Unable to locate one or more fields on the ClearPass Guest Login page. Maybe the page didn't load or change?", 0)
sys.exit (2)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.XPATH, "//a[contains(.,'Manage Devices')]")))
t_cpguest_console = time.time()
outp ("%s: ClearPass Guest Portal page retrieved" % tm(t_cpguest_console), 2)
outp ("Clicking on \"Manage Devices\"", 1)
ff.find_element_by_xpath ("//a[contains(.,'Manage Devices')]").click()
except:
outp ("Unable to login to the ClearPass Guest portal or the page loads incompletely", 0)
sys.exit (2)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.ID, "mac_list_item_20")))
t_cpguest_devices = time.time()
outp ("%s: Loaded devices" % tm(t_cpguest_devices), 2)
outp ("Logging out from ClearPass Guest", 1)
ff.find_element_by_xpath ("//a[contains(.,'Logout')]").click()
except:
outp ("Unable to locate the 20th (last) device on the page. There might be a problem loading the device page", 0)
sys.exit (2)
WebDriverWait (ff, 60).until (EC.title_contains("Login"))
ff.close()
ff.switch_to.window (main_window)
try:
t_cpguest_logout = time.time()
outp ("%s: Logged out from ClearPass Guest and ready to go into ClearPass Policy Manager" % tm(t_cpguest_logout), 2)
outp ("Clicking on ClearPass Policy Manager", 1)
ff.find_element_by_xpath ("//a[contains(.,'ClearPass Policy Manager')]").click()
except:
outp ("Unable to locate the ClearPass Policy Manager link. This is weird and shouldn't have happened.", 0)
sys.exit (2)
time.sleep(2)
for win in ff.window_handles:
ff.switch_to.window (win)
#outp ("Found Window %s" % ff.current_url, 0)
if re.match ("/tips/tipsLogin.action", ff.current_url, flags=re.IGNORECASE):
break
win = False
ff.maximize_window()
#next_window = ff.window_handles[-1]
#ff.switch_to.window (next_window)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.NAME, "password")))
t_login_cppm = time.time()
outp ("%s: ClearPass Policy Manager Login page retrieved" % tm(t_login_cppm), 2)
outp ("Entering login fields and clicking on \"Log In\"", 1)
uidfield = ff.find_element_by_id ("username")
uidfield.send_keys (usr)
passfield = ff.find_element_by_name ("password")
passfield.send_keys (usrpass)
passfield.submit()
except:
outp ("Unable to locate one or more fields on the ClearPass Policy Manager Login page. Maybe the page didn't load or change?", 0)
sys.exit (2)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.ID, "menu_5_5_button")))
t_cppm_console = time.time()
outp ("%s: ClearPass Policy Manager Portal page retrieved" % tm(t_cppm_console), 2)
outp ("Clicking on \"Conguration\" section", 1)
ff.find_element_by_id ("menu_5_5_button").click()
except:
outp ("Unable to login to the ClearPass Policy Manager portal or the page loads incompletely", 0)
sys.exit (2)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.XPATH, "//span[contains(.,'Network')]")))
t_cppm_config = time.time()
outp ("%s: Loaded the \"Configuration\" section" % tm(t_cppm_config), 2)
outp ("Clicking on the \"Network\" menu", 1)
ff.find_element_by_xpath ("//div[@id='menu_5_5']/div/div/div[2]/div[7]").click()
except:
outp ("Unable to click on the \"Network\" Menu. Maybe the page loaded incompletely", 0)
sys.exit (2)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.XPATH, "//span[contains(.,'Devices')]")))
t_cppm_network = time.time()
outp ("%s: Loaded the \"Network\" menu" % tm(t_cppm_network), 2)
outp ("Clicking on the \"Devices\" menu", 1)
ff.find_element_by_xpath ("//span[contains(.,'Devices')]").click()
except:
outp ("Unable to click on the \"Devices\" Menu. Maybe the page loaded incompletely", 0)
try:
WebDriverWait (ff, 60).until (EC.presence_of_element_located((By.XPATH, "//span[contains(.,'Aruba Controllers')]")))
t_cppm_devices = time.time()
outp ("%s: Loaded the \"Devices\" section" % tm(t_cppm_devices), 2)
outp ("Logging out from ClearPass Policy Manager", 1)
ff.find_element_by_xpath ("//a[contains(.,'Logout')]").click()
except:
outp ("Unable to locate the 20th (last) device on the page. There might be a problem loading the device page", 0)
sys.exit (2)
WebDriverWait (ff, 60).until (EC.title_contains("ClearPass Policy Manager"))
ff.close()
ff.switch_to.window (main_window)
msg_final = "Successfully tested ClearPass"
t_end = time.time()
outp ("%s | \
'main_page'=%.3fs;;; \
'guest_login'=%.3fs;;; \
'guest_console'=%.3fs;;; \
'guest_devices'=%.3fs;;; \
'guest_logout'=%.3fs;;; \
'cppm_login'=%.3fs;;; \
'cppm_console'=%.3fs;;; \
'cppm_config'=%.3fs;;; \
'cppm_network'=%.3fs;;; \
'cppm_devices'=%.3fs;;; \
'total_run'=%.3fs;;;" \
% \
(msg_final, \
(t_main - t_ini),\
(t_login_cpguest - t_main),\
(t_cpguest_console - t_login_cpguest),\
(t_cpguest_devices - t_cpguest_console),\
(t_cpguest_logout - t_cpguest_devices),\
(t_login_cppm - t_cpguest_logout),\
(t_cppm_console - t_login_cppm),\
(t_cppm_config - t_cppm_console),\
(t_cppm_network - t_cppm_config),\
(t_cppm_devices - t_cppm_network),\
(t_end - t_ini)), 0)
time.sleep(2)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (2)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (2)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (2)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (2)
finally:
ff.quit()
sys.exit (0)

@ -0,0 +1,74 @@
#!/usr/bin/perl -w
#
# Test accessibility of Departmental Charges webpage, and login
#
# By Igor Gubenko (igubenko@Princeton.EDU), 05/21/2012
#
use lib qw(/usr/local/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /var/local/groundwork/perl/lib/site_perl/5.8.8/);
use strict;
use WWW::Mechanize;
sub usage;
my $progname = $0;
usage unless @ARGV == 3;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '1', onerror => undef, onwarn => undef, quiet => '1', timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
my $url_ini = "https://puwebp.princeton.edu:7900/dc_web/priv/index.html";
my ($user, $pass, $group) = @ARGV;
# Retrieve initial URL
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Departmental Charges \[DC Home\]#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "\n";
exit 2;
}
$url_ini = "https://puwebp.princeton.edu:7900/dc_web/priv/Signin.jsp";
# Retrieve the login page
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Princeton University - Departmental Charges \[Sign In\]#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
# Login
$mech->submit_form (
fields => {
txtUserID => $user,
txtPassword => $pass,
selDept => $group,
}
);
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Do you wish to Sign Out from the Departmental Charges Application#) {
print "Failed: " . ($mech->status() !~ /^200$/ ? "Error submitting login information\n" : "Error logging in\n");
exit 2;
}
$url_ini = "https://puwebp.princeton.edu:7900/dc_web/priv/Signout.jsp";
# Logout
$mech->get ($url_ini);
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Signed Out of the DC system#) {
print 'Failed to log out. Web server returned ' . $mech->status() . "\n";
exit 2;
}
print "Successfully accessed the Departmental Charges webpage, logged in and logged out.\n";
exit 0;
sub usage {
print "Usage: $progname <login_for_dc> <password> <user_group_name>\n";
exit 2;
}

@ -0,0 +1,74 @@
#!/usr/bin/perl -w
#
# Test accessibility of Departmental Charges webpage, and login
#
# By Igor Gubenko (igubenko@Princeton.EDU), 05/21/2012
#
use lib qw(/usr/local/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /var/local/groundwork/perl/lib/site_perl/5.8.8/);
use strict;
use WWW::Mechanize;
sub usage;
my $progname = $0;
usage unless @ARGV == 3;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '1', quiet => '1', timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
my $url_ini = "https://puwebp.princeton.edu:7900/dc_web/priv/index.html";
my ($user, $pass, $group) = @ARGV;
# Retrieve initial URL
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Departmental Charges \[DC Home\]#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
$url_ini = "https://puwebp.princeton.edu:7900/dc_web/priv/Signin.jsp";
# Retrieve the login page
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Princeton University - Departmental Charges \[Sign In\]#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
# Login
$mech->submit_form (
fields => {
txtUserId => $user,
txtPassword => $pass,
selDept => $group,
}
);
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Do you wish to Sign Out from the Departmental Charges Application#) {
print "Failed: " . ($mech->status() !~ /^200$/ ? "Error submitting login information\n" : "Error logging in\n");
exit 2;
}
$url_ini = "https://puwebp.princeton.edu:7900/dc_web/priv/Signout.jsp";
# Logout
$mech->get ($url_ini);
unless ($mech -> success() && $mech->response()->decoded_content =~ m#Signed Out of the DC system#) {
print 'Failed to log out. Web server returned ' . $mech->status() . "\n";
exit 2;
}
print "Successfully accessed the Departmental Charges webpage, logged in and logged out.\n";
exit 0;
sub usage {
print "Usage: $progname <login_for_dc> <password> <user_group_name>\n";
exit 2;
}

@ -0,0 +1,41 @@
#!/usr/bin/perl -w
#
# Try to retrieve all AD users
#
# By Igor Gubenko (igubenko@Princeton.EDU), 05/21/2012
#
use lib qw(/usr/local/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /var/local/groundwork/perl/lib/site_perl/5.8.8/);
use strict;
use WWW::Mechanize;
sub usage;
my $progname = $0;
usage unless @ARGV == 0;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '60') or die ("Unable to instantiate WWW::Mechanize!\n");
my $url_ini = "https://tools.princeton.edu/ListADUsers/DumpAllUsers.aspx";
# Retrieve the AD users
$mech->get ($url_ini);
unless ($mech -> success()) {
print "Failed to fetch AD users from \"$url_ini\". Answer: " . $mech->status() . "\n";
exit 2;
}
my @rows = split (/\n/, $mech->response()->decoded_content);
my $nrows = @rows;
print "Successfully retrieved $nrows users\n";
exit 0;
sub usage {
print "Usage: $progname\n";
exit 2;
}

@ -0,0 +1,197 @@
#!/usr/bin/perl
use lib qw(/usr/local/perl/lib/perl5 /usr/local/perl/lib/perl5/x86_64-linux-thread-multi);
use strict;
use warnings;
use WWW::Mechanize::Firefox;
use Capture::Tiny ':all';
sub ffquit;
sub waituntilappears;
BEGIN {
*CORE::GLOBAL::die = sub {
die @_ if( $^S or not defined $^S );
foreach (@_) {
print "ERROR: $_\n";
}
ffquit 2;
};
*CORE::GLOBAL::warn = sub {
foreach (@_) {
print "WARNING: $_\n";
}
ffquit 1;
};
}
my ($URL, $id, $pass) = @ARGV;
unless (@ARGV == 3) {
print "Usage: $0 <URL> <login> <password>\n";
exit 3;
}
#print "###$URL###$id###$pass##\n";
#exit 0;
$ENV{'DISPLAY'}=':1';
$ENV{'HOME'}='/home/nagios';
`/usr/bin/killall -9 firefox >/dev/null 2>&1`;
my ($stdout, $stderr, $mech) = capture {
#my $instance_port = '4242';
#my $ff = Firefox::Application->new(
# autodie => 0,
# create => 1,
# log => [qw[error]],
# launch => ['/usr/bin/firefox', '-P', 'webtester', '-repl', $instance_port],
# repl => "localhost:$instance_port",
#);
my $mech = WWW::Mechanize::Firefox->new(launch => 'firefox', create => 1, log => [ qw/ error / ]);
#my $mech = WWW::Mechanize::Firefox->new (app => $ff);
};
$mech -> autoclose_tab (0);
#print "####stdout:###$stdout###\n";
#print "####stderr:###$stderr###\n";
#print "####res:#####", @res, "###\n";
sleep 1;
$mech->get ($URL);
#unless ($mech -> success() && $mech->title() =~ m#PUaccess#) {
# print "Failed to retrieve \"$URL\". Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
# ffquit 2;
#}
#sleep 2;
#my $retries = 10;
#while ($retries-- > 0) {
# last if $mech->is_visible (xpath => '//*[@id="userid"]');
# sleep 1;
#}
#$retries < 0 and do {
# print "Failed to retrieve \"$URL\". Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
# ffquit 2;
#};
if (waituntilappears '//*[@id="userid"]') {
print "Failed to retrieve \"$URL\". Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
$mech -> submit_form (
with_fields => {
userid => $id,
},
);
#sleep 2;
#unless ($mech -> success() && $mech->title() =~ m#Sign On#) {
# print "Failed to submit username to PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
# ffquit 2;
#}
#sleep 2;
#$retries = 10;
#while ($retries-- > 0) {
# last if $mech->is_visible (xpath => '//*[@id="Bharosa_Password_PadDataField"]');
# sleep 1;
#}
#$retries < 0 and do {
# print "Failed to submit username to PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
# ffquit 2;
#};
if (waituntilappears '//*[@id="Bharosa_Password_PadDataField"]') {
print "Failed to submit username to PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
$mech -> submit_form (
with_fields => {
Bharosa_Password_PadDataField => $pass,
},
);
##sleep 2;
##unless ($mech -> success() && $mech->title() =~ m#Manage My Enhanced Security Profile#) {
## print "Failed to login to PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
## ffquit 2;
##}
#sleep 2;
#$retries = 10;
#while ($retries-- > 0) {
# last if $mech->is_visible (xpath => '//a[text()="Log out"]');
# sleep 1;
#}
#$retries < 0 and do {
#print "Failed to login to PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
#ffquit 2;
#};
if (waituntilappears '//a[text()="Log out"]') {
print "Failed to login to PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 2;
}
my @lnk = $mech->xpath ('//a[text()="Log out"]', single => 'true');
#foreach (@lnk) {
# print $_ -> {innerHTML}, "\n";
#}
$mech -> follow_link ($lnk[0]);
#$mech->follow_link (xpath => '//a[text()="Log out"]', single => 'true');
if (waituntilappears '//input[@value="LOG OFF"]') {
print "Failed to pre-logout out of PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 1;
}
@lnk = $mech->xpath ('//input[@value="LOG OFF"]', single => 'true');
#foreach (@lnk) {
# print $_ -> {innerHTML}, "\n";
#}
$mech -> follow_link ($lnk[0]);
unless ($mech -> success() && $mech->title() =~ m#Single Sign-Off#) {
print "Failed to logout out of PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
ffquit 1;
}
#sleep 2;
#if (waituntilappears '//title[text()="Princeton University Logout Page"]') {
#if (waituntilappears '//title[contains(., "Princeton University Logout Page")]') {
# print "Failed to logout of PUaccess. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
# ffquit 2;
#}
print "Successfully logged in to PUAccess and logged out\n";
ffquit 0;
sub ffquit {
my $err = shift;
$mech -> application -> closeTab ($mech -> tab);
$mech -> application -> quit if $mech -> application -> openTabs < 2 || $mech -> application -> openTabs > 2;
#sleep 2;
exit $err;
}
sub waituntilappears {
my $retries = 20;
my $fnd = shift;
while ($retries-- > 0) {
return 0 if $mech->is_visible (xpath => $fnd);
sleep 1;
}
return 1;
}

@ -0,0 +1,79 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
ff, fp = init_selenium()
try:
ff.implicitly_wait (10)
ff.get (url)
#WebDriverWait (ff, 10).until (EC.title_contains("Sign On"))
uid = ff.find_element_by_id ("userid")
uid.send_keys (usr)
uid.submit()
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
pupass = ff.find_element_by_id ("Bharosa_Password_PadDataField")
pupass.send_keys (usrpass)
pupass.submit()
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='Log out']")))
logout1 = ff.find_element_by_xpath ("//a[text()='Log out']")
logout1.click()
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//input[@value='LOG OFF']")))
logout2 = ff.find_element_by_xpath ("//input[@value='LOG OFF']")
logout2.click()
WebDriverWait (ff, 10).until (EC.title_contains("Single Sign-Off"))
time.sleep(5)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to PUAccess and logged off"
sys.exit (0)

@ -0,0 +1,64 @@
#!/usr/bin/perl -w
#
# Test AIS ShoppingCart app for book purchases
#
# By Igor Gubenko (igubenko@Princeton.EDU), 10/15/2012
#
use lib qw(/usr/local/monitoring/perl/lib/perl5);
use strict;
use WWW::Mechanize;
#use Net::SSL; # From Crypt-SSLeay
#use LWP::Protocol::https;
#BEGIN {
# $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
# $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
#}
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
#$ENV{HTTPS_VERSION} = 3;
sub usage;
my $progname = $0;
usage unless @ARGV == 1;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '0', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
#$mech -> add_handler("request_send", sub { shift->dump; return });
#$mech -> add_handler("response_done", sub { shift->dump; return });
my $url_ini = "https://$ARGV[0].Princeton.EDU/bookordersws/Shoppingcart.asmx";
# Retrieve initial URL
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#ShoppingCart Web Service#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . ";\n";
exit 2;
}
# Go to login link
$mech->follow_link (text => 'InvokingWebServiceForTesting');
unless ($mech -> success() && $mech->response() -> decoded_content =~ m#To test the operation using the HTTP POST protocol, click the 'Invoke' button.#) {
print "Error clicking on the InvokingWebServiceForTesting link;" . $mech->status() . "\n";
exit 2;
}
# Login
$mech->submit_form ();
unless ($mech -> success() && $mech->response() -> decoded_content =~ m#<Invoking>Success</Invoking>#) {
print "Error clicking on \"Invoke\" or receiving the XML file;" . $mech->status() . "\n";
exit 2;
}
print "Successfully tested the ShoppingCart app\n";
exit 0;
sub usage {
print "Usage: $progname <host>\n";
exit 2;
}

@ -0,0 +1,47 @@
#!/bin/bash
#
# Wrapper for check_generic
#
plugins="$1"
shift
url="$1"
timeout="$2"
name="$3"
curl='/usr/bin/curl'
perl='/usr/local/bin/perl'
#
# Example:
# check_command check_http_string!admitted.Princeton.EDU!Congratulations!403 Forbidden!OK!'=~/HTTP\/1.1 OK/'
# command $USER1$/check_http_generic $USER1$ '$ARG1$' '$ARG2$' '$ARG3$' '$ARG4$' "$ARG5$" "$SERVICEDESC$"
${plugins}/check_generic -e "$curl $url 2>/dev/null | $perl -e '
use JSON qw(decode_json);
my \$data = <>;
my \$json = decode_json (\$data);
if (\$json) {
print \"\$json->{stat}: current time: \" . localtime(\$json->{response}->{time});
} else {
print \"ERROR: Invalid output: NO JSON\";
}
' 2>&1" -o "=~ /^OK:/" -t $timeout -f c -n $name -i
#$curl $url 2>/dev/null | $perl -e '
# use JSON qw(decode_json);
#
# my $data = <>;
#
# my $json = decode_json ($data);
#
# if ($json) {
# print "$json->{stat}: $json->{response}->{time}";
# } else {
# print "ERROR: Invalid output: NO JSON";
# }
#' 2>&1

@ -0,0 +1,46 @@
#!/usr/bin/perl -w
#
# Test CAS PA login page accessibility
#
# By Igor Gubenko (igubenko@Princeton.EDU), 05/21/2012
#
use lib qw(/usr/local/perl/lib/perl5);
#use lib qw(/usr/local/perl/modules/lib/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib/perl5/5.8.8 /usr/local/perl/modules/lib64/perl5/site_perl/5.8.8 /usr/local/perl/modules/lib64/perl5/5.8.8 /var/local/groundwork/perl/lib/site_perl/5.8.8/);
use strict;
use WWW::Mechanize;
sub usage;
my $progname = $0;
usage unless @ARGV == 0;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0', stack_depth => '1', noproxy => '1', quiet => '1', timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
my $url_ini = "https://cas.princeton.edu/parent/index.jsp";
# Retrieve initial URL
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Parental Access Site#) {
print "Failed to fetch \"$url_ini\". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
# Go to login link
$mech->follow_link (text => 'Click here to Log In');
unless ($mech -> success() && $mech->title() =~ m#Parental Access - Log In#) {
print "Error going to the login page. Web server returned " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
print "Successfully accessed \"$url_ini\", and navigated to the login page.\n";
exit 0;
sub usage {
print "Usage: $progname\n";
exit 2;
}

@ -0,0 +1,91 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff, fp = init_selenium (['mon202w'])
ff, fp = init_selenium()
try:
#ff.implicitly_wait (10)
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("Central Authentication Service - CAS"))
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.NAME, "submit")))
uid = ff.find_element_by_id ("username")
uid.send_keys (usr)
pupass = ff.find_element_by_id ("password")
pupass.send_keys (usrpass)
submt = ff.find_element_by_name ("submit")
submt.click()
except:
print "Error retrieving the initial login page"
sys.exit (2)
# try:
# WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='log out']")))
#
# logout1 = ff.find_element_by_xpath ("//a[text()='log out']")
# logout1.click()
# except:
# print "Error logging in, or retrieving the page post login"
# sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.title_contains("ShibbolethTest"))
except:
print "Error getting to Shibboleth Test Page"
sys.exit (1)
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
#print "Successfully logged on to CAS and logged off"
print "Successfully found eduPersonPrincipalName"
sys.exit (0)

@ -0,0 +1,99 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
ff, fp = init_selenium ()
try:
start_url = time.time()
ff.implicitly_wait (10)
try:
ff.get (url)
except:
print "Unable to retrieve URL \"%s\"" % url
sys.exit(2)
start_login = time.time()
try:
uid = ff.find_element_by_id ("username")
uid.send_keys (usr)
pupass = ff.find_element_by_id ("password")
pupass.send_keys (usrpass)
pupass.submit()
except:
print "Error navigating the CAS login page."
sys.exit(2)
try:
WebDriverWait (ff, 10).until (EC.title_contains("Welcome to IBM Cognos software"))
login_time = time.time()
ff.find_element_by_link_text ("Log Off").click()
except:
print "Error logging in or retrieving the Cognos webpage"
sys.exit(2)
logout_time = time.time()
try:
ff.find_element_by_name ("logout-button").click()
WebDriverWait (ff, 10).until (EC.title_contains("Princeton University Logout Page"))
except:
print "Error logging out or retrieving the CAS logout page"
end_time = time.time()
sys.exit(1)
end_time = time.time()
time.sleep(5)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (2)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (2)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (2)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (2)
finally:
ff.quit()
print "Successfully logged on to IW/Cognos and logged off | 'loginpage_get'=%.2fs;;; 'fulllogin'=%.2fs;;; 'logout'=%.2fs;;; 'cas_logout'=%.2fs;;; 'total'=%.2fs;;;" % ((start_login - start_url), (login_time - start_login), (logout_time - login_time), (end_time - logout_time), (end_time - start_url))
sys.exit (0)

@ -0,0 +1,104 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
##ff, fp = init_selenium (['mon200w', 'mon201w', 'mon202w', 'mon203w'])
#ff, fp = init_selenium (['mon203w'])
ff, fp = init_selenium ()
try:
t_ini = time.time()
ff.implicitly_wait (30)
ff.get (url)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.LINK_TEXT, "log in")))
t_inipage = time.time()
ff.find_element_by_link_text ("log in").click ()
except:
print "Error retrieving the initial page having a login link"
sys.exit (1)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Email Address")))
t_username = time.time()
puusr = ff.find_element_by_id ("Email Address")
puusr.send_keys (usr)
pupass = ff.find_element_by_id ("Password")
pupass.send_keys (usrpass)
ff.find_element_by_name ("e").click();
except:
print "Error retrieving the login page"
sys.exit (1)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//label[@for='Lists per Page']")))
t_logon = time.time()
except:
print "Error logging in or retrieving the lists management page"
sys.exit(1)
lgout = ff.find_element_by_id ("logout.cell")
ActionChains(ff).move_to_element(lgout).perform()
lgout.click()
exit_stat = 0
try:
WebDriverWait (ff, 10).until (EC.text_to_be_present_in_element((By.TAG_NAME, "h2"), 'Logged Out'))
t_end = time.time()
print "Successfully logged on to %s, found 'Lists per Page' and logged off | 'initial_page'=%.3fs;;; 'login_page'=%.3fs;;; 'management_page'=%.3fs;;; 'total'=%.3fs;;;" % (url, (t_inipage - t_ini), (t_username - t_inipage), (t_logon - t_username), (t_end - t_logon))
except:
exit_stat = 1
t_end = time.time()
print "Successfully logged on to %s, found 'Lists per Page' but could not log off | 'initial_page'=%.3fs;;; 'login_page'=%.3fs;;; 'management_page'=%.3fs;;; 'total'=%.3fs;;;" % (url, (t_inipage - t_ini), (t_username - t_inipage), (t_logon - t_username), (t_end - t_ini))
time.sleep(5)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
sys.exit (exit_stat)

@ -0,0 +1,76 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
ff, fp = init_selenium ()
try:
ff.implicitly_wait (10)
ff.get (url)
#WebDriverWait (ff, 10).until (EC.title_contains("Sign On"))
uid = ff.find_element_by_id ("userid")
uid.send_keys (usr)
uid.submit()
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
pupass = ff.find_element_by_id ("Bharosa_Password_PadDataField")
pupass.send_keys (usrpass)
pupass.submit()
WebDriverWait (ff, 10).until (EC.title_contains("PeopleSoft Enterprise Sign-in"))
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='Log out']")))
#logout1 = ff.find_element_by_xpath ("//a[text()='logout']")
#logout1.click()
#WebDriverWait (ff, 10).until (EC.title_contains("Admin CAS - Logout"))
time.sleep(5)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
#fp.clean()
ff.quit()
print "Successfully logged on to OAMHUB and logged off"
sys.exit (0)

@ -0,0 +1,154 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
#sys.path.insert (2, '/usr/local/monitoring/python/lib/python2.7/site-packages')
#sys.path.insert (3, '/usr/local/monitoring/python/lib/python2.7')
#sys.path.insert (4, '/usr/local/monitoring/python/lib64/python2.6/site-packages')
#sys.path.insert (5, '/usr/local/monitoring/python/lib/python2.6/site-packages')
#sys.path.insert (6, '/usr/local/monitoring/python/lib/python2.6/site-packages/selenium-2.48.0-py2.6.egg')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff = puselenium.init_selenium (['mon200w', 'mon201w', 'mon202w', 'mon203w'])
#ff, fp = init_selenium (['mon300w', 'mon301w'])
#ff, fp = init_selenium (['mon300w'])
ff, fp = init_selenium ()
try:
ff.implicitly_wait (30)
#ff.allowNativeXpath("false")
try:
ff.get (url)
WebDriverWait (ff, 10).until (EC.title_contains("WorkPlace"))
rid = Select (ff.find_element_by_id ("realmID"))
rid.select_by_visible_text ("Princeton University")
ff.find_element_by_name ("realmButton").submit()
except:
print "Error accessing the initial SRA realm selection page"
sys.exit (2)
#try:
# ff.get (url)
# WebDriverWait (ff, 10).until (EC.title_contains("Secure Remote Access"))
#except:
# print "Error accessing the SRA login page"
# sys.exit (2)
try:
WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "data_0")))
puusr = ff.find_element_by_id ("data_0")
puusr.send_keys (usr)
pupass = ff.find_element_by_id ("data_1")
pupass.send_keys (usrpass)
ff.find_element_by_name ("okButton").click()
except:
print "Error accessing elements on the SRA login page"
sys.exit (2)
# look for "Session Limit", and if so, press OK
try:
#print "Look for Session Limit"
WebDriverWait (ff, 10).until (EC.text_to_be_present_in_element((By.TAG_NAME, "b"), 'Session Limit'))
#if not ff.find_element_by_xpath ("//div[contains(.,'Session Limit')]"):
# raise
#print "Session Limit found"
ff.find_element_by_name ("okButton").click()
#print "Clicked on OK"
except:
pass
# Look for "Missing Components", and if so, press "Continue"
try:
#print "Look for Missing Components"
WebDriverWait (ff, 10).until (EC.text_to_be_present_in_element((By.TAG_NAME, "body"), 'Missing Components'))
#if not ff.find_element_by_xpath ("//body[contains(.,'Missing Components')]"):
# raise
#print "Missing Components found"
#ff.find_element_by_xpath ("//input[@type='button'][@value=' Continue ']").click()
ff.find_element_by_css_selector ("input.submitbutton[value*='Continue']").click()
#print "Clicked on Continue"
except:
# Look for "Aventail Access Manager", and if so, press Remind Me Later
try:
#print "Look for Aventail Access Manager"
WebDriverWait (ff, 10).until (EC.text_to_be_present_in_element((By.TAG_NAME, "div"), 'Aventail Access Manager'))
#if not ff.find_element_by_xpath ("//div[contains(.,'Aventail Access Manager')]"):
# raise
#print "Aventail Access Manager found"
ff.find_element_by_xpath ("//input[@type='button'][@value=' Remind me later ']").click()
#ff.execute_script ("setEPCCookie('remind_me_later', 'true', false); document.location='/postauth/__EPCinterrogatornext?success=%2Fworkplace%2Faccess%2Fhome';")
#print "Clicked on Remind Me Later"
except:
pass
# Check if we are in fact logged in to the main site. If so, log out
try:
WebDriverWait (ff, 30).until (EC.presence_of_element_located((By.XPATH, "//a[@title='Log out']")))
ff.find_element_by_xpath ("//a[@title='Log out']").click()
except:
#print "Unable to locate known webpage elements, such as \"Remind Me Later\" button, \"Missing Components\" dialog, or \"Log out\" link. Maybe the page loaded incorrectly"
print "Unable to locate known webpage elements after login, such as the \"Log out\" link. Maybe the page loaded incorrectly"
sys.exit (2)
exit_stat = 0
# Check if we logged out successfully
try:
WebDriverWait (ff, 10).until (EC.text_to_be_present_in_element((By.TAG_NAME, "body"), 'Logout successful'))
print "Successfully logged on to %s and logged out" %url
except:
print "Successfully logged on to %s but failed to log out" %url
exit_stat = 1
time.sleep(3)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (2)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (2)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Response: %s" % msg
sys.exit (2)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (2)
finally:
ff.quit()
sys.exit (exit_stat)

@ -0,0 +1,122 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
#sys.path.insert (2, '/usr/local/monitoring/python/lib/python2.7/site-packages')
#sys.path.insert (3, '/usr/local/monitoring/python/lib/python2.7')
#sys.path.insert (4, '/usr/local/monitoring/python/lib64/python2.6/site-packages')
#sys.path.insert (5, '/usr/local/monitoring/python/lib/python2.6/site-packages')
#sys.path.insert (6, '/usr/local/monitoring/python/lib/python2.6/site-packages/selenium-2.48.0-py2.6.egg')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff = puselenium.init_selenium (['ims316', 'ims317'])
ff, fp = init_selenium ()
try:
t_ini = time.time()
ff.implicitly_wait (30)
ff.get (url)
try:
#WebDriverWait (ff, 10).until (EC.title_contains("Sign On"))
#if not ff.find_element_by_xpath ("//body[contains(.,'Logon is required. If you have forgotten your logon information, contact your help desk or administrator')]"):
ff.find_element_by_xpath ("//body[contains(.,'If you have forgotten your logon information')]")
except:
print "Error retrieving the initial page"
ff.quit()
sys.exit (2)
t_username = time.time()
puusr = ff.find_element_by_name ("userID");
puusr.send_keys (usr)
ff.find_element_by_name ("nextUserID").click();
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
#if not ff.find_element_by_xpath ("//body[contains(.,'Select your preferred authentication method and log on')]"):
# print "Error retrieving the authentication method page"
# sys.exit (1)
#start_authmethod = time.time()
#authm = Select (ff.find_element_by_name ("authMethod"))
#authm.select_by_value ("RSA_Password")
#ff.find_element_by_name ("loginWithMethod").click();
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='Log out']")))
try:
ff.find_element_by_xpath ("//body[contains(.,'" + usr + "')]")
except:
print "Error retrieving the password entry page"
ff.quit()
sys.exit (2)
t_pass = time.time()
pupass = ff.find_element_by_name ("password");
pupass.send_keys (usrpass)
ff.find_element_by_name ("loginWithPwd").click();
try:
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='Log out']")))
ff.find_element_by_xpath ("//body[contains(.,'Logged on as:')]")
except:
print "Error logging in"
ff.quit()
sys.exit(2)
t_login = time.time()
ff.find_element_by_xpath ("//a[text()='Log Off']").click()
exit_stat = 0
try:
ff.find_element_by_xpath ("//body[contains(.,'Successful Logoff')]")
print "Successfully logged on to %s and logged off | 'loginpage_get'=%ss;;; 'passpage_get'=%ss;;; 'fulllogin'=%ss;;; 'total'=%ss;;;" % (url, (t_username - t_ini), (t_pass - t_username), (t_login - t_pass), (t_login - t_ini))
except:
print "Successfully logged on to %s but could not logoff | 'loginpage_get'=%ss;;; 'passpage_get'=%ss;;; 'fulllogin'=%ss;;; 'total'=%ss;;;" % (url, (t_username - t_ini), (t_pass - t_username), (t_login - t_pass), (t_login - t_ini))
exit_stat = 2
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
sys.exit (exit_stat)

@ -0,0 +1,107 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
#sys.path.insert (2, '/usr/local/monitoring/python/lib/python2.7/site-packages')
#sys.path.insert (3, '/usr/local/monitoring/python/lib/python2.7')
#sys.path.insert (4, '/usr/local/monitoring/python/lib64/python2.6/site-packages')
#sys.path.insert (5, '/usr/local/monitoring/python/lib/python2.6/site-packages')
#sys.path.insert (6, '/usr/local/monitoring/python/lib/python2.6/site-packages/selenium-2.48.0-py2.6.egg')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
##ff = puselenium.init_selenium (['ims316', 'ims317'])
ff, fp = init_selenium ()
try:
t_ini = time.time()
ff.implicitly_wait (30)
ff.get (url)
try:
#WebDriverWait (ff, 10).until (EC.title_contains("Self-Service Console"))
ff.find_element_by_name ("textFieldUserID")
except:
print "Error retrieving the initial page having a login textbox"
#ff.quit()
sys.exit (2)
t_username = time.time()
puusr = ff.find_element_by_name ("textFieldUserID");
puusr.send_keys (usr)
ff.find_element_by_name ("loginToMyAccount").click();
try:
ff.find_element_by_xpath ("//label[contains(.,'Password:')]")
except:
print "Error retrieving the password entry page"
#ff.quit()
sys.exit (2)
t_pass = time.time()
pupass = ff.find_element_by_name ("password");
pupass.send_keys (usrpass)
ff.find_element_by_name ("loginWithPwd").click();
try:
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.XPATH, "//a[text()='Log out']")))
ff.find_element_by_xpath ("//body[contains(.,'This page allows you to view your user profile and manage your authenticators')]")
except:
print "Error logging in"
#ff.quit()
sys.exit(2)
t_logon = time.time()
ff.find_element_by_xpath ("//a[text()='Log Off']").click()
exit_stat = 0
try:
ff.find_element_by_xpath ("//body[contains(.,'Log on with your')]")
print "Successfully logged on to %s and logged off | 'username'=%ss;;; 'pass'=%ss;;; 'logon'=%ss;;; 'total'=%ss;;;" % (url, (t_username - t_ini), (t_pass - t_username), (t_logon - t_pass), (t_logon - t_ini))
except:
exit_stat = 2
print "Successfully logged on to %s but could not log off | 'username'=%ss;;; 'pass'=%ss;;; 'logon'=%ss;;; 'total'=%ss;;;" % (url, (t_username - t_ini), (t_pass - t_username), (t_logon - t_pass), (t_logon - t_ini))
time.sleep(1)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
sys.exit (exit_stat)

@ -0,0 +1,82 @@
#!/usr/bin/perl -w
#
# Test sp2010
#
# By Igor Gubenko (igubenko@Princeton.EDU), 09/25/2013
#
use strict;
use lib qw(/usr/local/perl/lib/perl5/x86_64-linux-thread-multi /usr/local/perl/lib/perl5);
use WWW::Mechanize;
#use Net::SSL; # From Crypt-SSLeay
#use LWP::Protocol::https;
#BEGIN {
# $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
# $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}="IO::Socket::SSL";
#}
#$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
#$ENV{HTTPS_VERSION} = 3;
$ENV{HTTPS_CA_DIR}='/etc/pki/tls/certs';
sub usage;
my $progname = $0;
usage unless @ARGV >= 3;
my $mech = WWW::Mechanize->new (agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', stack_depth => '1', noproxy => '1', quiet => '1', onerror => undef, onwarn => undef, timeout => '20') or die ("Unable to instantiate WWW::Mechanize!\n");
#$mech->proxy (['http', 'https'], 'http://malka.princeton.edu:8888');
$mech -> add_handler("request_send", sub { shift->dump; return });
$mech -> add_handler("response_done", sub { shift->dump; return });
my ($host, $user, $pass, $str) = @ARGV;
$str = '.*' unless defined $str;
my $url_ini = "https://${host}.princeton.edu/oit/csg/sharepoint/default.aspx";
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Sign In#) {
print "Failed to fetch \"$url_ini\". Current URL: " . $mech->uri->as_string . ". Answer: " . $mech->status() . ";\n";
exit 2;
}
# Login
$mech->submit_form (
'form_id' => 'loginForm',
with_fields => {
'userNameInput' => $user,
'passwordInput' => $pass,
},
);
unless ($mech -> success() && $mech->title() =~ m#Working#) {
print "Failed to login at Federation Services. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
$mech->submit();
unless ($mech -> success() && $mech->title() =~ m#Home - SharePoint# && $mech->response()->decoded_content =~ m#$str#) {
print "Failed to follow with authentication to SharePoint. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 2;
}
#print "\n#########################\n\n\n", $mech -> response() -> decoded_content, "\n";
$url_ini = 'https://sp2010prod.princeton.edu/oit/csg/sharepoint/_layouts/SignOut.aspx';
$mech->get ($url_ini);
unless ($mech -> success() && $mech->title() =~ m#Sign Out: Close Browser To Complete Sign Out#) {
print "Failed to sign out of SharePoint. Current URL: ". $mech->uri->as_string . ". Answer: " . $mech->status() . "; " . $mech->title() . "\n";
exit 1;
}
#print "\n#########################\n\n\n", $mech -> response() -> decoded_content, "\n";
print "Successfully accessed SharePoint, logged in and logged out\n";
exit 0;
sub usage {
print "Usage: $progname <host> <login> <password>\n";
exit 2;
}

@ -0,0 +1,109 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
#sys.path.insert (2, '/usr/local/monitoring/python/lib/python2.7/site-packages')
#sys.path.insert (3, '/usr/local/monitoring/python/lib/python2.7')
#sys.path.insert (4, '/usr/local/monitoring/python/lib64/python2.6/site-packages')
#sys.path.insert (5, '/usr/local/monitoring/python/lib/python2.6/site-packages')
#sys.path.insert (6, '/usr/local/monitoring/python/lib/python2.6/site-packages/selenium-2.48.0-py2.6.egg')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
ff, fp = init_selenium ()
try:
prog_start = time.time()
ff.implicitly_wait (10)
try:
ff.get (url)
except:
print "Unable to retrieve the initial (Login) webpage \"%s\"" % url
sys.exit (2)
#WebDriverWait (ff, 20).until (EC.title_contains("Sign In"))
fed_login = time.time()
try:
uid = ff.find_element_by_id ("userNameInput")
uid.send_keys (usr)
except:
print "Unable to locate the login field. Page likely loaded incorrectly"
sys.exit (2)
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
try:
pupass = ff.find_element_by_id ("passwordInput")
pupass.send_keys (usrpass)
pupass.submit()
except:
print "Unable to locate the password field. Page likely loaded incorrectly"
sys.exit (2)
try:
WebDriverWait (ff, 30).until (EC.presence_of_element_located((By.XPATH, "//a[contains(@href, '/SiteAssets/OITmedallion_onWhite.gif')]")))
gwmenu = ff.find_element_by_id ("O365_MainLink_Me")
gwmenu.click()
logoutln = ff.find_element_by_xpath ("//*[text()='Sign Out']")
logoutln.click()
except:
print "Unable to locate the OIT logo and/or the \"Sign Out\" link. The webpage likely did not fully load"
sys.exit (2)
prog_finish = time.time()
try:
WebDriverWait (ff, 10).until (EC.title_contains("Please close the browser to complete sign out."))
except:
print "Failed to sign out of SharePoint. This is likely harmless"
sys.exit (1)
time.sleep(2)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
#fp.clean()
ff.quit()
print "Successfully logged on to SharePoint (\"%s\") and logged off | 'loginpage_get'=%ss;;; 'fulllogin'=%ss;;; 'total'=%ss;;;" % (url, (fed_login - prog_start), (prog_finish - fed_login), (prog_finish - prog_start))
sys.exit (0)

@ -0,0 +1,109 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
#sys.path.insert (2, '/usr/local/monitoring/python/lib/python2.7/site-packages')
#sys.path.insert (3, '/usr/local/monitoring/python/lib/python2.7')
#sys.path.insert (4, '/usr/local/monitoring/python/lib64/python2.6/site-packages')
#sys.path.insert (5, '/usr/local/monitoring/python/lib/python2.6/site-packages')
#sys.path.insert (6, '/usr/local/monitoring/python/lib/python2.6/site-packages/selenium-2.48.0-py2.6.egg')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
ff, fp = init_selenium ()
try:
prog_start = time.time()
ff.implicitly_wait (10)
try:
ff.get (url)
except:
print "Unable to retrieve the initial (Login) webpage \"%s\"" % url
sys.exit (2)
#WebDriverWait (ff, 20).until (EC.title_contains("Sign In"))
fed_login = time.time()
try:
uid = ff.find_element_by_id ("userNameInput")
uid.send_keys (usr)
except:
print "Unable to locate the login field. Page likely loaded incorrectly"
sys.exit (2)
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
try:
pupass = ff.find_element_by_id ("passwordInput")
pupass.send_keys (usrpass)
pupass.submit()
except:
print "Unable to locate the password field. Page likely loaded incorrectly"
sys.exit (2)
try:
WebDriverWait (ff, 30).until (EC.presence_of_element_located((By.XPATH, "//img[contains(@src, 'OITmedallion_onWhite.gif')]")))
gwmenu = ff.find_element_by_id ("zz8_Menu")
gwmenu.click()
logoutln = ff.find_element_by_xpath ("//*[text()='Sign Out']")
logoutln.click()
except:
print "Unable to locate the OIT logo and/or the \"Sign Out\" link. The webpage likely did not fully load"
sys.exit (2)
prog_finish = time.time()
try:
WebDriverWait (ff, 10).until (EC.title_contains("Sign Out"))
except:
print "Failed to sign out of SharePoint. This is likely harmless"
sys.exit (1)
time.sleep(2)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
#fp.clean()
ff.quit()
print "Successfully logged on to SharePoint (\"%s\") and logged off | 'loginpage_get'=%ss;;; 'fulllogin'=%ss;;; 'total'=%ss;;;" % (url, (fed_login - prog_start), (prog_finish - fed_login), (prog_finish - prog_start))
sys.exit (0)

@ -0,0 +1,112 @@
#!/usr/local/monitoring/bin/python
import calendar, time, sys
sys.path.insert (1, '/usr/local/monitoring/princeton/lib')
from puselenium import init_selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions as EXCEP
from random import sample
if len (sys.argv) != 4:
print "Usage: %s <URL> <username> <password>" % sys.argv[0]
sys.exit (3)
url = sys.argv[1]
usr = sys.argv[2]
usrpass = sys.argv[3]
#ff, fp = init_selenium (['mon203w'])
ff, fp = init_selenium ()
try:
prog_start = time.time()
ff.implicitly_wait (10)
try:
ff.get (url)
except:
print "Unable to retrieve the initial (Login) webpage \"%s\"" % url
sys.exit (2)
#WebDriverWait (ff, 20).until (EC.title_contains("Sign In"))
fed_login = time.time()
try:
uid = ff.find_element_by_id ("userNameInput")
uid.send_keys (usr)
except:
print "Unable to locate the login field. Page likely loaded incorrectly"
sys.exit (2)
#WebDriverWait (ff, 10).until (EC.presence_of_element_located((By.ID, "Bharosa_Password_PadDataField")))
try:
pupass = ff.find_element_by_id ("passwordInput")
pupass.send_keys (usrpass)
ff.find_element_by_id ("submitButton").click()
except:
print "Unable to locate the password field. Page likely loaded incorrectly"
sys.exit (2)
try:
ff.get (url + "/Organization Logos/logoPU.png")
except:
print "Unable to retrieve logoPU.png"
sys.exit (2)
#try:
ff.back()
gwmenu = ff.find_element_by_id ("O365_MainLink_Me")
gwmenu.click()
logoutln = ff.find_element_by_xpath ("//*[text()='Sign Out']")
logoutln.click()
#except:
# print "Unable to navigate back to main page and/or locate the \"Sign Out\" link. The webpage likely did not fully load"
# sys.exit (1)
prog_finish = time.time()
try:
WebDriverWait (ff, 10).until (EC.title_contains("Please close the browser to complete sign out."))
except:
print "Failed to sign out of SharePoint. This is likely harmless"
sys.exit (1)
time.sleep(2)
except EXCEP.ErrorInResponseException, (resp, msg):
print "ERROR: An error occured communicating with the browser server: Response: %s; Message: %s" % (resp, msg)
sys.exit (1)
except EXCEP.NoSuchElementException, msg:
print "ERROR: Unable to locate webpage element. Probably the page loaded incompletely or incorrectly: %s" % msg
sys.exit (1)
except EXCEP.TimeoutException, msg:
print "ERROR: Request timed out. Network??? Response: %s" % msg
sys.exit (1)
except EXCEP.WebDriverException, msg:
print "ERROR: I don't know what happened. Read this - %s" % msg
sys.exit (1)
finally:
ff.quit()
print "Successfully logged on to SharePoint (\"%s\") and logged off | 'loginpage_get'=%ss;;; 'fulllogin'=%ss;;; 'total'=%ss;;;" % (url, (fed_login - prog_start), (prog_finish - fed_login), (prog_finish - prog_start))
sys.exit (0)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save