]>
Commit | Line | Data |
---|---|---|
b9ae18aa | 1 | |
2 | /* | |
af00d03d | 3 | * $Id: DiskDaemonDiskIOModule.cc,v 1.4 2007/04/12 19:37:24 wessels 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" | |
62ee09ca | 36 | #include "CacheManager.h" |
b9ae18aa | 37 | #include "DiskdIOStrategy.h" |
38 | #include "Store.h" | |
39 | ||
40 | DiskDaemonDiskIOModule::DiskDaemonDiskIOModule() : initialised(false) | |
41 | { | |
42 | ModuleAdd(*this); | |
43 | } | |
44 | ||
45 | DiskDaemonDiskIOModule & | |
46 | DiskDaemonDiskIOModule::GetInstance() | |
47 | { | |
48 | return Instance; | |
49 | } | |
50 | ||
51 | void | |
52 | DiskDaemonDiskIOModule::init() | |
53 | { | |
54 | /* We may be reused - for instance in coss - eventually. | |
55 | * When we do, we either need per-using-module stats ( | |
56 | * no singleton pattern), or we need to refcount the | |
57 | * initialisation level and handle multiple clients. | |
58 | * RBC - 20030718. | |
59 | */ | |
60 | assert(!initialised); | |
61 | memset(&diskd_stats, '\0', sizeof(diskd_stats)); | |
af00d03d | 62 | #if 0 |
63 | /* | |
64 | * DPW 2007-04-12 | |
65 | * No debugging here please because this method is called before | |
66 | * the debug log is configured and we'll get the message on | |
67 | * stderr when doing things like 'squid -k reconfigure' | |
68 | */ | |
62ee09ca | 69 | debugs(47, 1, "diskd started"); |
af00d03d | 70 | #endif |
b9ae18aa | 71 | initialised = true; |
72 | } | |
73 | ||
62ee09ca | 74 | void |
15fab853 | 75 | DiskDaemonDiskIOModule::registerWithCacheManager(void) |
62ee09ca | 76 | { |
15fab853 | 77 | CacheManager::GetInstance()->registerAction("diskd", "DISKD Stats", Stats, 0, 1); |
62ee09ca | 78 | } |
79 | ||
b9ae18aa | 80 | void |
81 | DiskDaemonDiskIOModule::shutdown() | |
82 | { | |
83 | initialised = false; | |
84 | } | |
85 | ||
86 | DiskIOStrategy * | |
87 | DiskDaemonDiskIOModule::createStrategy() | |
88 | { | |
89 | return new DiskdIOStrategy(); | |
90 | } | |
91 | ||
92 | DiskDaemonDiskIOModule DiskDaemonDiskIOModule::Instance; | |
93 | ||
94 | void | |
95 | DiskDaemonDiskIOModule::Stats(StoreEntry * sentry) | |
96 | { | |
97 | storeAppendPrintf(sentry, "sent_count: %d\n", diskd_stats.sent_count); | |
98 | storeAppendPrintf(sentry, "recv_count: %d\n", diskd_stats.recv_count); | |
99 | storeAppendPrintf(sentry, "max_away: %d\n", diskd_stats.max_away); | |
100 | storeAppendPrintf(sentry, "max_shmuse: %d\n", diskd_stats.max_shmuse); | |
101 | storeAppendPrintf(sentry, "open_fail_queue_len: %d\n", diskd_stats.open_fail_queue_len); | |
102 | storeAppendPrintf(sentry, "block_queue_len: %d\n", diskd_stats.block_queue_len); | |
103 | diskd_stats.max_away = diskd_stats.max_shmuse = 0; | |
64ffef5e | 104 | storeAppendPrintf(sentry, "\n OPS SUCCESS FAIL\n"); |
105 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", | |
b9ae18aa | 106 | "open", diskd_stats.open.ops, diskd_stats.open.success, diskd_stats.open.fail); |
64ffef5e | 107 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 108 | "create", diskd_stats.create.ops, diskd_stats.create.success, diskd_stats.create.fail); |
64ffef5e | 109 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 110 | "close", diskd_stats.close.ops, diskd_stats.close.success, diskd_stats.close.fail); |
64ffef5e | 111 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 112 | "unlink", diskd_stats.unlink.ops, diskd_stats.unlink.success, diskd_stats.unlink.fail); |
64ffef5e | 113 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 114 | "read", diskd_stats.read.ops, diskd_stats.read.success, diskd_stats.read.fail); |
64ffef5e | 115 | storeAppendPrintf(sentry, "%7s %9d %9d %7d\n", |
b9ae18aa | 116 | "write", diskd_stats.write.ops, diskd_stats.write.success, diskd_stats.write.fail); |
117 | } | |
118 | ||
119 | char const * | |
120 | DiskDaemonDiskIOModule::type () const | |
121 | { | |
122 | return "DiskDaemon"; | |
123 | } |