Automated Links¶
hostinfo can display links to other sources of data such as backup reports, host diagrams, monitoring and measuring systems. These are not generated no the fly but instead are generated overnight by a script called link_generator.py and added to the hostinfo database for rapid retrieval when required.
link_generator.py¶
The link_generator.py script is run by cron on a nightly basis. It gets a list of all hosts currently in hostinfo and runs all the link generator scripts in the /opt/hostinfo/links.d directory against them and stores the results in the hostinfo database. All links for a host are deleted before the link generator scripts are run.
If you want to generate links for a single host you can run the link_generator script with the names of the hosts you want to create links for; otherwise, with no hosts specified, it will generate links for all hosts.
Link process¶
Links are generated by various scripts in the /opt/hostinfo/links.d directory. Anything that is executable in this directory will be tried by the link_generator script to see if it will return a valid link.
In this way people can add new links to the hostinfo system without any requirement to change the hostinfo code itself.
To achieve this flexibility every link generating script needs to be run for every host - this is very, very slow (many seconds per host), so this becomes impractical to do it on demand. Instead the links are generated before hand and stored in the database for quick retrieval.
Link Generation Scripts¶
The scripts in the {{Path|links.d}} directory are required to obey the following design steps:
The script can be written in any language
The script is going to be run once per host.
Scripts must be executable
They will be passed one argument, the name of the host in question
If a link is generated the script should return 0, otherwise return non-zero
The output of the script should only be:
- The URL of the link
- The name or tag of the link
- Tags should be unique per script; otherwise they will overwrite each other
The URL cannot have any spaces in it; a space is used to separate the URL and the tag on the output