Kaseya Network Monitor includes support for the Lua scripting language. Lua is a powerful light-weight programming language designed for extending applications. With Lua customers can create custom made monitors to test systems and equipment not supported by any built-in monitor.
- New monitors, actions and events can be created and tested in the development environment provided by Kaseya, before they are exported and used in Kaseya Network Monitor.
- A comprehensive library of pre-made classes, such as SFTP client, HTTP client and file management, are available to developers.
- The develop environment includes debugger, keyword highlighting, integrated help and other features available in state-of-the-art development tools.
In the default KNM installer there are a number of bundled scripts. The scripts are located in the “script” directory in the KNM folder. The included scripts is a great place to start if you want learn to develop your own script.
Monitors work threads in a Apache web server
BackupExec_.lua / BackupExec_11D_.lua
Monitors the completion status of backup jobs.
Checks if a HTTP certificate is about to expiry, the period can be set in days.
Monitors the bandwidth usage of all IPSec tunnels open on a firewall.
Monitors the bandwidth of a specific (named) IPSec tunnel.
Monitors health status parameters of an HP iLo2 watchdog computer.
Checks if a Windows attached printer is out of paper.
Monitors VMWare ESXi hardware parameters (Fan, raidarray and PSU health status)
Steps to start developing scripts
First you need to download the Lua IDE. Its shipped with KNM and all you need to do is to logon to the KNM web interface and go to the “About page”.
Click on the Lua IDE link and download the installer. Start the installer and follow the instructions on screen. When the installer is done, located the Lua IDE in the start menu and start it.
Scripts written must adhere to the programing model of KNM, to get started quickly and avoid writing boilerplate code, you can use a script template. In the menu “Insert code” , click the “insert template script” menu item.
Before we can run the debugger and test this boilerplate code, we need to add a new host. KNM Lua script is always run in the context of a host. API calls are always relative to a host, meaning that its not possible to perform actions against different machines in the same insttance of a script. Therefore before starting a debugging session we always need to select a host.
Click the “Open host list” in the tool bar and add a host by entering it the text field below the list and click “Add host”. When added, select it in the list and click the “select host” button.
To test the template scripts just inserted into the empty document, click on the cogwheel in the tool bar or hit CTRL+F5 to start a new debugging session.
The script will be executed by the IDE the exact same way KNM will execute it, the interface will be emulated using standard windows controls.
To learn more about using the IDE and the Lua API, open the link below.
How to deploy and use a script
When you are happy with your script its time to deploy it to KNM.
- Located the script on your computer
- Copy the script to the “script” directory in the KNM folder
When deployed to KNM it can be used in the Lua script monitor.
- Select a object and open up its object info page
- Click New monitor
- Select Lua script in the script category
- Select the script from the drop down list in the “Lua script monitor properties” section.
- Configure the script parameters
Note that when selecting a script, it permanently removes the option to select another script, if you need to use a different script, create a new monitor for that script.
Hope this mini-tutorial have been helpful, the Lua API opens up a lot of possibilities to monitor company specific processes and systems.
Please let us know if you´ve written a script that you want to share !