From df8414af63347fa1f5f50fc2003cad7c9fda5c77 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 27 Jul 2014 17:16:04 +0800 Subject: [PATCH] api connections add udp, add disk iops. 0.9.176 --- README.md | 1 + trunk/src/app/srs_app_utility.cpp | 31 ++++++++++++++++++++++++------- trunk/src/app/srs_app_utility.hpp | 5 +++++ trunk/src/core/srs_core.hpp | 2 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 238e45df1..3162994c9 100755 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ Supported operating systems and hardware: * 2013-10-17, Created.
## History +* v1.0, 2014-07-27, api connections add udp, add disk iops. 0.9.176 * v1.0, 2014-07-26, complete config utest. 0.9.173 * v1.0, 2014-07-26, fix [#124](https://github.com/winlinvip/simple-rtmp-server/issues/124), gop cache support disable video in publishing. 0.9.171. * v1.0, 2014-07-23, fix [#121](https://github.com/winlinvip/simple-rtmp-server/issues/121), srs_info detail log compile failed. 0.9.168. diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index f28131cdf..d8d2523fe 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -244,11 +244,6 @@ bool get_proc_system_stat(SrsProcSystemStat& r) // matched ok. r.ok = true; - - // @see: http://tester-higkoo.googlecode.com/svn-history/r14/trunk/Tools/iostat/iostat.c - // add the interrupts to sys. - // TODO: FIXME: check out it. - r.sys += r.irq + r.softirq; break; } @@ -362,6 +357,7 @@ SrsDiskStat::SrsDiskStat() ok = false; sample_time = 0; in_KBps = out_KBps = 0; + busy = 0; pgpgin = 0; pgpgout = 0; @@ -515,6 +511,26 @@ void srs_update_disk_stat() r.out_KBps = (r.pgpgout - o.pgpgout) * 1000 / duration_ms; } } + + // diskstats + if (true) { + SrsProcSystemStat* cpu = srs_get_system_proc_stat(); + SrsCpuInfo* cpuinfo = srs_get_cpuinfo(); + + if (cpu->ok && cpu->total_delta > 0 + && cpuinfo->ok && cpuinfo->nb_processors > 0 + && o.ticks < r.ticks + ) { + // @see: print_partition_stats() of iostat.c + double delta_ms = cpu->total_delta * 10 / cpuinfo->nb_processors; + unsigned int ticks = r.ticks - o.ticks; + + // busy in [0, 1], where 0.1532 means 15.32% + r.busy = srs_min(1, (float)(ticks / delta_ms)); + } + } + + _srs_disk_stat = r; } SrsMemInfo::SrsMemInfo() @@ -1065,8 +1081,9 @@ void srs_api_dump_summaries(std::stringstream& ss) << __SRS_JOBJECT_END << __SRS_JFIELD_CONT << __SRS_JFIELD_ORG("system", __SRS_JOBJECT_START) << __SRS_JFIELD_ORG("cpu_percent", s->percent) << __SRS_JFIELD_CONT - << __SRS_JFIELD_ORG("disk_in_KBps", d->in_KBps) << __SRS_JFIELD_CONT - << __SRS_JFIELD_ORG("disk_out_KBps", d->out_KBps) << __SRS_JFIELD_CONT + << __SRS_JFIELD_ORG("disk_read_KBps", d->in_KBps) << __SRS_JFIELD_CONT + << __SRS_JFIELD_ORG("disk_write_KBps", d->out_KBps) << __SRS_JFIELD_CONT + << __SRS_JFIELD_ORG("disk_busy_percent", d->busy) << __SRS_JFIELD_CONT << __SRS_JFIELD_ORG("mem_ram_kbyte", m->MemTotal) << __SRS_JFIELD_CONT << __SRS_JFIELD_ORG("mem_ram_percent", m->percent_ram) << __SRS_JFIELD_CONT << __SRS_JFIELD_ORG("mem_swap_kbyte", m->SwapTotal) << __SRS_JFIELD_CONT diff --git a/trunk/src/app/srs_app_utility.hpp b/trunk/src/app/srs_app_utility.hpp index 099252584..dca78b67d 100644 --- a/trunk/src/app/srs_app_utility.hpp +++ b/trunk/src/app/srs_app_utility.hpp @@ -332,11 +332,16 @@ public: bool ok; // the time in ms when sample. int64_t sample_time; + // input(read) KBytes per seconds int in_KBps; // output(write) KBytes per seconds int out_KBps; + // @see: print_partition_stats() of iostat.c + // but its value is [0, 1], for instance, 0.1532 means 15.32%. + float busy; + public: // @see: cat /proc/vmstat // the in(read) page count, pgpgin*1024 is the read bytes. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 9ffd1e556..fa2d7c464 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "175" +#define VERSION_REVISION "176" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "SRS"