# sched\_requirements and custom attributes

**URL:** <https://forum.opennebula.io/t/sched-requirements-and-custom-attributes/2129>\
**Category:** Product Support\
**Created:** [April 21, 2016, 2:49pm UTC](https://forum.opennebula.io/t/sched-requirements-and-custom-attributes/2129 "2016-04-21T14:49:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boolman](https://avatars.discourse-cdn.com/v4/letter/b/bc79bd/32.png) [@boolman](https://forum.opennebula.io/u/boolman)\
**Post date:** [April 21, 2016, 2:49pm UTC](https://forum.opennebula.io/t/sched-requirements-and-custom-attributes/2129/1 "2016-04-21T14:49:04Z")

</div>

I’m having trouble getting sched\_requirements to work with my custom attributes. what am I doing wrong here?

Here is the log entry form /var/log/one/sched.log:  
Thu Apr 21 16:46:38 2016 [Z0][SCHED][D]: Match-making results for VM 241:  
Cannot schedule VM. Error in SCHED\_REQUIREMENTS: ‘CLUSTER\_ID = 100 & !(PUBLIC\_CLOUD = YES) & ( LOAD15 \< MAX\_CPU )’, error: syntax error, unexpected STRING, expecting INTEGER or FLOAT at line 1, columns 55:62

Thu Apr 21 16:46:38 2016 [Z0][SCHED][D]: Match-making results for VM 241:  
Cannot schedule VM, there is no suitable host.

Here is my custom script that adds the LOAD-attributes:  
#!/usr/bin/ruby  
loadavg = File.read(’/proc/loadavg’)  
loads = loadavg.scan(/\d+.\d+/)  
onemin = loads[0].to\_f  
fivemin = loads[1].to\_f  
fifteenmin = loads[2].to\_f  
printf(“LOAD1=%d\nLOAD5=%d\nLOAD15=%d\n”, (onemin_100).to\_i, (fivemin_100).to\_i, (fifteenmin\*100).to\_i)

Here is the host information:

# onehost show 0 | head -n 60

HOST 0 INFORMATION  
ID : 0  
NAME : node01  
CLUSTER : dc01  
STATE : MONITORED  
IM\_MAD : kvm  
VM\_MAD : kvm  
VN\_MAD : ovswitch  
LAST MONITORING TIME : 04/21 16:45:27

HOST SHARES  
TOTAL MEM : 251.8G  
USED MEM (REAL) : 7.8G  
USED MEM (ALLOCATED) : 512M  
TOTAL CPU : 4800  
USED CPU (REAL) : 0  
USED CPU (ALLOCATED) : 100  
RUNNING VMS : 1

MONITORING INFORMATION  
ARCH="x86\_64"  
CPUSPEED="1489"  
HOSTNAME="node01"  
HYPERVISOR="kvm"  
IM\_MAD="kvm"  
LOAD1="4"  
LOAD15="36"  
LOAD5="25"  
MODELNAME="Intel® Xeon® CPU E5-2680 v3 @ 2.50GHz"  
NETRX="1199403926447"  
NETTX="1243839796855"  
NUM\_NODES=“3"  
RESERVED\_CPU=”“  
RESERVED\_MEM=”"  
VERSION="4.14.2"  
VM\_MAD="kvm"  
VN\_MAD=“ovswitch”

Here is my template:

# onetemplate show 16

TEMPLATE 16 INFORMATION  
ID : 16  
NAME : ubuntu14\_tmpl  
USER : oneadmin  
GROUP : DEVOPS  
REGISTER TIME : 04/14 13:18:13

PERMISSIONS  
OWNER : um-  
GROUP : um-  
OTHER : —

TEMPLATE CONTENTS  
CONTEXT=[  
CHEF\_BOOTSTRAP=“true”,  
DHCP=“true”,  
NETWORK=“YES”,  
SET\_HOSTNAME="$NAME",  
SSH\_PUBLIC\_KEY="$USER[SSH\_PUBLIC\_KEY]" ]  
CPU=“1"  
DISK=[  
IMAGE=“os\_ubuntu\_v1.0-copy”,  
IMAGE\_UNAME=“oneadmin” ]  
GRAPHICS=[  
LISTEN=“0.0.0.0”,  
TYPE=“SPICE” ]  
HYPERVISOR=“kvm"  
MEMORY=“512"  
NIC\_DEFAULT=[  
MODEL=“virtio” ]  
OS=[  
BOOT=“cdrom,hd” ]  
RAW=[  
DATA=””,  
TYPE=“kvm” ]  
SCHED\_RANK=”- RUNNING\_VMS"  
SCHED\_REQUIREMENTS=“LOAD15 \< MAX\_CPU”

---

<div class="post-metadata">

**Author:** ![boolman](https://avatars.discourse-cdn.com/v4/letter/b/bc79bd/32.png) [@boolman](https://forum.opennebula.io/u/boolman)\
**Post date:** [May 2, 2016, 8:27am UTC](https://forum.opennebula.io/t/sched-requirements-and-custom-attributes/2129/2 "2016-05-02T08:27:08Z")

</div>

oh, i figured out that I can’t use math in the requirements… so I moved it to a script on each host and then just eval the string… SCHED\_REQ… = MY\_VAR = 1
