239 |
"'%s' unable to read device %s state", s->name, s->path); |
"'%s' unable to read device %s state", s->name, s->path); |
240 |
return FALSE; |
return FALSE; |
241 |
} else { |
} else { |
242 |
|
s->inf->inode_percent= |
243 |
|
(int)((float)(1000 * (s->inf->f_files - s->inf->f_filesfree)) / |
244 |
|
(float)s->inf->f_files); |
245 |
|
s->inf->space_percent= |
246 |
|
(int)((float)(1000 * (s->inf->f_blocks - s->inf->f_blocksfree)) / |
247 |
|
(float)s->inf->f_blocks); |
248 |
|
s->inf->inode_total= s->inf->f_files - s->inf->f_filesfree; |
249 |
|
s->inf->space_total= s->inf->f_blocks - s->inf->f_blocksfreetotal; |
250 |
Event_post(s, EVENT_DATA, FALSE, s->action_DATA, |
Event_post(s, EVENT_DATA, FALSE, s->action_DATA, |
251 |
"'%s' succeeded getting device statistic for %s", s->name, s->path); |
"'%s' succeeded getting device statistic for %s", s->name, s->path); |
252 |
} |
} |
914 |
} |
} |
915 |
|
|
916 |
if(td->limit_percent >= 0) { |
if(td->limit_percent >= 0) { |
917 |
int value = |
if(compare_value( td->operator, s->inf->inode_percent, td->limit_percent)) { |
|
(int)((float)(100 * (s->inf->f_files - s->inf->f_filesfree)) / |
|
|
(float)s->inf->f_files); |
|
|
if(compare_value( td->operator, value, td->limit_percent)) { |
|
918 |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
919 |
"'%s' inode usage %ld%% matches resource limit [inode usage%s%d%%]", |
"'%s' inode usage %ld%% matches resource limit [inode usage%s%d%%]", |
920 |
s->name, |
s->name, |
921 |
value, |
s->inf->inode_percent/10., |
922 |
operatorshortnames[td->operator], |
operatorshortnames[td->operator], |
923 |
td->limit_percent); |
td->limit_percent/10.); |
924 |
return; |
return; |
925 |
} |
} |
926 |
} else { |
} else { |
927 |
int value = s->inf->f_files - s->inf->f_filesfree; |
if(compare_value(td->operator, s->inf->inode_total, td->limit_absolute)) { |
|
if(compare_value(td->operator, value, td->limit_absolute)) { |
|
928 |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
929 |
"'%s' inode usage %ld matches resource limit [inode usage%s%ld]", |
"'%s' inode usage %ld matches resource limit [inode usage%s%ld]", |
930 |
s->name, |
s->name, |
931 |
value, |
s->inf->inode_total, |
932 |
operatorshortnames[td->operator], |
operatorshortnames[td->operator], |
933 |
td->limit_absolute); |
td->limit_absolute); |
934 |
return; |
return; |
935 |
} |
} |
936 |
} |
} |
937 |
DEBUG("'%s' inode usage check passed [current inode usage=%.1f%%]\n", |
DEBUG("'%s' inode usage check passed [current inode usage=%.1f%%]\n", |
938 |
s->name, |
s->name, s->inf->inode_percent/10.); |
|
(float)(100 * (s->inf->f_files - s->inf->f_filesfree)) / |
|
|
(float)s->inf->f_files); |
|
939 |
Event_post(s, EVENT_RESOURCE, FALSE, td->action, |
Event_post(s, EVENT_RESOURCE, FALSE, td->action, |
940 |
"'%s' device resources passed", s->name); |
"'%s' device resources passed", s->name); |
941 |
return; |
return; |
942 |
|
|
943 |
case RESOURCE_ID_SPACE: |
case RESOURCE_ID_SPACE: |
944 |
if(td->limit_percent >= 0) { |
if(td->limit_percent >= 0) { |
945 |
int value = |
if(compare_value( td->operator, s->inf->space_percent, td->limit_percent)) { |
|
(int)((float)(100 * (s->inf->f_blocks - s->inf->f_blocksfreetotal)) / |
|
|
(float)s->inf->f_blocks); |
|
|
if(compare_value( td->operator, value, td->limit_percent)) { |
|
946 |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
947 |
"'%s' space usage %ld%% matches resource limit [space usage%s%d%%]", |
"'%s' space usage %ld%% matches resource limit [space usage%s%d%%]", |
948 |
s->name, |
s->name, |
949 |
value, |
s->inf->space_percent/10., |
950 |
operatorshortnames[td->operator], |
operatorshortnames[td->operator], |
951 |
td->limit_percent); |
td->limit_percent/10.); |
952 |
return; |
return; |
953 |
} |
} |
954 |
} else { |
} else { |
955 |
int value = s->inf->f_blocks - s->inf->f_blocksfreetotal; |
if(compare_value(td->operator, s->inf->space_total, td->limit_absolute)) { |
|
if(compare_value(td->operator, value, td->limit_absolute)) { |
|
956 |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
Event_post(s, EVENT_RESOURCE, TRUE, td->action, |
957 |
"'%s' space usage %ld blocks matches resource limit " |
"'%s' space usage %ld blocks matches resource limit " |
958 |
"[space usage%s%ld blocks]", |
"[space usage%s%ld blocks]", |
959 |
s->name, |
s->name, |
960 |
value, |
s->inf->space_total, |
961 |
operatorshortnames[td->operator], |
operatorshortnames[td->operator], |
962 |
td->limit_absolute); |
td->limit_absolute); |
963 |
return; |
return; |
964 |
} |
} |
965 |
} |
} |
966 |
DEBUG("'%s' space usage check passed [current space usage=%.1f%%]\n", |
DEBUG("'%s' space usage check passed [current space usage=%.1f%%]\n", |
967 |
s->name, |
s->name, s->inf->space_percent/10.); |
|
(float)(100 * (s->inf->f_blocks - s->inf->f_blocksfreetotal)) / |
|
|
(float)s->inf->f_blocks); |
|
968 |
Event_post(s, EVENT_RESOURCE, FALSE, td->action, |
Event_post(s, EVENT_RESOURCE, FALSE, td->action, |
969 |
"'%s' device resources passed", s->name); |
"'%s' device resources passed", s->name); |
970 |
return; |
return; |