]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskDaemon/DiskDaemonDiskIOModule.cc
e7793d1b8e5f212e7d862069996f68187a085eef
[thirdparty/squid.git] / src / DiskIO / DiskDaemon / DiskDaemonDiskIOModule.cc
1
2 /*
3 * $Id: DiskDaemonDiskIOModule.cc,v 1.4 2007/04/12 19:37:24 wessels Exp $
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 "CacheManager.h"
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));
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 */
69 debugs(47, 1, "diskd started");
70 #endif
71 initialised = true;
72
73 registerWithCacheManager();
74 }
75
76 void
77 DiskDaemonDiskIOModule::registerWithCacheManager(void)
78 {
79 CacheManager::GetInstance()->registerAction("diskd", "DISKD Stats", Stats, 0, 1);
80 }
81
82 void
83 DiskDaemonDiskIOModule::shutdown()
84 {
85 initialised = false;
86 }
87
88 DiskIOStrategy *
89 DiskDaemonDiskIOModule::createStrategy()
90 {
91 return new DiskdIOStrategy();
92 }
93
94 DiskDaemonDiskIOModule DiskDaemonDiskIOModule::Instance;
95
96 void
97 DiskDaemonDiskIOModule::Stats(StoreEntry * sentry)
98 {
99 storeAppendPrintf(sentry, "sent_count: %d\n", diskd_stats.sent_count);
100 storeAppendPrintf(sentry, "recv_count: %d\n", diskd_stats.recv_count);
101 storeAppendPrintf(sentry, "max_away: %d\n", diskd_stats.max_away);
102 storeAppendPrintf(sentry, "max_shmuse: %d\n", diskd_stats.max_shmuse);
103 storeAppendPrintf(sentry, "open_fail_queue_len: %d\n", diskd_stats.open_fail_queue_len);
104 storeAppendPrintf(sentry, "block_queue_len: %d\n", diskd_stats.block_queue_len);
105 diskd_stats.max_away = diskd_stats.max_shmuse = 0;
106 storeAppendPrintf(sentry, "\n OPS SUCCESS FAIL\n");
107 storeAppendPrintf(sentry, "%7s %9d %9d %7d\n",
108 "open", diskd_stats.open.ops, diskd_stats.open.success, diskd_stats.open.fail);
109 storeAppendPrintf(sentry, "%7s %9d %9d %7d\n",
110 "create", diskd_stats.create.ops, diskd_stats.create.success, diskd_stats.create.fail);
111 storeAppendPrintf(sentry, "%7s %9d %9d %7d\n",
112 "close", diskd_stats.close.ops, diskd_stats.close.success, diskd_stats.close.fail);
113 storeAppendPrintf(sentry, "%7s %9d %9d %7d\n",
114 "unlink", diskd_stats.unlink.ops, diskd_stats.unlink.success, diskd_stats.unlink.fail);
115 storeAppendPrintf(sentry, "%7s %9d %9d %7d\n",
116 "read", diskd_stats.read.ops, diskd_stats.read.success, diskd_stats.read.fail);
117 storeAppendPrintf(sentry, "%7s %9d %9d %7d\n",
118 "write", diskd_stats.write.ops, diskd_stats.write.success, diskd_stats.write.fail);
119 }
120
121 char const *
122 DiskDaemonDiskIOModule::type () const
123 {
124 return "DiskDaemon";
125 }