A discussion on pulling device scores through automation in ControlUp’s API took place. An employee suggested a script for doing so at the given URL, as an alternative to using employee scores. The user testing this found a limitation in the number of devices returned, which was addressed by a team member. The method is trapped before it can be lost. Score!
Read the entire ‘How to Retrieve Device Scores Through ControlUp’s API’ thread below:
I’m looking at running some automation to pull out device score of devices so I can run some specific reporting that would work with some other internal processes inside a workflow. I can’t seem to do this via the List all devices API, has anyone built anything that can do this?
Device score isn’t stored (as far as I’m aware). The DEX (employee score) is.
Generally speaking the employee score is more useful since it is more geared towards people than the underlying hardware.
As in, do you care that your machines CPU is high if you’re not actively using the device? Maybe in some edge cases. But generally you don’t.
Having said that, if you’re trying to retrieve the device score via API, we can do that.
I just wanted to make sure we’re talking about the correct score
Yeah for me I want to measure device score rather than employee score as such as I want to measure device health and hopefully correlate that to end of life devices etc.
URL: https://api.controlup.com/edge/api/dal/_devices
Body:
“`{
"data_query": {
"track_scores": true,
"size": 10,
"from": 0,
"sort": [
{
"gpu_usage": "desc"
}
],
"query": {
"script_score": {
"query": {
"bool": {
"should": [],
"must": [
{
"term": {
"platform": {
"value": "1"
}
}
},
{
"range": {
"last_communication": {
"gt": 1762186057861
}
}
}
],
"must_not": []
}
},
"script": {
"source": "double score_divisor=1;double score=0;if(doc.containsKey(‘cpu_total_percentage’)&&doc[‘cpu_total_percentage’].size()!=0){score+=(doc[‘cpu_total_percentage’].value<=80)?10:Math.max(0,10-((doc[‘cpu_total_percentage’].value-80)/ 2f));} if(doc.containsKey(‘memory_total_bytes_available’)&&doc[‘memory_total_bytes_available’].size()!=0){float mb_available=doc[‘memory_total_bytes_available’].value / 1048576f;score+=(mb_available<100)?(mb_available / 10f):10;score_divisor++;} if(doc.containsKey(‘latency_result_1’)&&doc[‘latency_result_1’].size()!=0){score+=(doc[‘latency_result_1’].value<=50)?10:Math.max(0,10-((doc[‘latency_result_1’].value-50)/ 20f));score_divisor++;} if(doc.containsKey(‘wifi_signal’)&&doc[‘wifi_signal’].size()!=0&&doc[‘wifi_signal’].value>=0){score+=(doc[‘wifi_signal’].value>90)?10:Math.max(0,(doc[‘wifi_signal’].value-30)/ 6f);score_divisor++;} if(doc.containsKey(‘cpu_queue_length_history.keyword’)&&doc[‘cpu_queue_length_history.keyword’].size()!=0&&doc[‘platform’].value==1){String history=doc[‘cpu_queue_length_history.keyword’].value;int count=0;int pos=1;while(pos<(history.length()-1)){if(history.charAt(pos)==48&&(history.charAt(pos-1)==44||history.charAt(pos-1)==91)){count++;} pos++;} score+=10-Math.max(0, (10-(count2)));score_divisor++;} if(doc.containsKey(‘user_input_delay_max’)&&doc[‘user_input_delay_max’].size()!=0){score+=(doc[‘user_input_delay_max’].value<=1000)?10:Math.max(0,10-((doc[‘user_input_delay_max’].value-1000)/ 4000f));score_divisor++;} score=(score / score_divisor); if(doc.containsKey(‘app_crashes_history.keyword’)&&doc[‘app_crashes_history.keyword’].size()!=0){String history=doc[‘app_crashes_history.keyword’].value;int count=0;int pos=1;while(pos<(history.length()-1)){if(history.charAt(pos)!=48&&(history.charAt(pos-1)==44||history.charAt(pos-1)==91)){count++;} pos++;} score=Math.max(0,score-(count2));} if(doc.containsKey(‘user_logon_duration’)&&doc[‘user_logon_duration’].size()!=0){score = Math.max(0, score – Math.min(3, Math.max(0, (doc[‘user_logon_duration’].value – 3000) / 9000f)));} return score;"
}
}
}
},
"device_query": null,
"export": false
}“`
Thank you for this, that’s very helpful for me, only thing I have noticed it only returns 100 devices, do you run any pagination when running these?
Yup. Size and from near the top
Thank you 🙂
Continue reading and comment on the thread ‘How to Retrieve Device Scores Through ControlUp’s API’. Not a member? Join Here!
Categories: All Archives, ControlUp for Desktops, ControlUp Scripts & Triggers
