This example script sets the system contact for the selected Cisco device. It relies on the task that is calling the script having a systemContact parameter set to the contact name.
In Entuity, system contact is an inventory attribute held against the device chassis. Inventory attributes are polled every 24 hours - this reflects their relatively unchanging nature when compared to performance and availability attributes. It may therefore be up to 24 hours before a change in the system contact is reflected in Entuity.
1. expect.with
2. {
3. if( vendor.equals("9") )
4. {
5. println "Setting Cisco sysContact to " + param.systemContact
6. sendln "configure terminal"
7. expect( configPrompt, {} )
8. sendln "snmp-server contact " + param.systemContact
9. expect( configPrompt, {} )
10. }
11. else
12. {
13. println "NO VALID METHOD FOR THIS DEVICE"
14. throw new Exception("no valid method for this device")
15. }
16. }
Overview of the set system contact script structure:
- Line 3. finds the seventh character of the sysOID to identify the device vendor.
- Line 5. prints the name of the system contact, held in the task’s systemContact parameter.
- Line 6. sets the terminal to configure.
- Line 7. checks the prompt is the expected terminal prompt. configPrompt is defined in the login script. If the prompt is not as expected the job would eventually return a timeout error.
- Line 8. sets the snmp-server contact to the value of the task’s systemContact parameter.
- Line 11. to Line 15. return an error message when the device is not a Cisco device.
Comments
0 comments
Please sign in to leave a comment.