SlideShare a Scribd company logo
Scripting...…on the Windows side
These slides represent the work and opinions of the author and do not constitute official positions of any organization sponsoring the author’s work This material has not been peer reviewed and is presented here as-is with the permission of the author.The author assumes no liability for any content or opinion expressed in this presentation and or use of content herein.Disclaimer!It is not their fault!It is not my fault!It is your fault!
External ScriptsInternal ScriptsArgumentsScripting: Batch filesWrapped scriptsScripting: VBAInternal ScriptsAgenda
Windows monitoringNSClient++ (from a scripters perspecitve)
External ScriptsThe normal kind of scriptsCan be written in:BatchVBA/VBScript (pretty popular on Windows)Powershell (a rather strange language)But also:Perl, python, bash, etc etc…Internal ScriptsCan interact with (other) internal commandsCan access settingsCan hold stateCan be written in:LuaPython (requires python on the machine)Two kinds of scripts
Enable the check module[/modules]CheckExternalScripts=	# Runs the scriptNRPEServer=			# NRPE serverEach script requires a definition[/settings/External Scripts]check_es_test=scripts\test.batOptions disabled by default (for a reason)allow arguments = falseallow nasty characters = falseConfiguring External Scripts
Enable the check module[/modules]LUAScript=PythonScript=Each script requires a definition[/settings/LUA/Scripts]<alias>=test.lua[/settings/python/Scripts]<alias>=test.pyScripts requires NRPE/NSCA (or NSCP)[/modules]NRPEServer=Configuring Internal Scripts
Can be configured in many placesIs probably more confusing then it is worthThe server moduleMeans NO commands can have argumentsThe script moduleMeans NO external script can have argumentsAllow arguments
Allow arguments
Writing our first ScriptsThe first batch script
Output:Use: echo <text>Don’t forget @echo off (or all commands will be echoed)Exit statuses:Use: exit <code>0 = OK1 = Warning2 = Critical3 = UnknownNSC.ini syntax:[/settings/External Scripts/scripts]my_script=scripts\script.batReference:http://www.ss64.com/nt/Don’t let preconceptions fool you: batch can actually do a lot!Writing a Script (Batch)
@echo offecho CRITICAL: Everything is not going to be fineexit 2A basic script (batch)
…\NSClient++\scripts>cmd /ctest.batCRITICAL: Everything is not going to be fine…\NSClient++\scripts>echo %ERRORLEVEL%2Running from Command Line
D:\demo>nscp --testNSClient++ 0,4,0,98 2011-09-06 x64 booting...Boot.ini found in: D:/demo//boot.iniBoot order: ini://${shared-path}/nsclient.ini, old://${exe-path}/nsc.iniActivating: ini://${shared-path}/nsclient.iniCreating instance for: ini://${shared-path}:80/nsclient.iniReading INI settings from: D:/demo//nsclient.iniLoading: D:/demo//nsclient.ini from ini://${shared-path}/nsclient.iniBooted settings subsystem...On crash: restart: NSClientppArchiving crash dumps in: D:/demo//crash-dumpsbooting::loading pluginsFound: CheckExternalScripts asProcessing plugin: CheckExternalScripts.dll asaddPlugin(D:/demo//modules/CheckExternalScripts.dll as )Loading plugin: Check External Scripts asNSClient++ - 0,4,0,98 2011-09-06 Started!Enter command to inject or exit to terminate...Running from NSClient
Enter command to inject or exit to terminate...my_scriptsInjecting: my_script...Arguments:Result my_script: WARNINGWARNING:Hello WorldRunning from NSClientCommandReturn StatusReturn Message
DemoWriting our first Scripts
Writing our first ScriptsKilling notepad once and or all!
TASKKILL [/S dator [/U användarnamn [/P lösenord]]]]         { [/FI filter] [/PID process-ID | /IM avbildning] } [/T][/F]Beskrivning:    Det här verktyget används för att avsluta en eller flera aktiviteter    utifrån process-ID (PID) eller avbildningsnamn.Parameterlista:…    /FI   filter           Använder ett filter för att välja aktiviteter.                           Jokertecknet * kan användas, t.ex:imagenameeq note*    /PID  process-ID       Anger process-ID för den process som ska avbrytas.                           Använd kommandot Tasklist för att hämta process-ID    /IM   avbildning       Anger avbildning för den process som                           för den process som ska avslutas. Jokertecknet *                           användas för att ange alla aktiviteter eller                           avbildningar.Killing notepad once and for all!
@echo offtaskkill /im notepad.exe 1>NUL 2>NULIF ERRORLEVEL 128 GOTO errIF ERRORLEVEL 0 GOTO okGOTO unknown:unknownecho UNKNOWN: unknown problem killing notepad...exit /B 3:errecho CRITICAL: Notepad was not killed...exit /B 1:okecho OK: Notepad was killed!exit /B 0KILL!!!
DemoKilling notepad…
Wrapped scriptsInterlude
NSC.ini syntax:[External Scripts]check_bat=scripts\check_test.batOr[Wrapped Scripts]check_test=check_test.batAdding a Script (.bat)
NSC.ini syntax:[External Scripts]check_test=cscript.exe /T:30 /NoLogo scripts\check_test.vbsOr[Wrapped Scripts]check_test=check_test.vbsAdding a Script (.VBS)
NSC.ini syntax:[External Scripts]check_test=cscript.exe /T:30 /NoLogo scripts\lib\wrapper.vbs scripts\check_test.vbsOr[Wrapped Scripts]check_test=check_test.vbsAdding a Script (.VBS) w/ libs
NSC.ini syntax:[External Scripts]check_test=cmd /c echo scripts\check_test.ps1; exit($lastexitcode) | powershell.exe -command -Or[Wrapped Scripts]check_test=check_test.ps1Adding a Script (.PS1)
[…/wrappings]bat=scripts\%SCRIPT% %ARGS%vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -[…/wrapped scripts]check_test_vbs=check_test.vbs /arg1:1 /variable:1check_test_ps1=check_test.ps1 arg1 arg2check_test_bat=check_test.bat $ARG1$ arg2check_battery=check_battery.vbscheck_printer=check_printer.vbs; So essentially it is a macro! (but a nice one)What is wrapped scripts?
Writing your first ScriptsWriting a simple VB script
Output:Use: Wscript.StdOut.WriteLine <text>Exit statuses:Use: Wscript.Quit(<code>)0 = OK1 = Warning2 = Critical3 = UnknownNSC.ini syntax:[External Scripts]check_vbs=cscript.exe //T:30 //NoLogo scripts\check_vbs.vbs	//T:30 Is the timeout and might need to be changed.Reference:http://msdn.microsoft.com/en-us/library/t0aew7h6(VS.85).aspxWriting a Script (VBS)
wscript.echo ”Hello World"wscript.quit(0)Hello_World.vbs
Set <variable name>=CreateObject(“<COM Object>")There is A LOT of objects you can createA nice way to interact with other applicationsFor instance:Set objWord = CreateObject("Word.Application")objWord.Visible = TrueSet objDoc = objWord.Documents.Add()Set objSelection = objWord.SelectionobjSelection.Font.Name = “Comic Sans MS"objSelection.Font.Size = “28"objSelection.TypeText“Hello World"objSelection.TypeParagraph()objSelection.Font.Size = "14"objSelection.TypeText "" & Date()objSelection.TypeParagraph()Object oriented programming (ish)
Demo:Words…
strFile=”c:\windows”Dim oFSOSet oFSO=CreateObject("Scripting.FileSystemObject")If oFSO.FileExists(strFile) Thenwscript.echo”Yaay!"wscript.quit(0)elsewscript.echo“Whhh… what the f***!"wscript.quit(2)end ifAre we running windows?
Demo:Are we running Windows?
Using the libraryDissecting a VBScript
Can be used to extend NSClient++Are very powerfulA good way to:Alter things you do not likeCreate advanced thingsAre written in Lua or PythonPossibly unsafeRuns inside NSClient++Internal Scripts
Internal scripts are fundamentally differentOne script is NOT equals to one functionA script (at startup) can:Register query (commands) handlersRegister submission (passive checks) handlersRegister exec handlersRegister configurationAccess configurationHandlers can:Execute queries (commands)Submit submissions (passive checks)Etc etc…Anatomy of an internal script
definit(plugin_id, plugin_alias, script_alias):conf = Settings.get()reg = Registry.get(plugin_id)reg.simple_cmdline('help', get_help)reg.simple_function(‘command', cmd, ‘A command…')conf.set_int('hello', 'python', 42)	log(Answer: %d'%conf.get_int('hello','python',-1))def shutdown():	log(“Shutting down…”)A basic script
defget_help(arguments):	return (status.OK, ‘Im not helpful ')def test(arguments):	core = Core.get()count = len(arguments)(retcode, retmessage, retperf) =core.simple_query(‘CHECK_NSCP’, [])return (status.OK, ‘Life is good… %d'%count)A basic script
Questions?Q&A
Michael Medinmichael@medin.namehttp://www.linkedin.com/in/mickemInformation about NSClient++http://nsclient.orgFacebook: facebook.com/nsclientSlides, and exampleshttp://nsclient.org/nscp/conferances/2011/nwcna/Thank You!

More Related Content

What's hot (19)

ruxc0n 2012
ruxc0n 2012ruxc0n 2012
ruxc0n 2012
mimeframe
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
All Things Open
 
.NET Debugging Workshop
.NET Debugging Workshop.NET Debugging Workshop
.NET Debugging Workshop
Sasha Goldshtein
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
Chris Gates
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Peter Hlavaty
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Node.js essentials
 Node.js essentials Node.js essentials
Node.js essentials
Bedis ElAchèche
 
Mastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionMastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and Production
Sasha Goldshtein
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
Gert Poppe
 
Introduction to .NET Performance Measurement
Introduction to .NET Performance MeasurementIntroduction to .NET Performance Measurement
Introduction to .NET Performance Measurement
Sasha Goldshtein
 
OrientDB - The 2nd generation of (multi-model) NoSQL
OrientDB - The 2nd generation of  (multi-model) NoSQLOrientDB - The 2nd generation of  (multi-model) NoSQL
OrientDB - The 2nd generation of (multi-model) NoSQL
Roberto Franchini
 
Супер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOSСупер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOS
SQALab
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
Dror Helper
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
Aleksandr Tarasov
 
OHHttpStubs
OHHttpStubsOHHttpStubs
OHHttpStubs
CocoaHeads France
 
Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10
Honorary_BoT
 
Se lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
Se lancer dans l'aventure microservices avec Spring Cloud - Julien RoySe lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
Se lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
ekino
 
Testing with PostgreSQL
Testing with PostgreSQLTesting with PostgreSQL
Testing with PostgreSQL
Shawn Sorichetti
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
All Things Open
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
Chris Gates
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Peter Hlavaty
 
Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012Jenkins Evolutions - JEEConf 2012
Jenkins Evolutions - JEEConf 2012
Anton Arhipov
 
Mastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionMastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and Production
Sasha Goldshtein
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
Gert Poppe
 
Introduction to .NET Performance Measurement
Introduction to .NET Performance MeasurementIntroduction to .NET Performance Measurement
Introduction to .NET Performance Measurement
Sasha Goldshtein
 
OrientDB - The 2nd generation of (multi-model) NoSQL
OrientDB - The 2nd generation of  (multi-model) NoSQLOrientDB - The 2nd generation of  (multi-model) NoSQL
OrientDB - The 2nd generation of (multi-model) NoSQL
Roberto Franchini
 
Супер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOSСупер быстрая автоматизация тестирования на iOS
Супер быстрая автоматизация тестирования на iOS
SQALab
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
Dror Helper
 
Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10Bypassing patchguard on Windows 8.1 and Windows 10
Bypassing patchguard on Windows 8.1 and Windows 10
Honorary_BoT
 
Se lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
Se lancer dans l'aventure microservices avec Spring Cloud - Julien RoySe lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
Se lancer dans l'aventure microservices avec Spring Cloud - Julien Roy
ekino
 

Viewers also liked (6)

Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...
Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...
Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...
Nagios
 
Nagios
NagiosNagios
Nagios
Assil Fradi
 
Nagios
NagiosNagios
Nagios
Nick Arancio
 
Nagios Conference 2011 - Jared Bird - Using Nagios As A Security Tool
Nagios Conference 2011 - Jared Bird - Using Nagios As A Security ToolNagios Conference 2011 - Jared Bird - Using Nagios As A Security Tool
Nagios Conference 2011 - Jared Bird - Using Nagios As A Security Tool
Nagios
 
Nagios Conference 2012 - Ethan Galstad - Keynote
Nagios Conference 2012 - Ethan Galstad - KeynoteNagios Conference 2012 - Ethan Galstad - Keynote
Nagios Conference 2012 - Ethan Galstad - Keynote
Nagios
 
Nagios Conference 2011 - Arun Ramanathan - Environment Monitoring With Nagios
Nagios Conference 2011 - Arun Ramanathan - Environment Monitoring With NagiosNagios Conference 2011 - Arun Ramanathan - Environment Monitoring With Nagios
Nagios Conference 2011 - Arun Ramanathan - Environment Monitoring With Nagios
Nagios
 
Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...
Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...
Nagios Conference 2011 - Mike Weber - Training: Monitoring Linux Mail Servers...
Nagios
 
Nagios Conference 2011 - Jared Bird - Using Nagios As A Security Tool
Nagios Conference 2011 - Jared Bird - Using Nagios As A Security ToolNagios Conference 2011 - Jared Bird - Using Nagios As A Security Tool
Nagios Conference 2011 - Jared Bird - Using Nagios As A Security Tool
Nagios
 
Nagios Conference 2012 - Ethan Galstad - Keynote
Nagios Conference 2012 - Ethan Galstad - KeynoteNagios Conference 2012 - Ethan Galstad - Keynote
Nagios Conference 2012 - Ethan Galstad - Keynote
Nagios
 
Nagios Conference 2011 - Arun Ramanathan - Environment Monitoring With Nagios
Nagios Conference 2011 - Arun Ramanathan - Environment Monitoring With NagiosNagios Conference 2011 - Arun Ramanathan - Environment Monitoring With Nagios
Nagios Conference 2011 - Arun Ramanathan - Environment Monitoring With Nagios
Nagios
 

Similar to Nagios Conference 2011 - Michael Medin - Workshop: Scripting On The Windows Side (20)

Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009
rsnarayanan
 
Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...
Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...
Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...
Nagios
 
Scripting and Automation within the MAX Platform - Mark Petrie
Scripting and Automation within the MAX Platform - Mark Petrie Scripting and Automation within the MAX Platform - Mark Petrie
Scripting and Automation within the MAX Platform - Mark Petrie
MAXfocus
 
Power on, Powershell
Power on, PowershellPower on, Powershell
Power on, Powershell
Roo7break
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue Kid
Matthew Johnson
 
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
NETWAYS
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershell
Salaudeen Rajack
 
Cscript exe
Cscript exeCscript exe
Cscript exe
ssuser1eca7d
 
Qtp wsh scripts examples
Qtp wsh scripts examplesQtp wsh scripts examples
Qtp wsh scripts examples
Ramu Palanki
 
CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!
walk2talk srl
 
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Hitesh Mohapatra
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second Language
Rob Dunn
 
Batch file-programming
Batch file-programmingBatch file-programming
Batch file-programming
jamilur
 
Batch file programming
Batch file programmingBatch file programming
Batch file programming
alan moreno
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
CODE BLUE
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
Ilya Haykinson
 
Batch file programming
Batch file programmingBatch file programming
Batch file programming
swapnil kapate
 
Power Shell For Testers
Power Shell For TestersPower Shell For Testers
Power Shell For Testers
Mca140 software solutions
 
Revoke-Obfuscation
Revoke-ObfuscationRevoke-Obfuscation
Revoke-Obfuscation
Daniel Bohannon
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009
rsnarayanan
 
Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...
Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...
Nagios Conference 2012 - Yancy Ribbens - Windows Advanced Monitoring with WMI...
Nagios
 
Scripting and Automation within the MAX Platform - Mark Petrie
Scripting and Automation within the MAX Platform - Mark Petrie Scripting and Automation within the MAX Platform - Mark Petrie
Scripting and Automation within the MAX Platform - Mark Petrie
MAXfocus
 
Power on, Powershell
Power on, PowershellPower on, Powershell
Power on, Powershell
Roo7break
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue Kid
Matthew Johnson
 
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
NETWAYS
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershell
Salaudeen Rajack
 
Qtp wsh scripts examples
Qtp wsh scripts examplesQtp wsh scripts examples
Qtp wsh scripts examples
Ramu Palanki
 
CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!
walk2talk srl
 
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...Basic commands for powershell : Configuring Windows PowerShell and working wi...
Basic commands for powershell : Configuring Windows PowerShell and working wi...
Hitesh Mohapatra
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second Language
Rob Dunn
 
Batch file-programming
Batch file-programmingBatch file-programming
Batch file-programming
jamilur
 
Batch file programming
Batch file programmingBatch file programming
Batch file programming
alan moreno
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
CODE BLUE
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
Ilya Haykinson
 
Batch file programming
Batch file programmingBatch file programming
Batch file programming
swapnil kapate
 

More from Nagios (20)

Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best Practices
Nagios
 
Jesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture OverviewJesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture Overview
Nagios
 
Trevor McDonald - Nagios XI Under The Hood
Trevor McDonald  - Nagios XI Under The HoodTrevor McDonald  - Nagios XI Under The Hood
Trevor McDonald - Nagios XI Under The Hood
Nagios
 
Sean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient NotificationsSean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient Notifications
Nagios
 
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise EditionMarcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Nagios
 
Janice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios PluginsJanice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios Plugins
Nagios
 
Dave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical ExperienceDave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical Experience
Nagios
 
Mike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service ChecksMike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service Checks
Nagios
 
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios InstallationMike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
Nagios
 
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Nagios
 
Matt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With NagiosMatt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With Nagios
Nagios
 
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Nagios
 
Eric Loyd - Fractal Nagios
Eric Loyd - Fractal NagiosEric Loyd - Fractal Nagios
Eric Loyd - Fractal Nagios
Nagios
 
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Nagios
 
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Nagios
 
Nagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson OpeningNagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson Opening
Nagios
 
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nagios
 
Nagios Log Server - Features
Nagios Log Server - FeaturesNagios Log Server - Features
Nagios Log Server - Features
Nagios
 
Nagios Network Analyzer - Features
Nagios Network Analyzer - FeaturesNagios Network Analyzer - Features
Nagios Network Analyzer - Features
Nagios
 
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing NagiosNagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best Practices
Nagios
 
Jesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture OverviewJesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture Overview
Nagios
 
Trevor McDonald - Nagios XI Under The Hood
Trevor McDonald  - Nagios XI Under The HoodTrevor McDonald  - Nagios XI Under The Hood
Trevor McDonald - Nagios XI Under The Hood
Nagios
 
Sean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient NotificationsSean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient Notifications
Nagios
 
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise EditionMarcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Nagios
 
Janice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios PluginsJanice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios Plugins
Nagios
 
Dave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical ExperienceDave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical Experience
Nagios
 
Mike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service ChecksMike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service Checks
Nagios
 
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios InstallationMike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
Nagios
 
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Nagios
 
Matt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With NagiosMatt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With Nagios
Nagios
 
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Nagios
 
Eric Loyd - Fractal Nagios
Eric Loyd - Fractal NagiosEric Loyd - Fractal Nagios
Eric Loyd - Fractal Nagios
Nagios
 
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Nagios
 
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Nagios
 
Nagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson OpeningNagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson Opening
Nagios
 
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nagios
 
Nagios Log Server - Features
Nagios Log Server - FeaturesNagios Log Server - Features
Nagios Log Server - Features
Nagios
 
Nagios Network Analyzer - Features
Nagios Network Analyzer - FeaturesNagios Network Analyzer - Features
Nagios Network Analyzer - Features
Nagios
 
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing NagiosNagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios
 

Recently uploaded (20)

UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
The 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptxThe 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptx
aptyai
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Cyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptxCyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptx
Ghimire B.R.
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Maxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing placeMaxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing place
usersalmanrazdelhi
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
cloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mitacloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mita
siyaldhande02
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Talk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya WeersTalk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya Weers
Kaya Weers
 
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Aaryan Kansari
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
The 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptxThe 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptx
aptyai
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Cyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptxCyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptx
Ghimire B.R.
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Maxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing placeMaxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing place
usersalmanrazdelhi
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
cloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mitacloudgenesis cloud workshop , gdg on campus mita
cloudgenesis cloud workshop , gdg on campus mita
siyaldhande02
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Talk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya WeersTalk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya Weers
Kaya Weers
 
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Aaryan Kansari
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 

Nagios Conference 2011 - Michael Medin - Workshop: Scripting On The Windows Side

  • 2. These slides represent the work and opinions of the author and do not constitute official positions of any organization sponsoring the author’s work This material has not been peer reviewed and is presented here as-is with the permission of the author.The author assumes no liability for any content or opinion expressed in this presentation and or use of content herein.Disclaimer!It is not their fault!It is not my fault!It is your fault!
  • 3. External ScriptsInternal ScriptsArgumentsScripting: Batch filesWrapped scriptsScripting: VBAInternal ScriptsAgenda
  • 4. Windows monitoringNSClient++ (from a scripters perspecitve)
  • 5. External ScriptsThe normal kind of scriptsCan be written in:BatchVBA/VBScript (pretty popular on Windows)Powershell (a rather strange language)But also:Perl, python, bash, etc etc…Internal ScriptsCan interact with (other) internal commandsCan access settingsCan hold stateCan be written in:LuaPython (requires python on the machine)Two kinds of scripts
  • 6. Enable the check module[/modules]CheckExternalScripts= # Runs the scriptNRPEServer= # NRPE serverEach script requires a definition[/settings/External Scripts]check_es_test=scripts\test.batOptions disabled by default (for a reason)allow arguments = falseallow nasty characters = falseConfiguring External Scripts
  • 7. Enable the check module[/modules]LUAScript=PythonScript=Each script requires a definition[/settings/LUA/Scripts]<alias>=test.lua[/settings/python/Scripts]<alias>=test.pyScripts requires NRPE/NSCA (or NSCP)[/modules]NRPEServer=Configuring Internal Scripts
  • 8. Can be configured in many placesIs probably more confusing then it is worthThe server moduleMeans NO commands can have argumentsThe script moduleMeans NO external script can have argumentsAllow arguments
  • 10. Writing our first ScriptsThe first batch script
  • 11. Output:Use: echo <text>Don’t forget @echo off (or all commands will be echoed)Exit statuses:Use: exit <code>0 = OK1 = Warning2 = Critical3 = UnknownNSC.ini syntax:[/settings/External Scripts/scripts]my_script=scripts\script.batReference:http://www.ss64.com/nt/Don’t let preconceptions fool you: batch can actually do a lot!Writing a Script (Batch)
  • 12. @echo offecho CRITICAL: Everything is not going to be fineexit 2A basic script (batch)
  • 13. …\NSClient++\scripts>cmd /ctest.batCRITICAL: Everything is not going to be fine…\NSClient++\scripts>echo %ERRORLEVEL%2Running from Command Line
  • 14. D:\demo>nscp --testNSClient++ 0,4,0,98 2011-09-06 x64 booting...Boot.ini found in: D:/demo//boot.iniBoot order: ini://${shared-path}/nsclient.ini, old://${exe-path}/nsc.iniActivating: ini://${shared-path}/nsclient.iniCreating instance for: ini://${shared-path}:80/nsclient.iniReading INI settings from: D:/demo//nsclient.iniLoading: D:/demo//nsclient.ini from ini://${shared-path}/nsclient.iniBooted settings subsystem...On crash: restart: NSClientppArchiving crash dumps in: D:/demo//crash-dumpsbooting::loading pluginsFound: CheckExternalScripts asProcessing plugin: CheckExternalScripts.dll asaddPlugin(D:/demo//modules/CheckExternalScripts.dll as )Loading plugin: Check External Scripts asNSClient++ - 0,4,0,98 2011-09-06 Started!Enter command to inject or exit to terminate...Running from NSClient
  • 15. Enter command to inject or exit to terminate...my_scriptsInjecting: my_script...Arguments:Result my_script: WARNINGWARNING:Hello WorldRunning from NSClientCommandReturn StatusReturn Message
  • 17. Writing our first ScriptsKilling notepad once and or all!
  • 18. TASKKILL [/S dator [/U användarnamn [/P lösenord]]]] { [/FI filter] [/PID process-ID | /IM avbildning] } [/T][/F]Beskrivning: Det här verktyget används för att avsluta en eller flera aktiviteter utifrån process-ID (PID) eller avbildningsnamn.Parameterlista:… /FI filter Använder ett filter för att välja aktiviteter. Jokertecknet * kan användas, t.ex:imagenameeq note* /PID process-ID Anger process-ID för den process som ska avbrytas. Använd kommandot Tasklist för att hämta process-ID /IM avbildning Anger avbildning för den process som för den process som ska avslutas. Jokertecknet * användas för att ange alla aktiviteter eller avbildningar.Killing notepad once and for all!
  • 19. @echo offtaskkill /im notepad.exe 1>NUL 2>NULIF ERRORLEVEL 128 GOTO errIF ERRORLEVEL 0 GOTO okGOTO unknown:unknownecho UNKNOWN: unknown problem killing notepad...exit /B 3:errecho CRITICAL: Notepad was not killed...exit /B 1:okecho OK: Notepad was killed!exit /B 0KILL!!!
  • 22. NSC.ini syntax:[External Scripts]check_bat=scripts\check_test.batOr[Wrapped Scripts]check_test=check_test.batAdding a Script (.bat)
  • 23. NSC.ini syntax:[External Scripts]check_test=cscript.exe /T:30 /NoLogo scripts\check_test.vbsOr[Wrapped Scripts]check_test=check_test.vbsAdding a Script (.VBS)
  • 24. NSC.ini syntax:[External Scripts]check_test=cscript.exe /T:30 /NoLogo scripts\lib\wrapper.vbs scripts\check_test.vbsOr[Wrapped Scripts]check_test=check_test.vbsAdding a Script (.VBS) w/ libs
  • 25. NSC.ini syntax:[External Scripts]check_test=cmd /c echo scripts\check_test.ps1; exit($lastexitcode) | powershell.exe -command -Or[Wrapped Scripts]check_test=check_test.ps1Adding a Script (.PS1)
  • 26. […/wrappings]bat=scripts\%SCRIPT% %ARGS%vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -[…/wrapped scripts]check_test_vbs=check_test.vbs /arg1:1 /variable:1check_test_ps1=check_test.ps1 arg1 arg2check_test_bat=check_test.bat $ARG1$ arg2check_battery=check_battery.vbscheck_printer=check_printer.vbs; So essentially it is a macro! (but a nice one)What is wrapped scripts?
  • 27. Writing your first ScriptsWriting a simple VB script
  • 28. Output:Use: Wscript.StdOut.WriteLine <text>Exit statuses:Use: Wscript.Quit(<code>)0 = OK1 = Warning2 = Critical3 = UnknownNSC.ini syntax:[External Scripts]check_vbs=cscript.exe //T:30 //NoLogo scripts\check_vbs.vbs //T:30 Is the timeout and might need to be changed.Reference:http://msdn.microsoft.com/en-us/library/t0aew7h6(VS.85).aspxWriting a Script (VBS)
  • 30. Set <variable name>=CreateObject(“<COM Object>")There is A LOT of objects you can createA nice way to interact with other applicationsFor instance:Set objWord = CreateObject("Word.Application")objWord.Visible = TrueSet objDoc = objWord.Documents.Add()Set objSelection = objWord.SelectionobjSelection.Font.Name = “Comic Sans MS"objSelection.Font.Size = “28"objSelection.TypeText“Hello World"objSelection.TypeParagraph()objSelection.Font.Size = "14"objSelection.TypeText "" & Date()objSelection.TypeParagraph()Object oriented programming (ish)
  • 32. strFile=”c:\windows”Dim oFSOSet oFSO=CreateObject("Scripting.FileSystemObject")If oFSO.FileExists(strFile) Thenwscript.echo”Yaay!"wscript.quit(0)elsewscript.echo“Whhh… what the f***!"wscript.quit(2)end ifAre we running windows?
  • 35. Can be used to extend NSClient++Are very powerfulA good way to:Alter things you do not likeCreate advanced thingsAre written in Lua or PythonPossibly unsafeRuns inside NSClient++Internal Scripts
  • 36. Internal scripts are fundamentally differentOne script is NOT equals to one functionA script (at startup) can:Register query (commands) handlersRegister submission (passive checks) handlersRegister exec handlersRegister configurationAccess configurationHandlers can:Execute queries (commands)Submit submissions (passive checks)Etc etc…Anatomy of an internal script
  • 37. definit(plugin_id, plugin_alias, script_alias):conf = Settings.get()reg = Registry.get(plugin_id)reg.simple_cmdline('help', get_help)reg.simple_function(‘command', cmd, ‘A command…')conf.set_int('hello', 'python', 42) log(Answer: %d'%conf.get_int('hello','python',-1))def shutdown(): log(“Shutting down…”)A basic script
  • 38. defget_help(arguments): return (status.OK, ‘Im not helpful ')def test(arguments): core = Core.get()count = len(arguments)(retcode, retmessage, retperf) =core.simple_query(‘CHECK_NSCP’, [])return (status.OK, ‘Life is good… %d'%count)A basic script
  • 40. Michael Medinmichael@medin.namehttp://www.linkedin.com/in/mickemInformation about NSClient++http://nsclient.orgFacebook: facebook.com/nsclientSlides, and exampleshttp://nsclient.org/nscp/conferances/2011/nwcna/Thank You!

Editor's Notes

  • #2: Hello my name is Michael Medin.I am from Stockholm, Sweden.I will give this in English just because I think everyone else does...If there are any questions or such just chime in.Feel free to ask questions in Swedish if you wish.
  • #3: Standard Disclaimer - My views (not anyone else&apos;s) - Not peer reviewed so I could be lying to you. - If you 2 billion dollar servers crash: life sucksLets simplify this a bit…
  • #14: cmd /c is because we need to capture the “exit code” normally exit will exit all running shellsWe get the message but no error codeUse echo %ERRORLEVEL% to display the exit code
  • #15: We run the scriptGet the error code (Critical) and the Message (...)But we get no performance data
  • #16: We run the scriptGet the error code (Critical) and the Message (...)But we get no performance data
  • #17: 2 minutes
  • #18: 2 minutes
  • #21: 2 minutes