Default Script and Program Monitors
IPHost Network Monitor allows you to run external scripts and programs that calculate performance numbers and report them back to the monitoring service. You can create your own monitors of this type to perform specific tasks; you can also contact us at email@example.com if you would like us to write such monitors for you as a separate project. However, several such monitors are shipped with IPHost Network Monitor by default and you can utilize them as explained below.
Usage: directory_size_kb.exe directory_name [-t timeout in sec] [-l DOMAIN:user:password]
Program Mode: Run program
This monitor calculates the total size of all files in a directory in kilobytes. This is done by recursively scanning the directory, so the operation is time consuming and it is not recommended to run it more frequently than every 20 minutes or so; it is also not recommended to calculate the size of directories with lots of files, especially on remote hosts.
You should pass the UNC or local directory name as the first parameter to this program. By default, a timeout of 10 seconds is implied for the whole operation which you can override using the -t command line switch. The last switch, -l, is used to pass credentials of a user who can read the directory contents. Since the monitoring service runs under a Local System account, it cannot access remote shared directories by default and should pass valid user credentials to access a share.
A typical Program Parameters string for this program can look like:
\\URAN\public -l $AdminDomain:$AdminName:$AdminPassword
You can view this plugin source code in scripts\iphost_dirsize_kb.cpp and build it using scripts\iphost_dirsize_kb.bat.
Usage: iphost_file_content.vbs <file> <mode> <string> [credentials]
Program Mode: Run script
This monitor reads the file named as the first script argument and searches for a particular string in the file. It has two execution modes:
- Mode ‘C’ (count): the script counts the total number of string occurrences in the file
- Mode ‘F’ (find): the script searches for the first string occurrence in the file and returns the first number it finds after this string.
The credentials string, if present, has the same format as for the directory size monitor: domain, user name, and password separated by a colon. Since the monitoring service runs under a Local System account, it cannot access remote shared files by default and should pass valid user credentials to access a share.
For example, you can use this script to parse the log file contents. The script can return the total number of particular messages, or q particular numeric value (that can be an error code). The following arguments instruct the script to return the total number of IPHost Network Monitor’s Web interface shutdowns:
“C:\ProgramData\IPHost Network Monitor\logs\error.log” C shutdown
Usage: iphost_http_content.vbs <URL> <mode> <string>
Program Type: Run script
Program Mode: Standard
This monitor makes an HTTP(S) request to the particular URL passed as the first argument and searches its contents for a particular string. It has two execution modes:
- Mode ‘C’ (count): the script counts the total number of string occurrences in the HTTP response.
- Mode ‘F’ (find): the script searches for the first string occurrence in the HTTP response and returns the first number it finds after this string.
You can find many uses for this script. One funny example is weather monitoring. The following arguments instruct the script to return the current weather in London:
“http://weather.yahooapis.com/forecastrss?p=UKXX0085&u=c” F temp=
To determine a similar URL for your location, enter your city name at weather.yahoo.com, find and click the RSS subscription link, and look at the resulting URL in the browser navigation bar. Please don’t schedule such HTTP requests too frequently; a polling interval of 1 hour should be enough in most cases.