2020-12-14 01:39:09 +00:00
'use strict' ;
'require view' ;
'require form' ;
'require tools.widgets as widgets' ;
return view . extend ( {
render : function ( ) {
var m , s , o ;
m = new form . Map ( 'watchcat' ,
_ ( 'Watchcat' ) ,
_ ( " Here you can set up several checks and actions to take in the event that a host becomes unreachable . \
Click the < b > Add < / b > b u t t o n a t t h e b o t t o m t o s e t u p m o r e t h a n o n e a c t i o n . " ) ) ;
s = m . section ( form . TypedSection , 'watchcat' , _ ( 'Watchcat' ) , _ ( 'These rules will govern how this device reacts to network events.' ) ) ;
s . anonymous = true ;
s . addremove = true ;
s . tab ( 'general' , _ ( 'General Settings' ) ) ;
o = s . taboption ( 'general' , form . ListValue , 'mode' ,
_ ( 'Mode' ) ,
2021-03-22 07:16:13 +00:00
_ ( " Ping Reboot : Reboot this device if a ping to a specified host fails for a specified duration of time . < br / > \
Periodic Reboot : Reboot this device after a specified interval of time . < br / > \
2022-06-05 01:16:27 +00:00
Restart Interface : Restart a network interface if a ping to a specified host fails for a specified duration of time . < br / > \
Run Script : Run a script if a ping to a specified host fails for a specified duration of time . < br / > " ) ) ;
2020-12-14 01:39:09 +00:00
o . value ( 'ping_reboot' , _ ( 'Ping Reboot' ) ) ;
o . value ( 'periodic_reboot' , _ ( 'Periodic Reboot' ) ) ;
o . value ( 'restart_iface' , _ ( 'Restart Interface' ) ) ;
2022-06-05 01:16:27 +00:00
o . value ( 'run_script' , _ ( 'Run Script' ) ) ;
o = s . taboption ( 'general' , form . Value , 'script' ,
_ ( 'Script to run' ) ,
_ ( ` Script to run when the host has not responded for the specified duration of time. The script is passed the interface name as $ 1 ` ) ) ;
o . datatype = 'file' ;
o . default = "/etc/watchcat.user.sh" ;
o . depends ( { mode : "run_script" } ) ;
2020-12-14 01:39:09 +00:00
o = s . taboption ( 'general' , form . Value , 'period' ,
_ ( 'Period' ) ,
2021-03-22 07:16:13 +00:00
_ ( " In Periodic Reboot mode , it defines how often to reboot . < br / > \
2020-12-14 01:39:09 +00:00
In Ping Reboot mode , it defines the longest period of \
2021-03-22 07:16:13 +00:00
time without a reply from the Host To Check before a reboot is engaged . < br / > \
2022-06-05 01:16:27 +00:00
In Network Restart or Run Script mode , it defines the longest period of \
time without a reply from the Host to Check before the interface is restarted or the script is run . \
2021-03-22 07:16:13 +00:00
< br / > < br / > The default unit is seconds , without a suffix , but you can use the \
2020-12-14 01:39:09 +00:00
suffix < b > m < / b > f o r m i n u t e s , < b > h < / b > f o r h o u r s o r < b > d < / b > \
2021-03-22 07:16:13 +00:00
for days . < br / > < br / > Examples : < ul > < li > 10 seconds would be : < b > 10 < / b > o r < b > 1 0 s < / b > < / l i > < l i > 5 m i n u t e s w o u l d b e : < b > 5 m < / b > < / l i > < l i > \
2020-12-14 01:39:09 +00:00
1 hour would be : < b > 1 h < / b > < / l i > < l i > 1 w e e k w o u l d b e : < b > 7 d < / b > < / l i > < u l > " ) ) ;
o . default = '6h' ;
2022-06-05 01:13:56 +00:00
o = s . taboption ( 'general' , form . Value , 'pinghosts' , _ ( 'Host To Check' ) , _ ( ` IP address or hostname to ping. ` ) ) ;
o . datatype = 'host' ;
2020-12-14 01:39:09 +00:00
o . default = '8.8.8.8' ;
o . depends ( { mode : "ping_reboot" } ) ;
o . depends ( { mode : "restart_iface" } ) ;
2022-06-05 01:16:27 +00:00
o . depends ( { mode : "run_script" } ) ;
2020-12-14 01:39:09 +00:00
2022-06-05 01:13:56 +00:00
o = s . taboption ( 'general' , form . ListValue , 'addressfamily' ,
_ ( 'Address family for pinging the host' ) ) ;
o . default = 'any' ;
o . depends ( { mode : 'ping_reboot' } ) ;
o . depends ( { mode : 'restart_iface' } ) ;
2022-06-05 01:16:27 +00:00
o . depends ( { mode : "run_script" } ) ;
2022-06-05 01:13:56 +00:00
o . value ( 'any' ) ;
o . value ( 'ipv4' ) ;
o . value ( 'ipv6' ) ;
2020-12-14 01:39:09 +00:00
o = s . taboption ( 'general' , form . Value , 'pingperiod' ,
_ ( 'Check Interval' ) ,
_ ( " How often to ping the host specified above . \
2021-03-22 07:16:13 +00:00
< br / > < br / > The default unit is seconds , without a suffix , but you can use the suffix < b > m < / b > f o r m i n u t e s , < b > h < / b > f o r h o u r s o r < b > d < / b > f o r d a y s . < b r / > < b r / > \
2020-12-14 01:39:09 +00:00
Examples : < ul > < li > 10 seconds would be : < b > 10 < / b > o r < b > 1 0 s < / b > < / l i > < l i > 5 m i n u t e s w o u l d b e : < b > 5 m < / b > < / l i > < l i > 1 h o u r w o u l d b e : < b > 1 h < / b > < / l i > < l i > 1 w e e k w o u l d b e : < b > 7 d < / b > < / l i > < u l > " ) ) ;
o . default = '30s' ;
o . depends ( { mode : "ping_reboot" } ) ;
o . depends ( { mode : "restart_iface" } ) ;
2022-06-05 01:16:27 +00:00
o . depends ( { mode : "run_script" } ) ;
2020-12-14 01:39:09 +00:00
o = s . taboption ( 'general' , form . ListValue , 'pingsize' ,
_ ( 'Ping Packet Size' ) ) ;
o . value ( 'small' , _ ( 'Small: 1 byte' ) ) ;
o . value ( 'windows' , _ ( 'Windows: 32 bytes' ) ) ;
o . value ( 'standard' , _ ( 'Standard: 56 bytes' ) ) ;
o . value ( 'big' , _ ( 'Big: 248 bytes' ) ) ;
o . value ( 'huge' , _ ( 'Huge: 1492 bytes' ) ) ;
o . value ( 'jumbo' , _ ( 'Jumbo: 9000 bytes' ) ) ;
o . default = 'standard' ;
o . depends ( { mode : 'ping_reboot' } ) ;
o . depends ( { mode : 'restart_iface' } ) ;
2022-06-05 01:16:27 +00:00
o . depends ( { mode : "run_script" } ) ;
2020-12-14 01:39:09 +00:00
o = s . taboption ( 'general' , form . Value , 'forcedelay' ,
_ ( 'Force Reboot Delay' ) ,
2021-03-22 07:16:13 +00:00
_ ( " Applies to Ping Reboot and Periodic Reboot modes < /i> <br / > When rebooting the router , the service will trigger a soft reboot . \
2020-12-14 01:39:09 +00:00
Entering a non - zero value here will trigger a delayed hard reboot if the soft reboot were to fail . \
Enter the number of seconds to wait for the soft reboot to fail or use 0 to disable the forced reboot delay . " ) ) ;
o . default = '1m' ;
o . depends ( { mode : 'ping_reboot' } ) ;
o . depends ( { mode : 'periodic_reboot' } ) ;
2021-03-22 07:21:24 +00:00
o = s . taboption ( 'general' , widgets . DeviceSelect , 'interface' ,
2020-12-14 01:39:09 +00:00
_ ( 'Interface' ) ,
_ ( 'Interface to monitor and/or restart' ) ,
2022-06-05 01:16:27 +00:00
_ ( '<i>Applies to Ping Reboot, Restart Interface, and Run Script modes</i> <br /> Specify the interface to monitor and react if a ping over it fails.' ) ) ;
2020-12-14 01:39:09 +00:00
o . depends ( { mode : 'ping_reboot' } ) ;
o . depends ( { mode : 'restart_iface' } ) ;
2022-06-05 01:16:27 +00:00
o . depends ( { mode : 'run_script' } ) ;
2020-12-14 01:39:09 +00:00
o = s . taboption ( 'general' , widgets . NetworkSelect , 'mmifacename' ,
_ ( 'Name of ModemManager Interface' ) ,
2021-03-22 07:16:13 +00:00
_ ( " Applies to Ping Reboot and Restart Interface modes < /i> <br / > If using ModemManager , \
2020-12-14 01:39:09 +00:00
you can have Watchcat restart your ModemManger interface by specifying its name . " ) ) ;
o . depends ( { mode : 'restart_iface' } ) ;
o . optional = true ;
o = s . taboption ( 'general' , form . Flag , 'unlockbands' ,
_ ( 'Unlock Modem Bands' ) ,
_ ( 'If using ModemManager, then before restarting the interface, set the modem to be allowed to use any band.' ) ) ;
o . default = '0' ;
o . depends ( { mode : 'restart_iface' } ) ;
return m . render ( ) ;
}
} ) ;