I have a slackbot that posts snmp messages sent from network devices.
Example:
rtr-canada-1: BGP Peer 1.1.1.1 - Description: Test route - State: Idle
rtr-us-1: BGP Peer 1.1.1.2 - Description: Very Long name Industries - State: Established.
What's the best way of formatting every message so that the "Description:" and "State:" markers always end up at the same position in the string, therefore making everything uniform?
Example:
rtr-canada-1: BGP Peer 1.1.1.1 - Description: Test route - State: Idle
rtr-us-1: BGP Peer 1.1.1.2 - Description: Very Long name Industries - State: Established.
I'm thinking of making a function that measures the length of the string before posting it and then fills the message with whitespace until everything is pushed in place but I wonder if there isn't a smarter way of doing this.
Thanks,