How to add monitor without using the IPHost interface?
Q:Is there a way of adding ping monitors without using IPHost client? E.g., using some kind of script?
A: Yes. You can do something like the following (save SQL script below as create.sql):
CONNECT '127.0.0.1/3055:C:\ProgramData\IPHost Network Monitor\data\nms.fdb' user 'SYSDBA' password 'masterkey'; SET HEADING; set term ^ ; EXECUTE BLOCK RETURNS (newMonitorID INTEGER) AS DECLARE VARIABLE newHostID INTEGER; -- DECLARE VARIABLE newMonitorID INTEGER; DECLARE VARIABLE currentTime TIMESTAMP; BEGIN -- Get the current data/time SELECT 'NOW' FROM RDB$DATABASE INTO :currentTime; -- Generate ID for new host SELECT NEXT VALUE FOR HOSTS_ID_G0 FROM RDB$DATABASE INTO :newHostID; -- Generate ID for new monitor SELECT NEXT VALUE FOR MONITORS_ID_G0 FROM RDB$DATABASE INTO :newMonitorID; -- Add new host INSERT INTO HOSTS ( ID, HOST_TYPE_ID, -- reference to the HOST_TYPES table (groups of hosts) DISPLAY_NAME, NOTES, HOSTNAME, IP, A_PROFILE_KIND, A_PROFILE_GLOBAL_ID, CREATED, WEBINTERFACE_URL ) VALUES ( :newHostID, 0, -- put new host to the "Servers" group 'Google', 'Created by script, ' || :currentTime, 'google.com', '74.125.39.104', 0, -- use one of the global Alerting rules 1, -- 'Default Alerting Rule' in particular :currentTime, 'http://google.com:80' ); -- Add new PING monitor for the added host INSERT INTO MONITORS ( ID, HOST_ID, MONITOR_TYPE_ID, -- reference to the MONITOR_TYPES table DISPLAY_NAME, NOTES, INTERVAL, ACTIVITY, STATE, STATE_ACK, T_INHERITED, P_INHERITED, A_PROFILE_KIND, A_PROFILE_GLOBAL_ID, CREATED, RES_LOG_START ) VALUES ( :newMonitorID, :newHostID, 1, -- this monitor is a PING monitor 'PING google web site', 'Created by script, ' || :currentTime, 30, -- polling interval 30 seconds 0, -- create started -1, -- create in UNKNOWN state 'n', 'y', -- inherit the 'Availability Monitoring' settings 'y', -- inherit the 'Performance Monitoring' settings 2, -- inherit alerting rule from monitor type 1, -- the 'Default Alerting Rule' is used in particular :currentTime, :currentTime ); -- Add properties of the monitor created. -- PING monitor has only one property: 'Packet Size, bytes' INSERT INTO M_SETTINGS_FOR_MONITORS ( M_SETTING_TYPE_ID, MONITOR_ID, V_INT, V_STRING, V_BIGSTR ) VALUES ( 1, -- id of the 'Packet Size, bytes' property :newMonitorID, 32, -- use the 32 bytes packets NULL, -- is not used obsolete NULL -- is not used since this property is integer, use this field for -- string properties ); RDB$SET_CONTEXT('USER_SESSION', 'monitorID', :newMonitorID); RDB$SET_CONTEXT('USER_SESSION', 'hostID', :newHostID); END ^ set term ; ^ SELECT RDB$GET_CONTEXT('USER_SESSION', 'monitorID') FROM RDB$DATABASE; SELECT RDB$GET_CONTEXT('USER_SESSION', 'hostID') FROM RDB$DATABASE;
and run this script:
"C:\Program Files\IPHost Network Monitor\firebird\bin\isql.exe" -q -i create.sql
(replace path to IPHost Network Monitor installation folder if necessary)
The script writes directly into the IPHost’s database and creates a new host for the google.com and adds a PING monitor. You need to restart both the IPHost service and client to let them detect the new monitor/host.