This file is indexed.

/usr/lib/oar/detect_resources is in oar-server 2.5.2-4.1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# $Id$
# Detect resources on a list of nodes and print corresponding OAR commands
#set -x

OPENSSH_CMD=/usr/bin/ssh
. "$OARCONFFILE" || exit 20

OARNODES="oarnodesetting"
OARPROPERTY="oarproperty"
FILE_WITH_OAR_COMMANDS_GENERATED="/tmp/oar_resources_init.txt"

# check the file with the nodes to add
if [ -z "$1" ] || [ ! -r "$1" ]
then
    echo "Specify a file containing the list of nodes to add into OAR in argument of this command (must be readable by oar user)"
    exit 1
fi

echo "Did you configured the OAR SSH key on all the nodes? [yes/NO] "
read l ; [ "$l" != "yes" ] && exit 2

# Check output file
if [ -e "$FILE_WITH_OAR_COMMANDS_GENERATED" ]
then
    echo "Commands to run will be written into "$FILE_WITH_OAR_COMMANDS_GENERATED". Do you want to override it? [yes/NO] "
    read l ; [ "$l" != "yes" ] && exit 3
    rm $FILE_WITH_OAR_COMMANDS_GENERATED || exit 4
fi

# Add properties
echo "$OARPROPERTY -a cpu" > $FILE_WITH_OAR_COMMANDS_GENERATED
echo "$OARPROPERTY -a core" >> $FILE_WITH_OAR_COMMANDS_GENERATED
echo "$OARPROPERTY -c -a host" >> $FILE_WITH_OAR_COMMANDS_GENERATED
echo "$OARPROPERTY -a cpuset" >> $FILE_WITH_OAR_COMMANDS_GENERATED
echo "$OARPROPERTY -a mem" >> $FILE_WITH_OAR_COMMANDS_GENERATED

# Init CPU id
CPU=$(oarnodes --sql true | grep 'cpu=' | awk -F " cpu=" '{print $2}' | awk -F "," '{print $1}' | sort -r -n | head -1)
[ -z "$CPU" ] && CPU=0
# Init CORE id
CORE=$(oarnodes --sql true | grep 'core=' | awk -F " core=" '{print $2}' | awk -F "," '{print $1}' | sort -r -n | head -1)
[ -z "$CORE" ] && CORE=0

echo
for host in $(< $1)
do
    echo -n "Checking $host ... "

    # Store stderr and redirect it to /dev/null
    exec 3>&2
    exec 2> /dev/null

    mem=$($OPENSSH_CMD $host cat /proc/meminfo | grep ^MemTotal | awk '{print $2}')

    # Get CORE info in the form:
    # core:cpu
    # core:cpu
    # core:cpu
    # ...
    if [ "`$OPENSSH_CMD $host cat /proc/cpuinfo|grep 'physical id'`" != "" ]
    then
      DATA=$($OPENSSH_CMD $host cat /proc/cpuinfo| awk '{if ($1 == "processor") core=$3; if ($1 == "physical" && $2 =="id") print $4 ":" core}'|sort -n)
    else
      DATA=$($OPENSSH_CMD $host cat /proc/cpuinfo| awk '{if ($1 == "processor") print $3 ":" $3}'|sort -n)
    fi

    # Restore stderr
    exec 2>&3

    if [ -z "$mem" ] || [ -z "$DATA" ]
    then
        echo "*** KO ***"
        rm $FILE_WITH_OAR_COMMANDS_GENERATED
        echo 
        echo "ERROR with node $host. Please check the ssh connection with oar user ($OPENSSH_CMD $host)..."
        exit 5
    fi

    ((mem = $mem / 1024))
    prev_cpu="-1"
    for i in $DATA
    do
        core=$(echo $i|awk -F: '{print $2}')
        cpu=$(echo $i|awk -F: '{print $1}')
        [ "$cpu" != "$prev_cpu" ] && ((CPU++))
        ((CORE++))
        prev_cpu=$cpu
        echo "oarnodesetting -a -h $host -p host=$host -p cpu=$CPU -p core=$CORE -p cpuset=$core -p mem=$mem" >> $FILE_WITH_OAR_COMMANDS_GENERATED
    done
    echo "OK"
done



echo
echo "If the content of '$FILE_WITH_OAR_COMMANDS_GENERATED' is OK for you then you just need to execute:"
echo "  source $FILE_WITH_OAR_COMMANDS_GENERATED"