Is there a dynamic status macro based on the content of it?

Hi,

I'm looking for a way to display the status macro or similar, with color coding, based on its content.

The content is pulled from an external source via the magnificent SQL Plugin, and I'd like to color code the result based on it (not entire rows, just single cells, based on singular string values).

Thoughts on how this might be achieved?

1 answer

1 accepted

This widget could not be displayed.

In your SQL statement, you can make a field to have text something like:

{status:title=Good|color=green}

Use an SQL case statement or similar to condition the specific value of the status value based on what is in your data. Make sure you specify output=wiki in your sql macro.

Just to follow up, example with MySQL for those who wonder:

SELECT DISTINCT 
`icinga_hosts`.`display_name`,  
`icinga_hosts`.`alias`,  
`icinga_hosts`.`address`,  
`icinga_hoststatus`.`status_update_time`,  
CASE `icinga_hoststatus`.`current_state`   
 WHEN '0' THEN '{status:title=UP|color=green}'  
 WHEN '1' THEN '{status:title=DOWN|color=red}'  
 WHEN '2' THEN '{status:title=UNREACHABLE|color=red}}' 
END as hoststatus
FROM `icinga_hosts`,`icinga_hostgroups`,`icinga_hostgroup_members`,`icinga_hoststatus`,`icinga_objects`  
WHERE (`icinga_hosts`.`host_object_id`=`icinga_hostgroup_members`.`host_object_id`)
AND (`icinga_hostgroups`.`hostgroup_id`=`icinga_hostgroup_members`.`hostgroup_id`)
AND (`icinga_objects`.`object_id`=`icinga_hostgroups`.`hostgroup_object_id`)
AND (`icinga_hosts`.`host_object_id`=`icinga_hoststatus`.`host_object_id`)
AND (`icinga_objects`.`objecttype_id`='3')
AND (`icinga_objects`.`name1` like '<hostgroup>') 

Thanks for your quick reply!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 30, 2018 in Confluence

How Manon Soubies-Camy uses Confluence + Trello to organize webinar notes and her knitting stash

@Manon Soubies-Camy is an engineer who has been an avid Atlassian user since 2014. She helps companies of all sizes transform the way they work with the Atlassian stack, including Jira and Confl...

847 views 8 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you