David Backeberg
2010-Oct-15 15:22 UTC
[asterisk-users] how to insert dynamic hostname into shared CDR database
So I'm in a situation where I want to consolidate cdr logs. My general idea is to use cdr_mysql for this. I know I can do things like Set(CDR(userfield)=hostname) And I can hardcode the hostname for the dialplan on each system. But what I'd really like to do is have this dynamic, so I can use the same exact dialplan on multiple hosts, and have hostname dynamically generate. I went looking for a built-in asterisk variable for this, but haven't found anything yet. I know I can do something like Set(HOSTNAME=(System(/bin/hostname -s)) Set(CDR(userfield)=${HOSTNAME}) But that seems like more overhead than it should take to do this. Can anybody think of a better way? Hey, I just discovered ${SYSTEMNAME} * value of the systemname option of asterisk.conf which was turned off in my asterisk.conf, but then there's an option called autosystemname = yes With that enabled, ${SYSTEMNAME} is giving me what I want. I also spotted ${ENV(HOSTNAME)} which I assume would let me have whatever is set as an environmental variable. This didn't work for me, perhaps because my asterisk daemon is running in an environment without that variable set?