icwmp/scripts/functions/misc
2013-07-17 16:23:54 +02:00

40 lines
No EOL
1.2 KiB
Bash

#!/bin/sh
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
# Copyright (C) 2012 Ahmed Zribi <ahmed.zribi@pivasoftware.com>
get_misc_cpu_usage() {
local val=`uptime | awk -F'average: ' '{ print $2 }' | awk -F',' '{ print $1 }' | awk -F'.' '{ print $2 }'`
freecwmp_output "Device.DeviceInfo.ProcessStatus.CPUUsage" "$val"
}
get_misc_process_number() {
local val=`ps | grep -v COMMAND | wc -l`
local type="xsd:unsignedInt"
freecwmp_output "Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries" "$val" "" "$type"
}
get_misc() {
case "$1" in
Device.DeviceInfo.ProcessStatus.CPUUsage)
get_misc_cpu_usage
return $FAULT_CPE_NO_FAULT
;;
Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries)
get_misc_process_number
return $FAULT_CPE_NO_FAULT
;;
esac
return $FAULT_CPE_INVALID_PARAMETER_NAME
}
get_misc_name () { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
get_misc_notification () { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
set_misc() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
set_misc_notification () { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
add_misc() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }
delete_misc() { return $FAULT_CPE_INVALID_PARAMETER_NAME; }