From fc1bba730ff98e6765274c024ac51b192641f155 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 1 Dec 2024 04:54:43 +0100 Subject: [PATCH] Initial commit. --- .clang-format | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 10 +++ dot | Bin 0 -> 18000 bytes dot.c | 43 +++++++++++ 4 files changed, 245 insertions(+) create mode 100644 .clang-format create mode 100644 Makefile create mode 100755 dot create mode 100644 dot.c diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..de7da58 --- /dev/null +++ b/.clang-format @@ -0,0 +1,192 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 140 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: BinPack +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentRequires: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 +PointerAlignment: Right +PPIndentWidth: -1 +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME +... + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..618fa7a --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +CC = gcc +CFLAGS = -Wextra -Wall -Werror -pedantic -Ofast + +all: dot run + +dot: dot.c + $(CC) $(CFLAGS) dot.c -o dot + +run: + ./dot my-service diff --git a/dot b/dot new file mode 100755 index 0000000000000000000000000000000000000000..624e6f9243300544dffd5f799ffad7c3c2525a55 GIT binary patch literal 18000 zcmeHPeQ+Dcbzgv=5@it7heb(ocy>UAssoUeD2B4D7?eoq=%Fmtq7vIxd zk|;udZ*SiLxB#^$O{f20hq$-zx9|6M@7>cmF`X^R_dB&-S+ zeoXY*u(3B=OoQQ$fDZh6PJ*AxYv@OHZf@ zSPH*wNxTNiD%~wVFAIfW$>mOc8j+DSxh+bye}ZL6eH5GNplv_Bw_Ki4_KPkasl_0M#eSChjws%7O}Y_3 zC2d$7SCZ@dCGaRN?=|sZzEjm#?Kmu`__I{u72V0icz<7aG8RlGQn{Jn%s_vzzb}+c zhjz*)P`fnzsM{R8;}{+OCBjq~g?HB0*&mf{ROMvq_RqUx>Rr3FJ;2M7JbQ^$5_S>uATdLr3JwmHdATxQ3rQ(P>x7z7Ket*ed*C zo5AN#1nNyTRKA@yGnsTo7)I8LMDI7EllL3(NFoVfI+I9QaY95qp3G$@MJ}5(&1sRf zV(FX(k%?Q0DN{_CRx%xlMIM|03;i)lzA~0E6-lIkL}wyKJduhd6DLiPOh+S0$s$AQ zr~TsK=*YhP#?H{LP@j`8=5`gcJ43sLF*0_@h?yC4B9XPs%-Es*$#lvbi;O2t)HN}c zPN~`r+q9w~_0Kx=O)suRwDscrpsk&!zUx8BNk~3Ftu2W)bQV3Tu#Jhtb#x_LQ2Gl` zKZ9;wCqAR}+*Y#pia&r(iLa}CJQnCALz+?7O$S%^vso8@MA*uM1BGI{4 zdLCXV!TFpgyOk2$K0gV?^|}OKXG3y(r37y+!MUH&^@YxNP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&*N|Zd*rvN`jt7m70lo6Aa;h@N{QuG#kbMowqH4P`(++m?x@0#E27DUO1k;G ztMI?3_@nQ_-(Q8lxz{E}--Ulz@!k7*Qt@f-PibP62mI_zYS)U_}*J>{;#_TE>-+DmH|ab literal 0 HcmV?d00001 diff --git a/dot.c b/dot.c new file mode 100644 index 0000000..39264f9 --- /dev/null +++ b/dot.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +void print_datetime(time_t now) { + struct tm *local = localtime(&now); + char buffer[20]; + strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M", local); + printf("%s", buffer); +} + +void print_load() { + double loadavg[3]; + if (getloadavg(loadavg, 3) == -1) { + perror("getloadavg failed"); + return; + } + printf("%.2f %.2f %.2f", loadavg[0], loadavg[1], loadavg[2]); +} + +int main(int argc, char *argv[]) { + time_t start_time = time(NULL); + while (true) { + for(int i = 1; i < argc; i++){ + printf("%s ", argv[i]); + } + if(argc == 1){ + printf("%s", "\rUpdate "); + } + print_datetime(time(NULL)); + printf("%s", " since "); + print_datetime(start_time); + printf("%s", ". "); + printf("%s", "Load: "); + print_load(); + printf(".%s", "\n"); + fflush(stdout); + usleep(30 * 1000 * 1000); + } + return 0; +}