Forum Discussion
The problem about iCall's tmsh script.
The iCall script as a configuration object, could have been created by an iApp Application-service. In that case, the app-service field would reflect the service that did so.
The description is a Text field for the user to document the purpose of the iCall script, or anything else.
The iCall script "definition" section can generate Events, in that case it will publish the Event details in the "events" section, here is an example:
sys icall script get_sharepoint_score_new_and_improved {
app-service none
definition {
package require http
if {[catch {tmsh::generate sys icall event SharePoint_SCORE context \{ \{ name node_addr value $nodeaddr \} \{ name score value $spscore \} \}} err]} {
puts "generate iCall event FAIL $url"
http::cleanup $token
} else {
http::cleanup $token
}
}
}
}
description none
events {
SharePoint_SCORE {
app-service none
contexts {
node_addr {
app-service none
}
score {
app-service none
}
}
}
}
}
The only required section for an iCall script is the definition section. The events, app-service and description can be left as "none".
Here is an example of a script which sends an email upon a failover Event. Note the FAILOVER event is system defined and it does not require special definition.
sys icall script email-on-failover {
definition {
set old_status standby
while { 1 } {
EVENT::get_next
set new_status $EVENT::context(/Common/traffic-group-1)
detect if we just went standby
if { $new_status eq "standby" && $old_status ne "standby" } {
puts "failover detected - i am standby now!"
set date [clock format [clock seconds] -format "%Y%m%d%H%M%S"]
set settings [tmsh::get_config sys global-settings]
set host [tmsh::get_field_value [lindex $settings 0] hostname]
puts "generating email for $host-$date"
set args "echo \"Failover notification\" | mail -s \"$host is now Standby. $date\" network_operations@company.com“
if { [catch { exec /bin/bash -c $args }] } {
puts "\nCould not send email, try again."
}
}
save the state
set old_status $new_status
}
}
description none
events none
}
And the following perpetual handler to run it upon a Failover Event:
sys icall handler perpetual handle-failover {
script email-on-failover
subscriptions {
failover {
event-name FAILOVER_STATE
}
}
}
You also need to prepare the bash mail client.
HTH
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com