]>
Commit | Line | Data |
---|---|---|
b9ae18aa | 1 | |
2 | /* | |
64ffef5e | 3 | * $Id: DiskDaemonDiskIOModule.cc,v 1.2 2005/05/01 10:49:03 serassio Exp $ |
b9ae18aa | 4 | * |
5 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
6 | * ---------------------------------------------------------- | |
7 | * | |
8 | * Squid is the result of efforts by numerous individuals from | |
9 | * the Internet community; see the CONTRIBUTORS file for full | |
10 | * details. Many organizations have provided support for Squid's | |
11 | * development; see the SPONSORS file for full details. Squid is | |
12 | * Copyrighted (C) 2001 by the Regents of the University of | |
13 | * California; see the COPYRIGHT file for full details. Squid | |
14 | * incorporates software developed and/or copyrighted by other | |
15 | * sources; see the CREDITS file for full details. | |
16 | * | |
17 | * This program is free software; you can redistribute it and/or modify | |
18 | * it under the terms of the GNU General Public License as published by | |
19 | * the Free Software Foundation; either version 2 of the License, or | |
20 | * (at your option) any later version. | |
21 | * | |
22 | * This program is distributed in the hope that it will be useful, | |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | * GNU General Public License for more details. | |
26 | * | |
27 | * You should have received a copy of the GNU General Public License | |
28 | * along with this program; if not, write to the Free Software | |
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
30 | * | |
31 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
32 | */ | |
33 | ||
34 | #include "squid.h" | |
35 | #include "DiskDaemonDiskIOModule.h" | |
36 | #include "DiskdIOStrategy.h" | |
37 | #include "Store.h" | |
38 | ||
39 | DiskDaemonDiskIOModule::DiskDaemonDiskIOModule() : initialised(false) | |
40 | { | |
41 | ModuleAdd(*this); | |
42 | } | |
43 | ||
44 | DiskDaemonDiskIOModule & | |
45 | DiskDaemonDiskIOModule::GetInstance() | |
46 | { | |
47 | return Instance; | |
48 | } | |
49 | ||
50 | void | |
51 | DiskDaemonDiskIOModule::init() | |
52 | { | |
53 | /* We may be reused - for instance in coss - eventually. | |
54 | * When we do, we either need per-using-module stats ( | |
55 | * no singleton pattern), or we need to refcount the | |
56 | * initialisation level and handle multiple clients. | |
57 | * RBC - 20030718. | |
58 | */ | |
59 | assert(!initialised); | |
60 | memset(&diskd_stats, '\0', sizeof(diskd_stats)); | |
61 | cachemgrRegister("diskd", "DISKD Stats", Stats, 0, 1); | |
62 | ||
63 | debug(47, 1) ("diskd started\n"); | |
64 | initialised = true; | |
65 | } | |
66 | ||
67 | void | |
68 | DiskDaemonDiskIOModule::shutdown() | |
69 | { | |
70 | initialised = false; | |
71 | } | |
72 | ||
73 | DiskIOStrategy * | |
74 | DiskDaemonDiskIOModule::createStrategy() | |
75 | { | |
76 | return new DiskdIOStrategy(); | |
77 | } | |
78 | ||
79 | DiskDaemonDiskIOModule DiskDaemonDiskIOModule::Instance; | |
80 | ||
81 | void | |
82 | DiskDaemonDiskIOModule::Stats(StoreEntry * sentry) | |
83 | { | |
84 | storeAppendPrintf(sentry, "sent_count: %d\n", diskd_stats.sent_count); | |
85 | storeAppendPrintf(sentry, "recv_count: %d\n", diskd_stats.recv_count); | |
86 | storeAppendPrintf(sentry, "max_away: %d\n", diskd_stats.max_away); | |
87 | storeAppendPrintf(sentry, "max_shmuse: %d\n", diskd_stats.max_shmuse); | |
88 | storeAppendPrintf(sentry, "open_fail_queue_len: %d\n", diskd_stats.open_fail_queue_len); | |
89 | storeAppendPrintf(sentry, "block_queue_len: %d\n", diskd_stats.block_queue_len); | |
90 | diskd_stats.max_away = diskd_stats.max_shmuse = 0; | |
64ffef5e | 91 | storeAppendPrintf(sentry, "\n OPS SUCCESS FAIL\n"); |
92 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", | |
b9ae18aa | 93 | "open", diskd_stats.open.ops, diskd_stats.open.success, diskd_stats.open.fail); |
64ffef5e | 94 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 95 | "create", diskd_stats.create.ops, diskd_stats.create.success, diskd_stats.create.fail); |
64ffef5e | 96 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 97 | "close", diskd_stats.close.ops, diskd_stats.close.success, diskd_stats.close.fail); |
64ffef5e | 98 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 99 | "unlink", diskd_stats.unlink.ops, diskd_stats.unlink.success, diskd_stats.unlink.fail); |
64ffef5e | 100 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 101 | "read", diskd_stats.read.ops, diskd_stats.read.success, diskd_stats.read.fail); |
64ffef5e | 102 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 103 | "write", diskd_stats.write.ops, diskd_stats.write.success, diskd_stats.write.fail); |
104 | } | |
105 | ||
106 | char const * | |
107 | DiskDaemonDiskIOModule::type () const | |
108 | { | |
109 | return "DiskDaemon"; | |
110 | } |